Docs, colour swatches


Install
npx shadcn add @klarhimmel/docs-swatchesDetailsAbout, usage, props and more
A grid of colour swatches with name, hex value and token. The colour foundation specimen. Only hex values paint a swatch.
Import
Import
- docs/swatches
- Category
- Documentation sections: headers, install panels, props tables, previews. New project? Set it up once: /get-started/installation.
Notes
When to use it
The colour foundation specimen: a grid of swatches with name, hex value and token. For non-colour tokens such as spacing or radius use docs-table.
Writing for it
- Each swatch has a name of 30 characters, a value of 16 and a token of 30. Write the value as a full hex code, such as #1F6FEB. - Name swatches by role, like Accent or Surface, and keep the token to the exact variable name, since a reader will copy it. - A grid takes 1 to 16 swatches. Keep related colours together, because the grid is two columns wide on narrow containers and four on wide ones.
Watch out for
Only a hex value paints a swatch. A value such as rgb(0, 0, 0) or a colour name is shown as text but the swatch stays empty, and in the wireframe theme every swatch is blank.
Pairs well with
Usage
The block in a page, with its default content (long lists shortened). Every prop is in the table below.
Props
The type, default and text limit of every prop. On a real page, over-limit text is kept and checkSections flags it (Installation, Check a page before you ship); this live preview shows the default until it fits. The panel above edits all props.
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | 'Name the set' | Text, up to 60 characters. |
description | string | 'Say where the values come from and …' | Text, up to 200 characters. |
swatches | { name, value, token }[] | 8 items | List of 1 to 16. Each item: name, value, token. |
headingLevel | '1' | '2' | - | One of '1', '2'. Optional; empty is not rendered. |