Changing the Appearance of your Timeline
For more technically capable creators, you can override or extend TimelineJS's CSS to have more control over how your timeline looks. To do this, you must be able to create CSS files and host them at a URL where TimelineJS can find them.
Fonts and Typography
For simple typographic styling, such as bold or italic text, you can use basic HTML tags in the headline
, text
, media credit
, and media caption
fields. You can also use tags which support the style
attribute, such as <p>
, <span>
, and <div>
. More complete documentation of HTML usage is beyond the scope of this document, but the web is full of tutorials. (Note that in limited cases, TimelineJS may strip some HTML markup that could be a potential security problem.)
The easiest way to change the fonts TimelineJS uses is to select from one of the list in the "Optional settings" section of step 3 of the Timeline authoring tool. However, if none of those font combinations work for you, you can create your own.
To create your own, you can download a model copy of a typical font CSS file from our CDN. You may want to put it through a CSS formatter before you start to edit it. If you are familiar with LESS, you may prefer to work from our LESS files on GitHub. If you set up Timeline as an `npm` project, then after you edit those files, you can run npm run dist
to compile the LESS into CSS. You'll find your generated font CSS file in the dist/css/fonts
directory.
Whether you use npm
or simply edit a copy of one of the provided font CSS files, it's up to you to put this file on a web server. If you're using the embed code to publish your timeline, then you should change the src
attribute of your iframe
so that it has a parameter font
with the URL to your font CSS as the value. This URL demonstrates setting the font with a URL, albeit in this case a URL to one of our provided font sets.
If, instead of the embed, you are directly instantiating the timeline in your page using JavaScript, see this documentation for more details.
Other CSS presentation
TimelineJS uses the Less CSS pre-processor to manage the complex number of elements, variables, and conditions needed to make everything look great. One side effect of how we use Less
is that various
style rules for TimelineJS are often very specific. Since, in CSS, more specific rules take precedence over less specific ones, you may find it easier to edit Timeline's Less
files and compile your own stylesheet than to work
out the exact selector which controls style rules.
If you want to change more than just typography, the basics are similar. You can create a Timeline CSS file by editing a copy of the main CSS file, or by
checking out TimelineJS from GitHub and using npm
to set up the development environment, and then editing the LESS files TimelineJS uses. If
you are instantiating the timeline using JavaScript, you may also be able to selectively override CSS with <style>
tags in the page.
Assuming you've created your own CSS file and put it on a web server somewhere, if you are using iframe
embeds, you can edit the src
of your embed to tell TimelineJS to load your CSS. Add a parameter called theme
and set its value to the URL for your custom CSS. (At one point we considered providing alternative themes with TimelineJS, but we haven't made the time to fully complete and test any.)
See below for more details on various CSS classes which TimelineJS uses.
Timeline CSS classes
This table lists the major CSS classes which TimelineJS uses. You may just be able to tweak some of these. However, TimelineJS uses Less for CSS preprocessing, which means that some of the CSS rules are very specific.
Slide options affect the media and text areas of slides.
tl-timeline
div
tl-slider-container-mask
div
tl-slide
div
.tl-slide-titleslide
(for title slides) or .tl-slide-media-only
(slides without text).
tl-media-content-container
div
tl-media-content
div
tl-credit
div
tl-caption
div
tl-text
div
tl-text-content-container
div
tl-headline-date
h3
tl-headline
h2
.tl-headline-title
. Note that you will probably need to use the selector h2.tl-headline
to change the appearance of the slide titles.
tl-text-content
div
p
tags.
tl-slidenav-next
or
tl-slidenav-previous
div
tl-slidenav-icon::before
div
.tl-slidenav-next
or .tl-slidenav-previous
to specify which arrow to render.
tl-slidenav-title
div
.tl-slidenav-next
or .tl-slidenav-previous
to specify which title to render.
tl-slidenav-description
div
.tl-slidenav-next
or .tl-slidenav-previous
to specify which description to render.
Timenav options affect the portion of the timeline that renders the time series.
tl-timenav
div
tl-menubar
div
tl-timemarker
div
.tl-timemarker-active
.
tl-timemarker-content-container
div
.tl-timemarker
(for slides other than the current slide) or .tl-timemarker.tl-timemarker-active
(for the current slide).
tl-timemarker-timespan
div
.tl-timemarker
(for slides other
than the current slide) or .tl-timemarker.tl-timemarker-active
(for the current slide).
tl-timemarker-media-container
div
tl-headline
h2
.tl-timemarker .tl-timemarker-content-container .tl-timemarker-content .tl-timemarker-text h2.tl-headline
.
(Yes, ideally it wouldn't need to be so specific, but for now, it does.)
tl-timeaxis
div
tl-timeaxis-background
div
tl-timeaxis-tick:before
div
.tl-timeaxis-major
to target major ticks or .tl-timeaxis-minor
to target minor ticks.