1.5.3 • Published 2 years ago
react-gradient-hook v1.5.3
Examples
- As a hook
const Component = (props) => {
const [colors, gradient] = useGradient({options})
...
return (
{ gradient }
)
}
- As a Component
const Component = (props) => {
...
return (
<Gradient {...options} />
)
}
Props
Name | Type | Default Value | Required? | Description |
---|---|---|---|---|
defaultColors | TRGB[] | see here | No | Array of default colors for the gradient |
onChange | (colors: TRGB[]) => void | undefined | No | Function triggered when the gradient changes (different colors, a cursor is moved, ...) |
gradientOptions | GradientOptions | see here | No | Options to change the way the gradient is displayed |
cursorOptions | CursorOptions | see here | No | Options to control the behavior of the cursors (i.e. colors on the gradient) |
pickerOptions | PickerOptions | see here | No | Options to control the color pickers under the gradient |
Types
TRGB
Name | Type | Required? | Description |
---|---|---|---|
r | number | Yes | Red value |
g | number | Yes | Green value |
b | number | Yes | Blue value |
t | number | Yes | Position on the gradient (from 0 to 1 included) |
GradientOptions
Name | Type | Default Value | Required? | Description |
---|---|---|---|---|
height | number | 45 | Yes | Gradient's height in pixels |
CursorOptions
Name | Type | Default Value | Required? | Description |
---|---|---|---|---|
width | number | 15 | No | - |
border | number | 4 | No | - |
shadow | number | 2 | No | - |
scale | number | 1 | No | - |
grid | boolean | false | No | - |
samples | number | 20 | No | Number of steps the cursors can take. Only works if grid is set to true |
PickerOptions
Name | Type | Default Value | Required? | Description |
---|---|---|---|---|
showHue | boolean | true | No | - |
showChrome | boolean | true | No | - |
showCircles | boolean | true | No | - |
1.5.3
2 years ago
1.5.2
2 years ago
1.5.1
2 years ago
1.5.0
2 years ago
1.4.16
2 years ago
1.4.15
2 years ago
1.4.14
2 years ago
1.4.13
2 years ago
1.4.12
2 years ago
1.4.10
2 years ago
1.4.9
2 years ago
1.4.8
2 years ago
1.4.7
2 years ago
1.4.6
2 years ago
1.4.5
2 years ago
1.4.3
2 years ago
1.4.2
2 years ago
1.4.1
2 years ago
1.2.1
2 years ago
1.2.0
2 years ago
1.1.7
2 years ago
1.1.6
2 years ago
1.1.4
2 years ago
1.1.3
2 years ago
1.1.2
2 years ago
1.1.1
2 years ago
1.1.0
2 years ago
1.0.6
2 years ago
1.0.5
2 years ago
1.0.4
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago