Theme

PlaygroundBeta

npm_versionnpm Paragon package page

ColorPicker

Basic Usage

Any Paragon component or export may be added to the code example.

() => {
const [colorSm, setColorSm] = useState('')
const [colorMd, setColorMd] = useState('')
return (
<div className="d-flex bg-light p-2" style={{ columnGap: '1rem' }}>
<ColorPicker color={colorSm} setColor={setColorSm} size="sm" />
<ColorPicker color={colorMd} setColor={setColorMd} size="md" />
</div>
)
}

With good and malformatted default color passed

Any Paragon component or export may be added to the code example.

() => {
const [color, setColor] = useState('#32116c')
const [colorBad, setColorBad] = useState('#badcolor')
return (
<div className="d-flex bg-light p-2" style={{ columnGap: '1rem' }}>
<ColorPicker color={color} setColor={setColor} />
<ColorPicker color={colorBad} setColor={setColorBad} />
</div>
)
}

Theme Variables (SCSS)#

$picker-size-sm: 2rem !default;
$picker-size-md: calc(1.3333em + 1.125rem + 2px) !default;

Props API#

ColorPicker Props API
  • color string

    A default hex code to preset the picker to display.

    Default''
  • setColor func Required

    Passing setState function allows parent to alter the color.

  • className string

    A class name to append to the base element.

  • size enum'sm' | 'md'

    Size of the color picker

    Default'md'