Skip to content

ColorSwatchPicker

One colour from a set chosen by design: the colour of a project, a label. Each swatch has a name.

import { ColorSwatchPicker } from '@sypnia/ui/react'

On this page
  1. A project colour
  2. When to use it
  3. For everyone
  4. Props

A project colour

Code
import { useState } from 'react';
import { ColorSwatchPicker, Field } from '@sypnia/ui/react';

// A colour from a set chosen by design. Arrow keys move between them; each has a name.
const colors = [{ value: '#8c9f13', label: 'Moss' }, { value: '#4174bf', label: 'Blue' }, { value: '#e56636', label: 'Ember' }, { value: '#34a990', label: 'Teal' }, { value: '#bf4a7f', label: 'Rose' }];
export default function Project() {
  const [c, setC] = useState(colors[1].value);
  return <Field label="Project colour"><ColorSwatchPicker colors={colors} value={c} onChange={setC} /></Field>;
}

When to use it

Use it when

  • Marking things so they are told apart at a glance.

Do not use it when

  • Brand colours that can be anything: use ColorPicker.

For everyone

  • It is a radio group; each swatch is named («Blue»), so colour is never the only clue.

Props

ColorSwatchPickerTypeDefault
colorsrequired { value: string; label: string; }[]
onChangerequired (v: string) => void
valuerequired string
label string
name string
  1. A project colour
  2. When to use it
  3. For everyone
  4. Props

    Search pages, sections and terms