Colour field
Darkened a little so text on it reads on white
npx shadcn add @klarhimmel/theme-partsCopy for AIDetailsAbout, usage, props and more
A brand colour: a hex field, the browser's own picker and up to eight swatches. It sends a normalised #rrggbb only, and a line under it says what the colour did or why it was refused.
Preview
Colour field
Import
Import
- Files
- theme-parts.tsx, in components/klarhimmel/ui/. With it: input, theme, utils.
- Render in
- Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | ReactNode | required | The field's words. |
description | ReactNode | - | The field's words. |
value | string | required | The colour as hex. |
onChange | (hex: string) => void | required | Gets a normalised #rrggbb; a bad hex is held and marked, never sent. |
swatches | string[] | [] | Up to eight colours to pick from. |
notes | ReactNode | - | A calm line on what the colour did, or a refusal in the danger tone. |
problem | ReactNode | - | A calm line on what the colour did, or a refusal in the danger tone. |
pickerLabel | string | 'Pick a colour' | |
invalidLabel | string | 'Write a colour as #rrggbb' | |
disabled | boolean | - | |
className | string | - | Extra classes, merged after the component's own. |