1.0.17 • Published 1 year ago

@atomik-color/component v1.0.17

Weekly downloads
6
License
MIT
Repository
github
Last release
1 year ago

Atomik Color

Hooks (and component) for building accessible color picker for React. 0 dependecies, tiny ~3K, built-in powerful color conversions, touch and pen support, keyboard and screen-reader accessible, built using React hooks, fast!

Demo

Installation

This examples shows how to install and use the color picker component, not the hooks! If you want to build your own color picker using our hooks see this example

yarn add @atomik-color/component

Usage

import ColorPicker from  "@atomik-color/component"

<ColorPicker />

// Default value
import { str2Color } from "@atomik-color/core"

<ColorPicker defaultValue={str2Color("#000")} />

// Controlled
import { useState } from  "react";
import { str2Color } from "@atomik-color/core"

const [color, setColor] = useState(str2Color("#000"))

<ColorPicker value={color} onChange={setColor} />

API

ColorPicker

Props

interface Props extends UseColorStateProps {
  showPreview?: boolean;
}
NameDescriptionTypeDefault
value?Present color valueTColor-
defaultValue?Default colorTColor-
onChange?Callback function for tracking the state change(value:TColor) => void-
showPreview?If true, preview box will be showntrue

useColorState

useColorState(props: UseColorStateProps): UseColorState

Props |Name|Description| Type| Default | |--|--|--|--| |value? |Present color value | TColor| - | |defaultValue? |Default color |TColor| - | |onChange? |Callback function for tracking the state change | (value:TColor) => void| - |

useColorRectangle

Props |Name|Description| Type| Default | |--|--|--|--| |state |Color state | ColorState| - | |ref |Ref of the element used as color rectangle |RefObject<HTMLElement>| - | |ariaLabel? |Aria label | string| - | |ariaValueFormat? |Formatted string used for aria-valuetext | string| - | |ariaDescription? |Aria description | string| - |

useHue

Props |Name|Description| Type| Default | |--|--|--|--| |state |Color state | ColorState| - | |ref |Ref of the element used as hue container |RefObject<HTMLElement>| - |

useAlpha

Props |Name|Description| Type| Default | |--|--|--|--| |state |Color state | ColorState| - | |ref |Ref of the element used as alpha container |RefObject<HTMLElement>| - |

1.0.18-alpha.5

1 year ago

1.0.17

1 year ago

1.0.18-alpha.3

1 year ago

1.0.18-alpha.2

1 year ago

1.0.18-alpha.1

1 year ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago