Slide State
reveal.js supports a data-state tag that can be added on slides which gets rendered into <section> tags.
In AsciiDoc the data-state can be applied to a slide by adding a state attribute to a section like this:
[state=topic]
== Epic Topic
That state can be queried from JavaScript or used in CSS to apply further customization to your slide deck. For example, by combining this feature with the CSS override one, you can alter fonts for specific pages with this CSS:
@import 'https://fonts.googleapis.com/css?family=Baloo+Bhai';
section[data-state="topic"] h2 {
font-family: 'Baloo Bhai', cursive;
font-size: 4em;
}
Role or state?
A role and a state both give you a hook to style a slide from CSS, but they don’t target the same element.
| Syntax | CSS selector | Scope |
|---|---|---|
|
|
The slide’s |
|
|
Same as above. |
|
|
The whole screen, while the slide is shown. |
reveal.js adds the state as a class on the viewport element when the slide is shown and removes it when you leave the slide.
Use a role (or the data-state attribute selector) to style the content of a slide, such as fonts, colors or spacing.
Use the state class on the viewport to style what surrounds the slide, such as a full-screen background.