UI Color Elements
This library is a react color picker element. In addition to this, there is an alpha picker and a field editor for hex values
Install Library
npm install @leverege/ui-color-elements --save
Install CSS
In the global-styles.css, import
@import '../../node_modules/@leverege/ui-color-elements/lib/ui-color-elements.less';
ColorSelector
import React from 'react'
import { ColorSelector } from '@leverege/ui-color-elements'
class Example extends React.component {
render {
return(
<ColorSelector />
)
}
}
props
- onChange - function - called whenever there is a change to the widget by the user
- allowsNull - boolean - if true allows empty inputs
- eventData - any - returned as data prop in the onChange callback
- placeholder - string - input placeholder value
- color - string - variable or hex corresponding to the current color
- id - any - identifier of the returned jsx
- style - object - css styles of the returned jsx
- className - string - css class of the returned jsx
- showInput - boolean - if false will not show the color input
- disableAlpha - boolean - does not currently do anything
- variables - object - color variables
CompactAlphaPicker
import React from 'react'
import { CompactAlphaPicker } from '@leverege/ui-color-elements'
class Example extends React.component {
render {
return(
<CompactAlphaPicker />
)
}
}
props
- onChange - function - callback attached to the input for the alpha
- onChangeComplete - function - callback for hex inputs and when the alpha is finished changing
- color - string - selected alpha
- onSwatchHover - function - callback when the swatch is hovered over
- colors - array - possible colors used to render the swatches
- hex - string - hex of the selected color
- rgb - string - rgb of the selected color
- className - string - css class of the element
CompactFields
import React from 'react'
import { CompactFields } from '@leverege/ui-color-elements'
class Example extends React.component {
render {
return(
<CompactFields />
)
}
}
Props
- hex - string - hex value of the selected color
- rgb - string - rgb value of the selected color
- onChange - function - onChange callback of the input