Lets a user choose a color for text, shapes, marking tools, and other elements.
You should have the chayns-components
package installed. If that is not the
case already, run
yarn add chayns-components
or
npm i chayns-components
After the chayns-components
package is installed, you can import the component
and use it with React:
import React from 'react'
import { ColorPicker } from 'chayns-components';
// ...
<ColorPicker {...} />
The ColorPicker
-component takes the following props:
Name | Type | Default | Required |
---|---|---|---|
inline | boolean |
false |
|
color | custom |
||
bubblePosition | number |
Bubble.position.BOTTOM_CENTER |
|
onChange | function |
||
onChangeEnd | function |
||
onBlur | function |
||
transparency | boolean |
false |
|
parent | custom |
||
className | string |
||
style | { [key: string]: number | string } |
||
bubbleClassName | string |
||
bubbleStyle | { [key: string]: number | string } |
||
input | boolean |
false |
|
defaultColorModel | number |
||
children | ReactNode |
||
removeParentSpace | boolean |
false |
|
showAllColorModels | boolean |
false |
|
customColorsArray | Array<custom> |
||
showCustomColors | boolean |
false |
|
showGlobalColors | boolean |
false |
|
onCreateCustomColor | function |
||
onRemoveCustomColor | function |
inline?: boolean
Display the color picker without a bubble.
color?: custom
The current color. Either a HEX-string, an HSV(A)- or RGB(A)-object.
bubblePosition?: number
The bubble position. The possible values are listed under the
Bubble
-component.
onChange?: function
Will be called when changing the color.
onChangeEnd?: function
Will be called after the color was changed.
onBlur?: function
Will be called when the picker loses focus.
transparency?: boolean
Wether the picker should show a transparency slider.
parent?: custom
The parent node the bubble should be rendered into.
className?: string
The classname that will be set on the children wrapper.
style?: { [key: string]: number | string }
A React style object that will be assigned to the children wrapper element.
bubbleClassName?: string
A classname string that will be applied to the Bubble component.
bubbleStyle?: { [key: string]: number | string }
A React style object that will be applied to the Bubble component.
input?: boolean
Displays an input to type in the color.
defaultColorModel?: number
The color model that is used by default.
children?: ReactNode
Children // TODO
removeParentSpace?: boolean
Removes space from the parent to the page borders from the tooltip position. This is only needed if the parent is padded from the page and has a relative positioning.
showAllColorModels?: boolean
Shows all color models
customColorsArray?: Array<custom>
An array of custom selectable colors
showCustomColors?: boolean
Shows custom colors
showGlobalColors?: boolean
Shows global colors
onCreateCustomColor?: function
Will be called when a custom color is added
onRemoveCustomColor?: function
Will be called when a custom color is removed