Garden 9 is now available.
The website has been updated to the latest major version. View previous versions
Skip to main content
Design
Components
Patterns
    • Introduction
      • Overview
    • Foundations
      • Bedrock CSS
      • Design tokens
      • Containers
      • Theming
      • Versions
    • Components
      • Accordion
      • Anchor
      • Avatar
      • Breadcrumbs
      • Buttons
      • Chrome
      • Code block
      • Color picker
      • Color swatch
      • Date picker
      • Draggable
      • Drawer
      • Forms
      • Grid
      • Loaders
      • Menu
      • Modal
      • Notification
      • Pagination
      • Pane
      • Sheet
      • Status indicator
      • Stepper
      • Table
      • Tabs
      • Tags
      • Tiles
      • Timeline
      • Tooltip
      • Tooltip dialog
      • Typography
      • Well
    Table of Contents
    • How to use it
      • Default
      • Custom trigger
      • Dialog
    • API
      • ColorSwatch
      • ColorSwatchDialog

    Color swatch

    The Color swatch allows users to select a single predefined color.


    Table of Contents
    • How to use it
      • Default
      • Custom trigger
      • Dialog
    • API
      • ColorSwatch
      • ColorSwatchDialog

    Used for this
    • To let users change, update, or add predefined colors
    Not for this
    • For more finite control over color selection, use the Color picker

    How to use it

    Default

    The Color swatch allows users to select a single predefined color.

    Toggle dark mode
    Set primary hue
    Toggle RTL
    Open in CodeSandbox
    Copy code
    View code

    Custom trigger

    The Color swatch can be displayed using a trigger, e.g. an Icon button.

    Toggle dark mode
    Set primary hue
    Toggle RTL
    Open in CodeSandbox
    Copy code
    View code

    Dialog

    The Color swatch can be shown inside a dialog using <ColorSwatchDialog>.

    Toggle dark mode
    Set primary hue
    Toggle RTL
    Open in CodeSandbox
    Copy code
    View code

    API

    ColorSwatch

    Extends HTMLAttributes<HTMLTableElement>

    Prop nameTypeDefaultDescription
    colors
    { value: string; label: string; }[][]
    Required

    Sets the two-dimension array of labeled HEX and RGB/A string colors

    defaultSelectedColIndex
    number

    Sets the default selected column index in an uncontrolled color swatch

    defaultSelectedRowIndex
    number

    Sets the default selected row index in an uncontrolled color swatch

    isCheckboxGroup
    boolean

    Determines if the color swatch is backed by radio (default) or checkbox inputs

    name
    string
    Required

    Sets the name used to reference the value of the control

    onSelect
    ((rowIndex: number | null, colIndex: number | null) => void)

    Handles color swatch select event

    selectedColIndex
    number | null

    Sets the selected column index in a controlled color swatch

    selectedRowIndex
    number | null

    Sets the selected row index in a controlled color swatch

    ColorSwatchDialog

    Extends HTMLAttributes<HTMLDivElement>

    Prop nameTypeDefaultDescription
    buttonProps
    HTMLAttributes<HTMLButtonElement>

    Passes HTML attributes to the color dialog button element

    colors
    { value: string; label: string; }[][]
    Required

    Sets the two-dimension array of labeled HEX and RGB/A string colors

    defaultSelectedColIndex
    number

    Sets the default selected column index in an uncontrolled color swatch

    defaultSelectedRowIndex
    number

    Sets the default selected row index in an uncontrolled color swatch

    disabled
    boolean

    Disables the color dialog button

    focusInset
    boolean

    Applies inset box-shadow styling on focus

    hasArrow
    boolean
    false

    Adds an arrow to the color dialog

    isAnimated
    boolean
    true

    Animates the color dialog

    isCheckboxGroup
    boolean

    Determines if the color swatch is backed by radio (default) or checkbox inputs

    isOpen
    boolean

    Opens the dialog in a controlled color swatch dialog

    name
    string
    Required

    Sets the name used to reference the value of the control

    onDialogChange
    ((changes: { isOpen: boolean; }) => void)

    Handles dialog changes

    Parameters
    changes

    The changed dialog state

    onSelect
    ((rowIndex: number | null, colIndex: number | null) => void)

    Handles color swatch select event

    placement
    'end' | 'start' | 'auto' | 'top' | 'bottom' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'end-top' | 'end-bottom' | 'start-top' | 'start-bottom'
    'bottom-start'

    Adjusts the placement of the color dialog

    selectedColIndex
    number | null

    Sets the selected column index in a controlled color swatch

    selectedRowIndex
    number | null

    Sets the selected row index in a controlled color swatch

    zIndex
    number
    1000

    Sets the z-index of the color dialog

    Garden is the design system by Zendesk.
    BlogGitHubVersions
    © Zendesk 2025