# Docs, colour swatches

- **[Sections](/blocks/)**
- **[Docs](/blocks/docs/)**
- **Docs, colour swatches**

A grid of colour swatches with name, hex value and token. The colour foundation specimen. Only hex values paint a swatch.

## Import

- **CLI**

  ```
  npx shadcn add @klarhimmel/docs-swatches
  ```
- **Import**

  ```
  import Block from '@/components/klarhimmel/blocks/docs-swatches';
  ```

Also called

- 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

- **[Docs, table](/blocks/docs/table)**
- **[Docs, page header](/blocks/docs/header)**
- **[Docs, do and don't](/blocks/docs/do-dont)**

## Usage

The block in a page, with its default content (long lists shortened). Every prop is in the table below.

section.tsx

```
import { Theme } from '@/components/klarhimmel/theme/style';
import { BlockSurface } from '@/components/klarhimmel/blocks/surface';
import DocsSwatches from '@/components/klarhimmel/blocks/docs-swatches';

export default function Section() {
  return (
    <Theme theme="brand">
      <BlockSurface>
        <DocsSwatches props={{
          "title": "Name the set",
          "description": "Say where the values come from and how to use them.",
          "swatches": [
            {
              "name": "Colour 1",
              "value": "#F4F1EA",
              "token": "--canvas"
            },
            {
              "name": "Colour 2",
              "value": "#FFFFFF",
              "token": "--surface"
            },
            {
              "name": "Colour 3",
              "value": "#16181D",
              "token": "--ink"
            },
            {
              "name": "Colour 4",
              "value": "#2B65C9",
              "token": "--accent"
            },
            {
              "name": "Colour 5",
              "value": "#D49A2C",
              "token": "--attention"
            },
            {
              "name": "Colour 6",
              "value": "#B84A32",
              "token": "--danger"
            },
            {
              "name": "Colour 7",
              "value": "#437A52",
              "token": "--success"
            },
            {
              "name": "Colour 8",
              "value": "#E0DCD2",
              "token": "--line"
            }
          ]
        }} />
      </BlockSurface>
    </Theme>
  );
}
```

## 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.

- **title**: Text, up to 60 characters.
- **description**: Text, up to 200 characters.
- **swatches**: List of 1 to 16. Each item: name, value, token.
- **headingLevel**: One of '1', '2'. Optional; empty is not rendered.

[Previous](/blocks/docs/related)

[Next](/blocks/docs/table)
