ColorPalette
Stacked color palette in the style of the Dropbox brand site: a row of
overlapping, bottom-anchored square cards cropped to 16:9. Hovering
or focusing a card smoothly raises it and reveals a search action that
deep-links into the colors search page.
The component renders only the swatch row — no card, heading, or CTA
chrome. Compose those around it (a <section>, a title, a sample button
wired to onSelectedIdsChange) when a surface calls for them.
Cards can be flat colors, gradients, or images (see ColorPaletteItem).
Image cards need a searchHex to be clickable.
With selectable, clicking anywhere on a card toggles it in and out of
the selection instead of linking out; selected cards keep a check
visible at rest, and the selection surfaces through onSelectedIdsChange.
Usage
import { buildSampleHref, buildSearchHref, ColorPalette, ColorPaletteItem, ColorPaletteLinkProps, ColorPaletteProps, getPaletteItemId, getSampleHex, PaletteDirection, PaletteSort, sortPaletteItems } from "@desk/ui/components/color-palette";Best practices
Describe cards as
items(kind: "color" | "gradient" | "image"), not hand-built markup — the component owns the overlap, hover-raise, and deep-link-to-search behaviour.Give every
imagecard asearchHex, otherwise it can't be searched or selected — flat colours and gradients derive theirs automatically.Pass
renderLink(e.g. wrappingnext/link) for client-side nav — the built-in links are plain<a>; the callback must return a single anchor element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| items | ColorPaletteItem[] | Cards to render — flat colors, gradients, or images (see ColorPaletteItem). | |
| sort | PaletteSort | Controlled sort order | |
| defaultSort | PaletteSort | Initial sort order when uncontrolled (default "original") | |
| onSortChange | (sort: PaletteSort) => void | Fired when the sort changes; pair with | |
| direction | PaletteDirection | Controlled stacking direction | |
| defaultDirection | PaletteDirection | Initial stacking direction when uncontrolled (default "left-first") | |
| onDirectionChange | (direction: PaletteDirection) => void | Fired when the direction changes; pair with | |
| showSettings | boolean | Show the sort/direction settings popover button (default false) | |
| selectable | boolean | Let users build a selection by clicking cards — the whole card becomes
a toggle instead of a search link. Selected cards keep a check visible
at rest; read the selection through | |
| selectedIds | string[] | Controlled selected ids. Ids come from | |
| defaultSelectedIds | string[] | Initial selected ids when uncontrolled | |
| onSelectedIdsChange | (selectedIds: string[]) => void | Fired when the selection changes; pair with | |
| searchBasePath | string | Base path for the built-in search links (default "/colors") | |
| searchLabel | string | Hover label for unnamed searchable cards (default "Search this color") | |
| renderLink | (props: ColorPaletteLinkProps) => ReactNode | Escape hatch to render links with a router-aware component (e.g. next/link). Must render a single anchor element. Defaults to a plain anchor. | |
| className | string |
Also exports
- const
buildSampleHref - const
buildSearchHref - type
ColorPaletteItem - interface
ColorPaletteLinkProps - interface
ColorPaletteProps - const
getPaletteItemId - const
getSampleHex - type
PaletteDirection - type
PaletteSort - const
sortPaletteItems
Composition
Builds on