- Components
- Colors
- Color Picker
Color Picker
A ColorPicker combines a swatch with a customizable popover for editing a color.
default.tsx
Installation
CLI
Manual
npm
pnpm
yarn
bun
Usage
Use a ColorPicker
to allow users to select and edit a color in an overlay.
Options
ColorPicker
accepts all button options.
options.tsx
Unontrolled
An initial, uncontrolled value can be provided to the ColorPicker
using the defaultValue
prop.
uncontrolled.tsx
Controlled
Use the value
and onChange
props to control the color picker.
controlled.tsx
Composition
If you need to customize things further, you can drop down to the composition level.
composition.tsx
API Reference
ColorPicker
extends and merges the props of the Button component.
Prop | Type | Default | Description |
---|---|---|---|
value | string | Color | null | - | The current value (controlled). |
defaultValue | string | Color | null | - | The default value (uncontrolled). |
children | ReactNode | (values: T & {defaultChildren: ReactNode | undefined}) => ReactNode | - | The children of the component. A function may be provided to alter the children based on component state. |
Event | Type | Description |
---|---|---|
onChange | (value: Color) => void | Handler that is called when the value changes. |
Last updated on 10/11/2024