Components

Color Picker

People choose a color from the colorspace, fine-tune hue and opacity, type a HEX value or reuse a saved swatch. In Arabic the field row, the header row and the swatches mirror, while the hue and opacity bars keep running left to right: they map a color scale, not reading order.

Preview

Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.

Installation

SoonInstalling from the registry is coming soon. Until then, these are the commands you will run.
npx ritla add color-picker

Also works with shadcn: npx shadcn@latest add @ritla/color-picker

Dependencies it brings: @base-ui/react, @phosphor-icons/react

Installing by hand copies the component's source into your project. The source comes with a Ritla UI license, so the CLI is the short way to the same files.

Usage

import { ColorPicker } from "@/components/ui/color-picker";
const [color, setColor] = useState("#4F46E5");

<ColorPicker aria-label="Brand color" value={color} onValueChange={setColor} />

Examples

In a popover, with a contrast check

The field shows the color and its code and opens the picker in a Popover. contrastWith measures white text on the chosen color, warns below 4.5:1 (contrastTarget={3} for icons and borders) and offers the nearest shade that passes, without blocking the choice. showAlpha={false} for colors that are always opaque.

Get the code ›

API reference

ColorPicker

PropTypeDefaultDescription
value / onValueChangestring / (value: string) => voidNoneThe color: #RRGGBB, or #RRGGBBAA when it isn't fully opaque.
swatches{ value, name? }[]NoneThe saved colors: a short row, most recent first. name is read with the code ("Brand indigo, #4F46E5"). Leave it out to hide the row.
onAddSwatch(value: string) => voidNoneThe Add link: saves the current color.
showAlphabooleantrueThe opacity bar and its field.
contrastWith / contrastTargetstring / numbercontrastTarget: 4.5The color that will sit with the chosen one (the text on it). Below the target a warning shows with the nearest shade that passes.
aria-labelstringNoneThe picker's name ("Brand color").

Accessibility

Keyboard

Keys are written for left-to-right. In right-to-left the arrow keys swap: the one pointing toward the reading direction moves forward.

KeyAction
TabThe colorspace, then hue, then opacity, then the fields, then the swatches.
ArrowLeftArrowRightIn the colorspace: saturation; on a bar: its value. Right raises it in both languages, since the bars run left to right.
ArrowUpArrowDownIn the colorspace: brightness; with Shift, in 10% steps.
PageUpPageDownHomeEndOn a bar: a tenth of the range, and the ends.
EnterIn the HEX field, applies the value.

ARIA

  • The colorspace and both bars are role="slider" with their values in words ("Saturation 70%, brightness 90%").
  • The swatches are a radio group, each named with its name and code; the selected one keeps a visible ring, never color alone.
  • The HEX field is the precise keyboard way in: it takes the code with or without #, in any case, and the short form.

Arabic and RTL notes

Mirrors

  • The field row (the HEX format, then the code, then opacity), the Saved colors row with Add, and the swatches.

Does not mirror

  • The colorspace and the hue and opacity bars: a fixed color scale, red at the left in both languages.
  • The HEX code stays left to right, with Latin letters and Western digits.
Numerals
Percentages (opacity, saturation, brightness, contrast) follow numerals; the HEX code never does.
Arabic typography
The fields are label-14 Medium and the swatch heading label-12; no fixed heights on Arabic text.