Theme studio

Design a theme, preview it live, then export it. Saved in this browser.

Quick picks #10b981
Generated scale
50100200300400500600700800900
Some text is below AA

Swatch

  • Stable
  • WCAG 2.2 evidence
  • RTL

A colour sample. Inside a {@link SwatchPicker} it is an option of a React Aria ColorSwatchPicker: arrow keys move between swatches, Enter or Space (or a click) selects, and the selected swatch shows a text/primary ring and, from md up, a check: selection is shown by shape, not by colour (WCAG 1.4.1, 1.4.11, 2.1.1, 4.1.2). Outside a picker it is a read-only image (role="img", "color swatch"). Every swatch is named by its colour name and hex value, so colour is never the only identifier. Hover, Focused and Selected are React Aria states (data-hovered, data-focus-visible, data-selected), not props. Consumer duties: meaningful, translated colorNames; unique colours within a picker.

import { Swatch } from "@nexera-ui/react";
Loading example…
4
examples
12
props
3
live controls
1
platform
8
WCAG criteria
3
blocks use it

Try every prop. Copy the code.

Change the props and the code updates. Check light and dark, LTR and RTL, and phone width.

Loading…
shape
size
isDisabled
Generated code
import { Swatch } from "@nexera-ui/react";

<Swatch />

Examples 3

The same examples as Storybook, rendered live. Open Code to copy one.

Picker

Inside a SwatchPicker the swatches are options: arrow keys move, Enter or Space selects. The selected swatch shows a ring and, from md up, a check (not colour alone).

Loading example…

Shapes and sizes

Every Figma Shape and Size (26, 38 and 54 px) in a picker.

Loading example…

Right to left

Right-to-left: the row starts on the right and the arrow keys follow the reading direction.

Loading example…

Props 12

Press "Try it" on a card to load that prop into the playground.

12 props shown

color*Nexera
string | Color

The colour: a CSS colour string such as "#04855D" or a React Aria Color. Drawn inline, because it is data. Colours inside one SwatchPicker must be unique.

Default –
colorNameNexera
string

Name of the colour, for example "Emerald 600". With the hex value it forms the accessible name ("Emerald 600, #04855D"), so the colour is never identified by its look alone (WCAG 1.4.1). Defaults to React Aria's localised description ("dark vibrant green"); pass your palette names and translate them.

Default –
shapeNexera
"circle" | "square"

Outline.

Default circle
sizeNexera
"sm" | "md" | "lg"

Box size: 26, 38 or 54 px. The selected check is shown from md up.

Default sm
isDisabledNexera
boolean

Whether the swatch cannot be chosen: faded, crossed out and skipped by selection. Inside a SwatchPicker it is announced as disabled; a standalone swatch is drawn the same way and marked aria-disabled.

Default false
classNameNexera
string

Extra classes for the root, merged last so they win over the defaults.

Default –
styleNexera
CSSProperties

Inline style for the root.

Default –
onPressReact Aria
(e: PressEvent) => void

Handler that is called when the press is released over the target.

Default –
onPressStartReact Aria
(e: PressEvent) => void

Handler that is called when a press interaction starts.

Default –
onPressEndReact Aria
(e: PressEvent) => void

Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target.

Default –
onPressChangeReact Aria
(isPressed: boolean) => void

Handler that is called when the press state changes.

Default –
onPressUpReact Aria
(e: PressEvent) => void

Handler that is called when a press is released over the target, regardless of whether it started on the target or not.

Default –

* Required. React Aria props shown are the ones most apps use; the component accepts the rest of its React Aria props too.

Accessible by default.

Built on React Aria, and covered by the WCAG 2.2 evidence generated on every build.

WCAG 2.2 evidence

6 direct · 2 supporting
  • 1.1.1Non-text ContentLevel A · tested directly
  • 1.3.1Info and RelationshipsLevel A · tested directly
  • 1.4.1Use of ColorLevel A · tested directly
  • 1.4.11Non-text ContrastLevel AA · supporting test
  • 2.1.1KeyboardLevel A · tested directly
  • 2.4.7Focus VisibleLevel AA · tested directly
  • 2.5.8Target Size (Minimum)Level AA · supporting test
  • 4.1.2Name, Role, ValueLevel A · tested directly

Fits any width.

Nexera components respond to the space they are given. Drag the corner of the frame, or pick a width.

0 px · drag the corner

Styling hooks

Pass className to add Tailwind classes (merged last). State is exposed as data attributes, so you can style it with variants like data-pressed:.

  • data-disabled
  • data-hovered
  • data-selected
Usage
<Swatch className="data-disabled:opacity-90 shadow-sm" />

Used in blocks

Related components