Skip to content

ColorSwatchPicker

A controlled swatch picker for choosing one named theme color.

Office colorChoose the named theme color used for this office.
<ColorSwatchPicker
label="Office color"
description="Choose the named theme color used for this office."
size="md"
value="blue"
/>
Office colorChoose the named theme color used for this office.
Office colorChoose the named theme color used for this office.
Office colorChoose the named theme color used for this office.
function SizesStory(args: ColorSwatchPickerProps): React.JSX.Element {
const [value, setValue] = useState(args.value);
return (
<div style={{display: 'grid', gap: 16, justifyItems: 'start'}}>
<ColorSwatchPicker
{...args}
onChange={setValue}
size="sm"
value={value}
/>
<ColorSwatchPicker
{...args}
onChange={setValue}
size="md"
value={value}
/>
<ColorSwatchPicker
{...args}
onChange={setValue}
size="lg"
value={value}
/>
</div>
);
}
<SizesStory {...args} />
Office colorChoose the named theme color used for this office.
<ColorSwatchPicker
label="Office color"
description="Choose the named theme color used for this office."
size="md"
value="green"
colors={['red', 'orange', 'green', 'blue', 'purple']}
/>
Office colorHover a swatch to see the grow effect.
<ColorSwatchPicker
label="Office color"
description="Hover a swatch to see the grow effect."
size="md"
value="purple"
/>
Office colorChoose the named theme color used for this office.
<ColorSwatchPicker
label="Office color"
description="Choose the named theme color used for this office."
size="md"
value="blue"
isDisabled
/>
Office colorChoose the named theme color used for this office.
<ColorSwatchPicker
label="Office color"
description="Choose the named theme color used for this office."
size="md"
value="blue"
status={{message: 'Choose an office color.', type: 'error'}}
/>
Office colorRequiredChoose the named theme color used for this office.
<ColorSwatchPicker
label="Office color"
description="Choose the named theme color used for this office."
size="md"
value="blue"
isRequired
/>
Office colorChoose the named theme color used for this office.
North officeNorth office
function DrivesOtherComponentsStory(
args: ColorSwatchPickerProps,
): React.JSX.Element {
const [value, setValue] = useState<ColorName>(args.value);
return (
<div style={{display: 'grid', gap: 16, justifyItems: 'start'}}>
<ColorSwatchPicker {...args} onChange={setValue} value={value} />
<div style={{display: 'flex', gap: 8}}>
<Tag color={value} label="North office" />
<Badge color={value} label="North office" />
</div>
</div>
);
}
<DrivesOtherComponentsStory {...args} />
Office colorChoose the named theme color used for this office.
<ColorSwatchPicker
label="Office color"
description="Choose the named theme color used for this office."
size="md"
value="blue"
isReadOnly
/>

A controlled swatch picker for choosing one named theme color.

When isOptional: false, isRequired: false

PropTypeDefaultDescription
classNamestring—Additional CSS class names applied to the field root.
colorsReadonlyArray<ColorName>COLOR_NAMESPalette colors to render, in display order.
data-testidstring—Test ID applied to the field root.
descriptionReactNode—Supporting text displayed below the label.
isDisabledbooleanfalseWhether all swatches are disabled.
isReadOnlybooleanfalseWhether the selected color is displayed without allowing interaction.
isLabelHiddenbooleanfalseWhether to visually hide the label.
label*string—Label text for the swatch picker.
labelEndReactNode—Content shown at the end of the label row, such as a link. It renders outside the label, so it does not focus the control or change its accessible name. It stays visible when isLabelHidden is true.
labelTooltipReactNode—Tooltip content shown next to the label.
onChange*(value: ColorName) => void—Callback fired when the selected color changes.
refRef<HTMLDivElement>—Ref forwarded to the field root.
size"sm" | "md" | "lg"'md'Size of the swatches.
statusInputStatus—Validation status displayed below the picker.
styleCSSProperties—Inline styles applied to the field root.
value*"red" | "orange" | "yellow" | "green" | "teal" | "cyan" | "blue" | "purple" | "pink" | "gray"—The currently selected color.
isOptionalfalse—
isRequiredfalse—

When isOptional: true, isRequired: false

PropTypeDefaultDescription
classNamestring—Additional CSS class names applied to the field root.
colorsReadonlyArray<ColorName>COLOR_NAMESPalette colors to render, in display order.
data-testidstring—Test ID applied to the field root.
descriptionReactNode—Supporting text displayed below the label.
isDisabledbooleanfalseWhether all swatches are disabled.
isReadOnlybooleanfalseWhether the selected color is displayed without allowing interaction.
isLabelHiddenbooleanfalseWhether to visually hide the label.
label*string—Label text for the swatch picker.
labelEndReactNode—Content shown at the end of the label row, such as a link. It renders outside the label, so it does not focus the control or change its accessible name. It stays visible when isLabelHidden is true.
labelTooltipReactNode—Tooltip content shown next to the label.
onChange*(value: ColorName) => void—Callback fired when the selected color changes.
refRef<HTMLDivElement>—Ref forwarded to the field root.
size"sm" | "md" | "lg"'md'Size of the swatches.
statusInputStatus—Validation status displayed below the picker.
styleCSSProperties—Inline styles applied to the field root.
value*"red" | "orange" | "yellow" | "green" | "teal" | "cyan" | "blue" | "purple" | "pink" | "gray"—The currently selected color.
isOptional*true—
isRequiredfalse—

When isOptional: false, isRequired: true

PropTypeDefaultDescription
classNamestring—Additional CSS class names applied to the field root.
colorsReadonlyArray<ColorName>COLOR_NAMESPalette colors to render, in display order.
data-testidstring—Test ID applied to the field root.
descriptionReactNode—Supporting text displayed below the label.
isDisabledbooleanfalseWhether all swatches are disabled.
isReadOnlybooleanfalseWhether the selected color is displayed without allowing interaction.
isLabelHiddenbooleanfalseWhether to visually hide the label.
label*string—Label text for the swatch picker.
labelEndReactNode—Content shown at the end of the label row, such as a link. It renders outside the label, so it does not focus the control or change its accessible name. It stays visible when isLabelHidden is true.
labelTooltipReactNode—Tooltip content shown next to the label.
onChange*(value: ColorName) => void—Callback fired when the selected color changes.
refRef<HTMLDivElement>—Ref forwarded to the field root.
size"sm" | "md" | "lg"'md'Size of the swatches.
statusInputStatus—Validation status displayed below the picker.
styleCSSProperties—Inline styles applied to the field root.
value*"red" | "orange" | "yellow" | "green" | "teal" | "cyan" | "blue" | "purple" | "pink" | "gray"—The currently selected color.
isOptionalfalse—
isRequired*true—