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

ColorInput

  • Needs review
  • WCAG 2.2 evidence
  • RTL

A hex colour field with a swatch and a picker popover. Built on React Aria ColorField: the label, helper and error are linked to the input (WCAG 1.3.1, 3.3.2); typing a hex value and Enter (or leaving the field) commits it; arrow keys step the value; invalid states set aria-invalid and show the error with an icon (1.4.1, 3.3.1). The swatch previews the typed colour and turns empty while the text is not a colour; the value is always shown as text (left-to-right, also in RTL layouts), so colour is never the only identifier. The chevron button (and Alt + Arrow Down in the field) opens a ColorPicker in a popover dialog: focus moves into it, Escape closes it and focus returns to the button (2.1.1, 2.1.2, 2.4.3). Every picker drag has a keyboard or typed alternative (2.5.7). Paste and autofill are never blocked. Consumer duties: label and error wording, validate / isRequired rules, and presets with meaningful names.

import { ColorInput } from "@nexera-ui/react";
Loading example…
6
examples
29
props
7
live controls
1
platform
10
WCAG criteria
1
block uses 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…
description
placeholder
defaultOpen
isDisabled
isReadOnly
isRequired
isInvalid
Generated code
import { ColorInput } from "@nexera-ui/react";

<ColorInput />

Examples 5

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

With presets

A compact picker with named presets in the popover (any ColorPicker inside stays in sync with the field).

Loading example…

Controlled

Controlled value: the committed colour is shown under the field.

Loading example…

States

Figma Error (isInvalid + errorMessage) and Disabled (isDisabled).

Loading example…

Long label

Long labels and helper texts wrap.

Loading example…

Right to left

Right-to-left: label and helper align to the right; the hex value stays left-to-right.

Loading example…

Props 29

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

29 props shown

valueNexera
string | Color | null

The colour: a CSS string, a React Aria Color, or null for empty. Shown as hex text with a swatch. Pair it with onChange.

Default –
defaultValueNexera
string | Color | null

The initial colour (uncontrolled). Empty when omitted.

Default –
onChangeNexera
(color: Color | null) => void

Called with the new Color (or null when cleared) when a typed value is committed (Enter or blur) and on every change in the picker.

Default –
descriptionNexera
ReactNode

Helper text under the field, linked with aria-describedby. Shown when provided.

Default –
errorMessageNexera
ReactNode | ((validation: ValidationResult) => ReactNode)

Error text under the field, shown with an icon while the field is invalid and linked with aria-describedby. Say what is wrong and how to fix it.

Default –
placeholderNexera
string

Example value shown while empty, for example "#04855D". Never the only label.

Default –
isOpenNexera
boolean

Whether the picker popover is open. Use with onOpenChange.

Default –
defaultOpenNexera
boolean

Whether the picker is open on first render (uncontrolled).

Default false
onOpenChangeNexera
(isOpen: boolean) => void

Called when the picker opens or closes.

Default –
pickerNexera
ReactNode

Content of the popover. Defaults to a full ColorPicker named after the label. Pass your own <ColorPicker mode="compact" presets={...} aria-label="..." /> to customise it: any ColorPicker inside stays in sync with the field.

Default –
pickerLabelNexera
string

Accessible name of the chevron button and of the popover dialog. Translate it.

Default Color picker
inputRefNexera
Ref<HTMLInputElement>

Ref to the native <input> (the root ref points to the field wrapper).

Default –
classNameNexera
string

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

Default –
styleNexera
CSSProperties

Inline style for the root.

Default –
labelNexera
FieldLabelContent

Visible label, linked to the control by React Aria (WCAG 1.3.1, 3.3.2). Short noun, for example "Work email". Wraps instead of truncating. A placeholder is never a substitute for it. Not set: the field has no visible label. Not set: the field has no visible label of its own.

Default –
aria-labelNexera
string

Accessible name when it must differ from the visible label. Prefer the visible label (WCAG 2.5.3). Accessible name. Required when there is no visible label; translate it. Accessible name. Optional when aria-labelledby is set.

Default –
aria-labelledbyNexera
string

Id(s) of element(s) that name the field; wins over the visible label. Id(s) of element(s) that name the field; wins over aria-label. Id(s) of visible element(s) that name the field.

Default –
validationBehaviorReact Aria
"native" | "aria"

Whether to use native HTML form validation to prevent form submission when the value is missing or invalid, or mark the field as required or invalid via ARIA.

Default 'native'
idReact Aria
string

The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).

Default –
nameReact Aria
string

The name of the input element, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).

Default –
formReact Aria
string

The <form> element to associate the input with. The value of this attribute must be the id of a <form> in the same document. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).

Default –
isWheelDisabledReact Aria
boolean

Enables or disables changing the value with scroll.

Default –
isDisabledReact Aria
boolean

Whether the input is disabled.

Default –
isReadOnlyReact Aria
boolean

Whether the input can be selected but not changed by the user.

Default –
isRequiredReact Aria
boolean

Whether user input is required on the input before form submission.

Default –
isInvalidReact Aria
boolean

Whether the input value is invalid.

Default –
validateReact Aria
(value: Color | null) => true | ValidationError | null

A function that returns an error message if a given value is invalid. Validation errors are displayed to the user when the form is submitted if validationBehavior="native". For realtime validation, use the isInvalid prop instead.

Default –
autoFocusReact Aria
boolean

Whether the element should receive focus on render.

Default –
aria-describedbyReact Aria
string

Identifies the element (or elements) that describes the object.

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

8 direct · 2 supporting
  • 1.3.1Info and RelationshipsLevel A · tested directly
  • 1.4.1Use of ColorLevel A · tested directly
  • 2.1.1KeyboardLevel A · tested directly
  • 2.1.2No Keyboard TrapLevel A · tested directly
  • 2.4.3Focus OrderLevel A · tested directly
  • 2.4.7Focus VisibleLevel AA · supporting test
  • 2.5.8Target Size (Minimum)Level AA · supporting test
  • 3.3.1Error IdentificationLevel A · tested directly
  • 3.3.2Labels or InstructionsLevel A · tested directly
  • 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-focus-within
  • data-hovered
  • data-invalid
  • data-open
  • data-pressed
Usage
<ColorInput className="data-disabled:opacity-90 shadow-sm" />

Used in blocks

Related components