Colour swatches
Show a palette's colours, and what each token resolves to in the current colour mode.
ColorSwatch shows one colour, its name, and the value it resolves to. Give it
any CSS colour, CSS variables included, so a library can document its own
design tokens. Switch the colour mode and the values below change with it:
these are this site’s own theme tokens.
var(--background)var(--foreground)var(--primary)var(--primary-foreground)var(--secondary)var(--muted)var(--accent)var(--destructive)var(--border)var(--ring)Usage
ColorSwatches lays swatches out in a grid, as many columns as fit.
var(--chart-1)var(--chart-2)oklch(0.7 0.15 150 / 50%)The name defaults to the variable for var(--x), and to the value for any
other colour. Below the name is the value the browser resolves, in the notation
your stylesheet uses. A token derived from others, such as a color-mix(),
shows the colour it comes out as. The value updates when the reader switches
colour mode, whether your site marks that with a class or attribute on the html element or follows the system setting. It is left out when it would only
repeat the name. A translucent colour shows over a checkerboard.
The server can’t know what a variable resolves to, so the page first shows the value as written, and the browser fills in the resolved value as it loads.
API reference
ColorSwatch
value required string #3b82f6, oklch(0.6 0.2 260) or var(--brand).name string default the variable's name for `var(--x)`, otherwise the valueColorSwatches
children required Snippet ColorSwatch components to lay out.