{"id":13400648,"url":"https://github.com/omgovich/react-colorful","last_synced_at":"2025-04-23T20:53:08.472Z","repository":{"id":37260091,"uuid":"281920861","full_name":"omgovich/react-colorful","owner":"omgovich","description":"🎨 A tiny (2,8 KB) color picker component for React and Preact apps","archived":false,"fork":false,"pushed_at":"2024-07-13T12:24:28.000Z","size":2790,"stargazers_count":3296,"open_issues_count":40,"forks_count":114,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-18T10:14:09.726Z","etag":null,"topics":["a11y","color","color-picker","hacktoberfest","hex","hooks","picker","preact","react","react-component","tiny","typescript-support","zero-dependency"],"latest_commit_sha":null,"homepage":"https://omgovich.github.io/react-colorful","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/omgovich.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"open_collective":"react-colorful","patreon":"omgovich"}},"created_at":"2020-07-23T10:25:57.000Z","updated_at":"2025-04-18T07:46:11.000Z","dependencies_parsed_at":"2024-01-16T01:24:14.463Z","dependency_job_id":"3a81bf04-7957-49ce-a970-07f80599bad9","html_url":"https://github.com/omgovich/react-colorful","commit_stats":{"total_commits":478,"total_committers":18,"mean_commits":"26.555555555555557","dds":0.3096234309623431,"last_synced_commit":"c7e87161d71be9156b0c149d0e110fa24fd7037d"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omgovich%2Freact-colorful","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omgovich%2Freact-colorful/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omgovich%2Freact-colorful/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omgovich%2Freact-colorful/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omgovich","download_url":"https://codeload.github.com/omgovich/react-colorful/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249556296,"owners_count":21290847,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["a11y","color","color-picker","hacktoberfest","hex","hooks","picker","preact","react","react-component","tiny","typescript-support","zero-dependency"],"created_at":"2024-07-30T19:00:54.253Z","updated_at":"2025-04-23T20:53:08.446Z","avatar_url":"https://github.com/omgovich.png","language":"TypeScript","funding_links":["https://opencollective.com/react-colorful","https://patreon.com/omgovich"],"categories":["UI Components","Uncategorized","TypeScript","React","React [🔝](#readme)"],"sub_categories":["Form Components","Uncategorized","Utility"],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://omgovich.github.io/react-colorful\"\u003e\n    \u003cimg src=\"demo/src/assets/design.png\" width=\"229\" height=\"233\" alt=\"react-colorful\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://npmjs.org/package/react-colorful\"\u003e\n    \u003cimg alt=\"npm\" src=\"https://img.shields.io/npm/v/react-colorful.svg?labelColor=da248d\u0026color=6ead0a\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/omgovich/react-colorful/actions\"\u003e\n    \u003cimg alt=\"build\" src=\"https://img.shields.io/github/workflow/status/omgovich/react-colorful/Node.js%20CI/master.svg?labelColor=da248d\u0026color=6ead0a\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/omgovich/react-colorful\"\u003e\n    \u003cimg alt=\"coverage\" src=\"https://img.shields.io/codecov/c/github/omgovich/react-colorful.svg?labelColor=da248d\u0026color=6ead0a\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://npmjs.org/package/react-colorful\"\u003e\n    \u003cimg alt=\"no dependencies\" src=\"https://badgen.net/bundlephobia/dependency-count/react-colorful?labelColor=da248d\u0026color=6ead0a\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://bundlephobia.com/result?p=react-colorful\"\u003e\n    \u003cimg alt=\"tree-shakeable\" src=\"https://badgen.net/bundlephobia/tree-shaking/react-colorful?labelColor=da248d\u0026color=6ead0a\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://npmjs.org/package/react-colorful\"\u003e\n    \u003cimg alt=\"types included\" src=\"https://badgen.net/npm/types/react-colorful?labelColor=da248d\u0026color=6ead0a\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003cstrong\u003ereact-colorful\u003c/strong\u003e is a tiny color picker component for React and Preact apps.\n\u003c/div\u003e\n\n## Features\n\n- 🗜 **Small**: Just 2,8 KB gzipped ([13x lighter](#why-react-colorful) than **react-color**).\n- 🌳 **Tree-shakeable**: Only the parts you use will be imported into your app's bundle.\n- 🚀 **Fast**: Built with hooks and functional components only.\n- 🛡 **Bulletproof**: Written in strict TypeScript and has 100% test coverage.\n- 🗂 **Typed**: Ships with [types included](#typescript-support)\n- 😍 **Simple**: The interface is straightforward and easy to use.\n- 👫 **Cross-browser**: Works out-of-the-box for most browsers, regardless of version.\n- 📲 **Mobile-friendly**: Supports mobile devices and touch screens.\n- 💬 **Accessible**: Follows the [WAI-ARIA](https://www.w3.org/WAI/standards-guidelines/aria/) guidelines to support users of assistive technologies.\n- 💨 **No dependencies**\n\n## Live demos\n\n- [Website](https://omgovich.github.io/react-colorful)\n- [HEX Color Picker (CodeSandbox)](https://codesandbox.io/s/react-colorful-demo-u5vwp)\n- [RGBA Color Picker (CodeSandbox)](https://codesandbox.io/s/react-colorful-rgb-o9q0t)\n\n## Table of Contents\n\n- [Getting Started](#getting-started)\n- [Supported Color Models](#supported-color-models)\n- [Customization](#customization)\n- [How to paste or type a color?](#how-to-paste-or-type-a-color)\n- [Code Recipes](#code-recipes)\n- [TypeScript Support](#typescript-support)\n- [Usage with Preact](#usage-with-preact)\n- [Browser Support](#browser-support)\n- [Why react-colorful?](#why-react-colorful)\n- [Projects using react-colorful](#projects-using-react-colorful)\n- [Ports](#ports)\n\n## Getting Started\n\n```\nnpm install react-colorful\n```\n\n```js\nimport { HexColorPicker } from \"react-colorful\";\n\nconst YourComponent = () =\u003e {\n  const [color, setColor] = useState(\"#aabbcc\");\n  return \u003cHexColorPicker color={color} onChange={setColor} /\u003e;\n};\n```\n\n## Supported Color Models\n\nWe provide 12 additional color picker components for different color models, unless your app needs a HEX string as an input/output format.\n\n\u003cdetails\u003e\n  \u003csummary\u003eHow to use another color model\u003c/summary\u003e\n\n#### Available pickers\n\n| Import                      | Value example                      |\n| --------------------------- | ---------------------------------- |\n| `{ HexColorPicker }`        | `\"#ffffff\"`                        |\n| `{ HexAlphaColorPicker }`   | `\"#ffffff88\"`                      |\n| `{ RgbColorPicker }`        | `{ r: 255, g: 255, b: 255 }`       |\n| `{ RgbaColorPicker }`       | `{ r: 255, g: 255, b: 255, a: 1 }` |\n| `{ RgbStringColorPicker }`  | `\"rgb(255, 255, 255)\"`             |\n| `{ RgbaStringColorPicker }` | `\"rgba(255, 255, 255, 1)\"`         |\n| `{ HslColorPicker }`        | `{ h: 0, s: 0, l: 100 }`           |\n| `{ HslaColorPicker }`       | `{ h: 0, s: 0, l: 100, a: 1 }`     |\n| `{ HslStringColorPicker }`  | `\"hsl(0, 0%, 100%)\"`               |\n| `{ HslaStringColorPicker }` | `\"hsla(0, 0%, 100%, 1)\"`           |\n| `{ HsvColorPicker }`        | `{ h: 0, s: 0, v: 100 }`           |\n| `{ HsvaColorPicker }`       | `{ h: 0, s: 0, v: 100, a: 1 }`     |\n| `{ HsvStringColorPicker }`  | `\"hsv(0, 0%, 100%)\"`               |\n| `{ HsvaStringColorPicker }` | `\"hsva(0, 0%, 100%, 1)\"`           |\n\n#### Code example\n\n```js\nimport { RgbColorPicker } from \"react-colorful\";\n\nconst YourComponent = () =\u003e {\n  const [color, setColor] = useState({ r: 50, g: 100, b: 150 });\n  return \u003cRgbColorPicker color={color} onChange={setColor} /\u003e;\n};\n```\n\n[Live demo →](https://codesandbox.io/s/react-colorful-rgb-o9q0t)\n\n\u003c/details\u003e\n\n## Customization\n\nThe easiest way to tweak **react-colorful** is to create another stylesheet to override the default styles.\n\n```css\n.your-component .react-colorful {\n  height: 240px;\n}\n.your-component .react-colorful__saturation {\n  border-radius: 4px 4px 0 0;\n}\n.your-component .react-colorful__hue {\n  height: 40px;\n  border-radius: 0 0 4px 4px;\n}\n.your-component .react-colorful__hue-pointer {\n  width: 12px;\n  height: inherit;\n  border-radius: 0;\n}\n```\n\n[See examples →](https://codesandbox.io/s/react-colorful-customization-demo-mq85z?file=/src/styles.css)\n\n## How to paste or type a color?\n\nAs you probably noticed the color picker itself does not include an input field, but do not worry if you need one. **react-colorful** is a modular library that allows you to build any picker you need. Since `v2.1` we provide an additional component that works perfectly in pair with our color picker.\n\n\u003cdetails\u003e\n  \u003csummary\u003eHow to use \u003ccode\u003eHexColorInput\u003c/code\u003e\u003c/summary\u003e\u003cbr /\u003e\n\n```js\nimport { HexColorPicker, HexColorInput } from \"react-colorful\";\n\nconst YourComponent = () =\u003e {\n  const [color, setColor] = useState(\"#aabbcc\");\n  return (\n    \u003cdiv\u003e\n      \u003cHexColorPicker color={color} onChange={setColor} /\u003e\n      \u003cHexColorInput color={color} onChange={setColor} /\u003e\n    \u003c/div\u003e\n  );\n};\n```\n\n[Live demo →](https://codesandbox.io/s/react-colorful-hex-input-demo-0k2fx)\n\n| Property   | Default | Description                                  |\n| ---------- | ------- | -------------------------------------------- |\n| `alpha`    | `false` | Allows `#rgba` and `#rrggbbaa` color formats |\n| `prefixed` | `false` | Enables `#` prefix displaying                |\n\n`HexColorInput` does not have any default styles, but it also accepts all properties that a regular `input` tag does (such as `className`, `placeholder` and `autoFocus`). That means you can place and modify this component as you like. Also, that allows you to combine the color picker and input in different ways:\n\n```jsx\n\u003cHexColorInput color={color} onChange={setColor} placeholder=\"Type a color\" prefixed alpha /\u003e\n```\n\n\u003c/details\u003e\n\n## Code Recipes\n\n- [Value debouncing](https://codesandbox.io/s/dgqn0?file=/src/DebouncedPicker.js)\n- [Popover picker](https://codesandbox.io/s/opmco?file=/src/PopoverPicker.js)\n- [Preset colors (color squares)](https://codesandbox.io/s/bekry?file=/src/SwatchesPicker.js)\n- [Picker that accepts any color input](https://codesandbox.io/s/6fp23?file=/src/CustomPicker.js)\n- [Text field to be able to type/copy/paste a color](https://codesandbox.io/s/0k2fx?file=/src/App.js)\n- [Custom styles and layout](https://codesandbox.io/s/mq85z?file=/src/styles.css)\n\n## TypeScript Support\n\n**react-colorful** supports TypeScript and ships with types in the library itself; no need for any other install.\n\n\u003cdetails\u003e\n  \u003csummary\u003eHow you can get the most from our TypeScript support\u003c/summary\u003e\u003cbr /\u003e\n\nWhile not only typing its own functions and variables, it can also help you type yours. Depending on the component you are using, you can also import the type that is associated with the component. For example, if you are using our HSL color picker component, you can also import the `HSL` type.\n\n```ts\nimport { HslColorPicker, HslColor } from \"react-colorful\";\n\nconst myHslValue: HslColor = { h: 0, s: 0, l: 0 };\n```\n\nTake a look at [Supported Color Models](#supported-color-models) for more information about the types and color formats you may want to use.\n\n\u003c/details\u003e\n\n## Usage with Preact\n\n**react-colorful** will work flawlessly with Preact out-of-the-box if you are using [WMR](https://github.com/preactjs/wmr), [Preact-CLI](https://github.com/preactjs/preact-cli), [NextJS with Preact](https://github.com/vercel/next.js/tree/canary/examples/using-preact), or a few other tools/boilerplates thanks to aliasing.\n\nIf you are using another solution, please refer to the [Aliasing React to Preact](https://preactjs.com/guide/v10/getting-started#aliasing-react-to-preact) section of the Preact documentation.\n\n\u003cdetails\u003e\n  \u003csummary\u003ePreact + Typescript\u003c/summary\u003e\u003cbr /\u003e\n\n**react-colorful**, like all other React + TS projects, can potentially cause issues in a Preact + TS application if you have the `@types/react` package installed, either as a direct dependency or a dependency of a dependency. For example, the Preact TS template comes with `@types/enzyme` which has `@types/react` as a dependency.\n\nTo fix this, create a `declaration.d.ts` file or add to your existing:\n\n```\nimport React from \"react\";\n\ndeclare global {\n    namespace React {\n        interface ReactElement {\n            nodeName: any;\n            attributes: any;\n            children: any;\n        }\n    }\n}\n```\n\nThis will correct the types and allow you to use **react-colorful** along with many other React + TS libraries in your Preact + TS application.\n\n\u003c/details\u003e\n\n## Browser Support\n\nIt would be an easier task to list all of the browsers and versions that **react-colorful** does not support! We regularly test against browser versions going all the way back to 2013 and this includes IE11.\n\n**react-colorful** works out-of-the-box for most browsers, regardless of version, and only requires an `Object.assign` polyfill be provided for full IE11 support.\n\n## Why react-colorful?\n\nToday each dependency drags more dependencies and increases your project’s bundle size uncontrollably. But size is very important for everything that intends to work in a browser.\n\n**react-colorful** is a simple color picker for those who care about their bundle size and client-side performance. It is fast and lightweight because:\n\n- has no dependencies (no risks in terms of vulnerabilities, no unexpected bundle size changes);\n- built with hooks and functional components only (no classes and polyfills for them);\n- ships only a minimal amount of manually optimized color conversion algorithms (while most of the popular pickers import entire color manipulation libraries that increase the bundle size by more than 10 KB and make your app slower).\n\nTo show you the problem that **react-colorful** is trying to solve, we have performed a simple benchmark (using [bundlephobia.com](https://bundlephobia.com)) against popular React color picker libraries:\n\n| Name               | Bundle size                                                                                                                        | Bundle size (gzip)                                                                                                                    | Dependencies                                                                                                                                    |\n| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |\n| **react-colorful** | [![](https://badgen.net/bundlephobia/min/react-colorful?color=6ead0a\u0026label=)](https://bundlephobia.com/result?p=react-colorful)    | [![](https://badgen.net/bundlephobia/minzip/react-colorful?color=6ead0a\u0026label=)](https://bundlephobia.com/result?p=react-colorful)    | [![](https://badgen.net/bundlephobia/dependency-count/react-colorful?color=6ead0a\u0026label=)](https://bundlephobia.com/result?p=react-colorful)    |\n| react-color        | [![](https://badgen.net/bundlephobia/min/react-color?color=red\u0026label=)](https://bundlephobia.com/result?p=react-color)             | [![](https://badgen.net/bundlephobia/minzip/react-color?color=red\u0026label=)](https://bundlephobia.com/result?p=react-color)             | [![](https://badgen.net/bundlephobia/dependency-count/react-color?color=red\u0026label=)](https://bundlephobia.com/result?p=react-color)             |\n| react-input-color  | [![](https://badgen.net/bundlephobia/min/react-input-color?color=red\u0026label=)](https://bundlephobia.com/result?p=react-input-color) | [![](https://badgen.net/bundlephobia/minzip/react-input-color?color=red\u0026label=)](https://bundlephobia.com/result?p=react-input-color) | [![](https://badgen.net/bundlephobia/dependency-count/react-input-color?color=red\u0026label=)](https://bundlephobia.com/result?p=react-input-color) |\n| rc-color-picker    | [![](https://badgen.net/bundlephobia/min/rc-color-picker?color=red\u0026label=)](https://bundlephobia.com/result?p=rc-color-picker)     | [![](https://badgen.net/bundlephobia/minzip/rc-color-picker?color=red\u0026label=)](https://bundlephobia.com/result?p=rc-color-picker)     | [![](https://badgen.net/bundlephobia/dependency-count/rc-color-picker?color=red\u0026label=)](https://bundlephobia.com/result?p=rc-color-picker)     |\n\n## Projects using react-colorful\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003ca href=\"https://storybook.js.org/\"\u003eStorybook\u003c/a\u003e — the most widely used open-source tool for developing UI components\u003c/summary\u003e\n\n  \u003ca href=\"https://storybook.js.org/\"\u003e\n    \u003cimg src=\"demo/src/assets/storybook.png\" width=\"551\" alt=\"Storybook\" /\u003e\n  \u003c/a\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003ca href=\"https://resume.io\"\u003eResume.io\u003c/a\u003e — online resume builder with over 9,400,000 users worldwide\u003c/summary\u003e\n\n  \u003ca href=\"https://resume.io/\"\u003e\n    \u003cimg src=\"demo/src/assets/resume-io.png\" width=\"873\" alt=\"resume.io\" /\u003e\n  \u003c/a\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003ca href=\"https://wireflow.co/\"\u003eWireflow.co\u003c/a\u003e — free tool for creating modern user flow prototypes\u003c/summary\u003e\n\n  \u003ca href=\"https://wireflow.co/\"\u003e\n    \u003cimg src=\"demo/src/assets/wireflow-co.png\" width=\"1222\" alt=\"wireflow.co\" /\u003e\n  \u003c/a\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003ca href=\"https://www.magicpattern.design/\"\u003eMagicPattern.design\u003c/a\u003e — unique geometric pattern generator\u003c/summary\u003e\n\n  \u003ca href=\"https://www.magicpattern.design/\"\u003e\n    \u003cimg src=\"demo/src/assets/magicpattern-design.jpg\" width=\"943\" alt=\"magicpattern.design\" /\u003e\n  \u003c/a\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003ca href=\"https://viewst.com/\"\u003eViewst.com\u003c/a\u003e — online tool for designing, creating and automating ad campaigns\u003c/summary\u003e\n\n  \u003ca href=\"https://viewst.com/\"\u003e\n    \u003cimg src=\"demo/src/assets/viewst.png\" width=\"1159\" alt=\"viewst.com\" /\u003e\n  \u003c/a\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003ca href=\"https://omatsuri.app\"\u003eOmatsuri.app\u003c/a\u003e — progressive web application with a lot of different frontend focused tools\u003c/summary\u003e\n\n  \u003ca href=\"https://omatsuri.app\"\u003e\n    \u003cimg src=\"demo/src/assets/omatsuri-app.png\" width=\"1223\" alt=\"omatsuri.app\" /\u003e\n  \u003c/a\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003ca href=\"https://github.com/pmndrs/leva\"\u003eLeva\u003c/a\u003e — open source extensible GUI panel made for React\u003c/summary\u003e\n\n  \u003ca href=\"https://github.com/pmndrs/leva\"\u003e\n    \u003cimg src=\"demo/src/assets/leva.png\" width=\"1223\" alt=\"pmndrs/leva\" /\u003e\n  \u003c/a\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003ca href=\"https://www.composable.art\"\u003eComposable\u003c/a\u003e — online tool for creating custom vector illustrations\u003c/summary\u003e\n\n  \u003ca href=\"https://www.composable.art\"\u003e\n    \u003cimg src=\"demo/src/assets/composable.png\" width=\"745\" alt=\"composable.art\" /\u003e\n  \u003c/a\u003e\n\u003c/details\u003e\n\n## Backers and sponsors\n\n\u003ca href=\"https://opencollective.com/react-colorful\"\u003e\u003cimg src=\"https://opencollective.com/react-colorful/individuals.svg?width=890\"\u003e\u003c/a\u003e\n\n## Ports\n\nNot using React or Preact? Not a problem! Check out the list of react-colorful ports adapted to your favourite framework or technology of choice:\n\n- **[vanilla-colorful](https://github.com/web-padawan/vanilla-colorful)** — a react-colorful reimplementation in vanilla Custom Elements, generously ported by [@web-padavan](https://github.com/web-padawan).\n\n- **[angular-colorful](https://github.com/fil0157/angular-colorful)** — a react-colorful rewritten for use with the Angular framework, lovingly ported by [@fil0157](https://github.com/fil0157).\n\nIf your port is not in the list, reach us out via [GitHub issues](https://github.com/omgovich/react-colorful/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomgovich%2Freact-colorful","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomgovich%2Freact-colorful","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomgovich%2Freact-colorful/lists"}