Skip to content

CSS Customization

CSS Customization

Learn how to customize your Starlight site and the Starlight View Modes plugin with custom CSS.

Custom CSS

To customize the styles applied to your Starlight site when using the Starlight View Modes plugin, you can provide additional CSS files to modify or extend the Starlight and the Starlight View Modes plugin default styles.

Learn more about custom CSS in the Starlight documentation.

Cascade layers1/2

Like Starlight, the Starlight View Modes plugin uses cascade layers internally to manage the order of its styles. This ensures a predictable CSS order and allows for simpler overrides. Any custom unlayered CSS will override the default styles from the starlight, zen-mode, and presentation-mode layers.

If you are using cascade layers, you can use @layer in your custom CSS to define the order of precedence for different layers relative to the Starlight and Starlight View Modes plugin styles:

src/styles/custom.css
@layer my-reset, starlight, zen-mode, presentation-mode, my-overrides;

Cascade layers2/2

The example above defines a custom layer named my-reset, applied before all the Starlight and Starlight View Modes plugin layers, and another named my-overrides, applied after all Starlight and Starlight View Modes plugin layers. Any styles in the my-overrides layer would take precedence over the Starlight and Starlight View Modes plugin styles, but Starlight or the Starlight View Modes plugin could still change styles set in the my-reset layer.

Switch to normal mode

Contents