Color Input
- 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";- 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.
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).
import { ColorInput, ColorPicker } from "@nexera-ui/react";
<ColorInput
label="Brand color"
defaultValue="#04855D"
description="Used for buttons, links and the sidebar"
picker={
<ColorPicker
aria-label="Brand color"
mode="compact"
presets={[
{ color: "#04855D", name: "Emerald 600" },
{ color: "#2563EB", name: "Blue 600" },
{ color: "#D97706", name: "Amber 600" },
{ color: "#7C3AED", name: "Violet 600" },
]}
/>
}
/>;
Controlled
Controlled value: the committed colour is shown under the field.
import { useState } from "react";
import { type Color } from "react-aria-components";
import { ColorInput } from "@nexera-ui/react";
export function Controlled() {
const [value, setValue] = useState<string | Color | null>("#2563EB");
return (
<div className="flex flex-col gap-2">
<ColorInput
label="Brand color"
defaultValue="#04855D"
description="Used for buttons, links and the sidebar"
value={value}
onChange={setValue}
/>
<p className="m-0 text-body-small text-secondary">
Value: {value === null ? "none" : typeof value === "string" ? value : value.toString("hex")}
</p>
</div>
);
}
States
Figma Error (isInvalid + errorMessage) and Disabled (isDisabled).
import { ColorInput } from "@nexera-ui/react";
export function States() {
return (
<div className="flex flex-col gap-6">
<ColorInput
defaultValue="#04855D"
label="Accent color"
isInvalid
errorMessage="Enter a 6-digit hex code, like #04855D"
description={undefined}
/>
<ColorInput
defaultValue="#04855D"
description="Used for buttons, links and the sidebar"
label="Disabled color"
isDisabled
/>
<ColorInput
defaultValue="#04855D"
description="Used for buttons, links and the sidebar"
label="Read-only color"
isReadOnly
/>
</div>
);
}
Long label
Long labels and helper texts wrap.
import { ColorInput } from "@nexera-ui/react";
<ColorInput
label="Primary brand color used for buttons, links, focus rings and the selected sidebar item"
defaultValue="#04855D"
description="Changing it updates every product surface after the next deployment; check the contrast on white and on the page background."
/>;
Right to left
Right-to-left: label and helper align to the right; the hex value stays left-to-right.
import { ColorInput } from "@nexera-ui/react";
<ColorInput
label="لون العلامة"
defaultValue="#04855D"
description="يستخدم للأزرار والروابط والشريط الجانبي"
/>;
Props 29
Press "Try it" on a card to load that prop into the playground.
29 props shown
valueNexerastring | Color | nullThe colour: a CSS string, a React Aria Color, or null for empty.
Shown as hex text with a swatch. Pair it with onChange.
defaultValueNexerastring | Color | nullThe initial colour (uncontrolled). Empty when omitted.
onChangeNexera(color: Color | null) => voidCalled with the new Color (or null when cleared) when a typed value is committed (Enter or blur) and on every
change in the picker.
descriptionNexeraReactNodeHelper text under the field, linked with aria-describedby.
Shown when provided.
errorMessageNexeraReactNode | ((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.
placeholderNexerastringExample value shown while empty, for example "#04855D". Never the only label.
isOpenNexerabooleanWhether the picker popover is open. Use with onOpenChange.
defaultOpenNexerabooleanWhether the picker is open on first render (uncontrolled).
onOpenChangeNexera(isOpen: boolean) => voidCalled when the picker opens or closes.
pickerNexeraReactNodeContent 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.
pickerLabelNexerastringAccessible name of the chevron button and of the popover dialog. Translate it.
inputRefNexeraRef<HTMLInputElement>Ref to the native <input> (the root ref points to the field wrapper).
classNameNexerastringExtra classes for the root, merged last so they win over the defaults.
styleNexeraCSSPropertiesInline style for the root.
labelNexeraFieldLabelContentVisible 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.
aria-labelNexerastringAccessible 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.
aria-labelledbyNexerastringId(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.
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.
idReact AriastringThe element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).
nameReact AriastringThe 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).
formReact AriastringThe <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).
isWheelDisabledReact AriabooleanEnables or disables changing the value with scroll.
isDisabledReact AriabooleanWhether the input is disabled.
isReadOnlyReact AriabooleanWhether the input can be selected but not changed by the user.
isRequiredReact AriabooleanWhether user input is required on the input before form submission.
isInvalidReact AriabooleanWhether the input value is invalid.
validateReact Aria(value: Color | null) => true | ValidationError | nullA 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.
autoFocusReact AriabooleanWhether the element should receive focus on render.
aria-describedbyReact AriastringIdentifies the element (or elements) that describes the object.
* 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.
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-disableddata-focus-withindata-hovereddata-invaliddata-opendata-pressed
<ColorInput className="data-disabled:opacity-90 shadow-sm" />Used in blocks
Related components
- CalendarDayOne day of a {@link CalendarMonth } grid, built on React Aria `CalendarCell`: a `gridcell` whose button is named by the full, localised date ("Wednesday, October 14, 2026"), with `aria-selected`, `aria-disabled` and the "today" and range descriptions read by screen readers (WCAG 1.3.1, 4.1.2).
- CalendarMonthA month calendar for picking a date or a date range: header with previous / next buttons and the localised month name, weekday row, and six weeks of `CalendarDay`s.
- CheckboxThe bare 18 px checkbox: one independent yes/no choice applied on submit, or a row selector in a table, list or tree.
- CheckboxCardA large checkbox option with an icon, a title and a description, for a few options that need explanation (notification channels, benefits).
- CheckboxFieldA checkbox with a label and optional helper text: the box (the same element as `Checkbox`) followed by the label and description, applied on submit.
- ColorPickerPicks a colour.
- ColorTokenCardDocumentation card for one colour token: a 96 px colour sample with an "Aa" text sample, then the name, token path, hex value and contrast note as text.
- ComboboxA text field with a filtered list of options.