Color Field
A text input for specifying color values, supporting formats like HEX, RGB, and HSL for precise color selection. It includes validation and prefix/suffix options.
Installation
Install the component via the CLI in one command.
npx shadcn@latest add @intentui/color-field
Composed components
When you install this component via the CLI, it automatically loads all composed components, so you don’t need to add them individually.
Manual installation
Use this approach if you prefer to install and wire up the component yourself instead of using the CLI.
npm install react-aria-components
Anatomy
import { ColorField } from "@/components/ui/color-field"
import { Label, Description } from "@/components/ui/field"
import { Input } from "@/components/ui/input"<ColorField>
<Label/>
<Input/>
<Description/>
</ColorField>Examples
Prefix
A color field can include a prefix to provide context or functionality.
Suffix
A color field can also have a suffix.
Controlled
Manage the color field in a controlled manner to automatically update the ColorSwatch and display the current color.
Disabled
You can disable the color field, making it non-interactive.
Validation
In this example, we’ll ensure it’s treated as a strict requirement.
Component API
ColorField
The ColorField component lets users enter a color value.
| Prop | Type | Default |
|---|---|---|
className | string | - |
See the React Aria for the full API reference.
Unlock the full power ofIntent UI Design
Build modern web apps faster with 1000+ resources across components, blocks, patterns, templates, and starter kits.