Socket
Socket
Sign inDemoInstall

@atomik-color/core

Package Overview
Dependencies
6
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

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


Version published
Weekly downloads
274
increased by3.01%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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

NameDescriptionTypeDefault
value?Present color valueTColor-
defaultValue?Default colorTColor-
onChange?Callback function for tracking the state change(value:TColor) => void-

useColorRectangle

Props

NameDescriptionTypeDefault
stateColor stateColorState-
refRef of the element used as color rectangleRefObject<HTMLElement>-
ariaLabel?Aria labelstring-
ariaValueFormat?Formatted string used for aria-valuetextstring-
ariaDescription?Aria descriptionstring-

useHue

Props

NameDescriptionTypeDefault
stateColor stateColorState-
refRef of the element used as hue containerRefObject<HTMLElement>-

useAlpha

Props

NameDescriptionTypeDefault
stateColor stateColorState-
refRef of the element used as alpha containerRefObject<HTMLElement>-

FAQs

Last updated on 11 Dec 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc