Skip to content

Themes

How themes work

A Theme is just a name plus a Record<string, string> of CSS variables.

interface Theme {
name: string
variables: Record<string, string>
styles?: string // optional inline CSS injected once
}

<ThemeProvider> wraps children in a <div data-theme="..."> with the variables applied as inline style. No theme engine, no runtime cost.

Built-in themes

Five ship from @react-slides/themes: minimal, dark, light, corporate, hacker.

Standard variables

Every built-in theme provides at least:

VariablePurpose
--rs-bgSlide background
--rs-fgDefault foreground/text
--rs-accentBrand/highlight color
--rs-mutedSecondary text
--rs-borderHairlines
--rs-shadowDrop shadows
--rs-radiusBorder radius default
--rs-code-bgCode block background
--rs-highlight-bgLine highlight in CodeStepper
--rs-fragment-transitionFragment fade transition
--rs-spacing-slideSlide padding default
--rs-font-heading / --rs-font-body / --rs-font-codeType stacks
--rs-font-size-h1 / h2 / h3 / body / codeType scale

Overriding

Compose with object spread — themes are plain data.

import { dark, defineTheme } from '@react-slides/themes'
const myTheme = defineTheme({
...dark,
name: 'my-dark',
variables: {
...dark.variables,
'--rs-accent': '#ff5722',
},
})

Or change one variable at runtime:

const { setVariable } = useTheme()
setVariable('--rs-accent', '#ff5722')

Custom theme from scratch

import { Slide } from '@react-slides/core'
import { defineTheme, ThemeProvider } from '@react-slides/themes'
const ocean = defineTheme({
name: 'ocean',
variables: {
'--rs-bg': '#001f3f',
'--rs-fg': '#7fdbff',
'--rs-accent': '#39cccc',
},
})
const slides = () => {
return (
<ThemeProvider theme={ocean}>
<>
<Slide>
<h1>Ocean theme</h1>
</Slide>
</>
</ThemeProvider>
)
}
export default slides

Reset CSS

Optionally import the bundled reset:

import '@react-slides/themes/reset.css'