# @atomik-color/core

> 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!

Latest version **1.0.13** (published 2022-12-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @atomik-color/core
pnpm add @atomik-color/core
yarn add @atomik-color/core
bun add @atomik-color/core
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.13 |
| Published | 2022-12-11 |
| First published | 2020-09-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 140.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Dilshod Turobov |
| Maintainers | deebov |

## Links

- npm: https://www.npmjs.com/package/@atomik-color/core
- Repository: https://github.com/deebov/color-picker
- Issues: https://github.com/deebov/color-picker/issues
- npm.io page: https://npm.io/package/@atomik-color/core

## Recent versions

- 1.0.13 (latest) — 2022-12-11
- 1.0.14-alpha.3 (canary) — 2022-12-17
- 1.0.12 — 2020-10-02
- 1.0.11 — 2020-10-02
- 1.0.10 — 2020-10-02
- 1.0.9 — 2020-10-02
- 1.0.8 — 2020-10-02
- 1.0.7 — 2020-10-02
- 1.0.6 — 2020-10-02
- 1.0.4 — 2020-10-02
- 1.0.3 — 2020-10-02
- 1.0.2 — 2020-10-02
- 1.0.0 — 2020-09-26

## README

# 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](https://codesandbox.io/s/atomik-colorcomponent-j3pyf)

## 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](https://codesandbox.io/s/atomik-color-hooks-k85hw)

```bash
yarn add @atomik-color/component
```

## Usage

```jsx
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**

```typescript
interface Props extends UseColorStateProps {
  showPreview?: boolean;
}
```

| Name            | Description                                     | Type                     | Default |
| --------------- | ----------------------------------------------- | ------------------------ | ------- |
| `value?`        | Present color value                             | `TColor`                 | -       |
| `defaultValue?` | Default color                                   | `TColor`                 | -       |
| `onChange?`     | Callback function for tracking the state change | `(value:TColor) => void` | -       |
| `showPreview?`  | If true, preview box will be shown              | `true`                   |

### 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>`| - |

---
_Source: https://npm.io/package/@atomik-color/core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
