Skip to content
SENVENLI UI

Color field

A hex color typed with a live swatch; a malformed value stays as typed with an example of a valid one.
A hex color
import { ColorField } from "@senvenli/react/color";

Examples

Controlled

`onChange` gives the normalized hex, or null when the field is emptied.

A single channel

The field types one channel's number instead of the hex.

Guidelines

When to use it

  • Typing a known color in compact settings.

Use something else when

Accessibility

Keyboard

KeysWhat happens
Arrow up / downSteps the value (the channel, on a single-channel field).

Built in

  • A malformed hex says what a valid one looks like.
  • Required fields show "Fill in this field."

You provide

  • A visible label.

API reference

ColorField

labelRequired
React.ReactNode
description
React.ReactNode
errorMessage
React.ReactNode

Shown while the field is invalid; a malformed hex says what a valid one looks like by itself.

value
string

"#1E63D0" (also "1e63d0" and "#16D"); null for none.

defaultValue
string
onChange
(value: string | null) => void

The normalised hex ("#1E63D0"), or null when emptied.

channel
ColorChannel

hex by default; a single channel ("hue", "saturation", "red"…) types that channel's number instead.

isRequired
boolean
requiredValidation
RequiredValidation

Who says an empty required ColorField is missing: inside a DS Form, field (default) shows "Fill in this field." on blur and on submit, which it then blocks; app only marks the field. See {@link RequiredValidation}. The app's isInvalid (true with its errorMessage, or false) overrides the check, as on TextField. Disabled, empty and required, it still blocks a DS Form's submit and cannot take focus (as TextField).

isDisabled
boolean
isReadOnly
boolean
isInvalid
boolean
name
string
id
string
aria-label
string
aria-labelledby
string