Docs › Getting started

Theming

Two attributes theme any element and everything inside it, color mode and corner shape.

Color mode

Set data-theme="light" or data-theme="dark" on any element. With no attribute on the page, dark follows the system setting.

<html data-theme="dark">

With next-themes, use the attribute mode:

<ThemeProvider attribute="data-theme" defaultTheme="system" enableSystem>

Corner shape

Set data-shape to rounded, soft or square. Every corner in the library comes from one scale, so one attribute recuts all of them. Dots, such as a radio's indicator, stay round in every shape, because there roundness carries meaning.

Example

rounded

A card, cut rounded.

soft

A card, cut soft.

square

A card, cut square.
Follows the page theme and corners

Nesting

Both attributes work on any element, and the nearest one wins. A light card inside a dark page takes its own colors and its own text color.

<main data-theme="dark">
<section data-theme="light" data-shape="square">...</section>
</main>

Tokens

Every value is a CSS variable you can read, such as var(--color-ink), var(--radius-control) or var(--spacing-peer). The same tokens are available in JavaScript, with each mode's value:

import { tokens } from '@snapshot-ui/core/tokens';

tokens.color.slate.var; // 'var(--color-slate)'
tokens.radius.pill.modes.shape.soft; // '12px'
esc

↑ ↓ to move↵ to open