All Projects → jonyw4 → color-thief-react

jonyw4 / color-thief-react

Licence: ISC license
🎨 A React component with hooks for Color Thief. Grab color palette from an image with javascript

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to color-thief-react

Webgradients
A curated collection of splendid gradients made in CSS3, .sketch and .PSD formats.
Stars: ✭ 2,197 (+7475.86%)
Mutual labels:  palette
Krypton-Toolkit-Suite-Extended-NET-5.470
An extension to the Krypton Toolkit suite of controls for .NET framework 4.7
Stars: ✭ 51 (+75.86%)
Mutual labels:  palette
ngColorThief
ColorThief wrapper for AngularJS
Stars: ✭ 36 (+24.14%)
Mutual labels:  color-thief
Chartjs Plugin Colorschemes
Predefined color schemes for Chart.js
Stars: ✭ 189 (+551.72%)
Mutual labels:  palette
Use Image Color
🎨 A hook to grab a color palette from images. Render a skeleton color while your original image still loading.
Stars: ✭ 222 (+665.52%)
Mutual labels:  palette
laravel-color-palette
Laravel Wrapper for @ksubileau/color-thief-php. Grabs the dominant color or a representative color palette from an image. Uses PHP and GD or Imagick.
Stars: ✭ 27 (-6.9%)
Mutual labels:  color-thief
Pixel Editor
An online canvas based Pixel Art creation tool for Lospec.com
Stars: ✭ 180 (+520.69%)
Mutual labels:  palette
hcv-color
🌈 Color model HCV/HCG is an alternative to HSV and HSL, derived by Munsell color system, usable for Dark and Light themes... 🌈
Stars: ✭ 44 (+51.72%)
Mutual labels:  palette
Md Color Picker
Angular-Material based color picker
Stars: ✭ 253 (+772.41%)
Mutual labels:  palette
tdesktop-material-dark
Dark variant material-style theme for Telegram Desktop
Stars: ✭ 18 (-37.93%)
Mutual labels:  palette
Haishoku
A development tool for grabbing the dominant color or representative color palette from an image
Stars: ✭ 214 (+637.93%)
Mutual labels:  palette
Themify
👨‍🎨 CSS Themes Made Easy. A robust, opinionated solution to manage themes in your web application
Stars: ✭ 218 (+651.72%)
Mutual labels:  palette
tailwind-css-palette-generator
10-color Palette Generator and API for Tailwind CSS
Stars: ✭ 206 (+610.34%)
Mutual labels:  palette
Styled Theme
Extensible theming system for styled-components 💅
Stars: ✭ 183 (+531.03%)
Mutual labels:  palette
colors
🎨 An elegant and minimalistic color palette for UI design.
Stars: ✭ 19 (-34.48%)
Mutual labels:  palette
Jscolor
JavaScript color picker with opacity (alpha channel) and customizable palette. Single file of plain JS with no dependencies.
Stars: ✭ 182 (+527.59%)
Mutual labels:  palette
Ciapre.tmTheme
Ciapre - an easy-on-the-eyes Sublime Text/TextMate color scheme.
Stars: ✭ 63 (+117.24%)
Mutual labels:  palette
glsl-cos-palette
glsl function for making cosine palettes
Stars: ✭ 26 (-10.34%)
Mutual labels:  palette
Palette
Android application to get the #hexcode and rgb() values for any image
Stars: ✭ 31 (+6.9%)
Mutual labels:  palette
photo recoloring
Palette-based Photo Recoloring, implementation of the approach of Huiwen Chang et al.
Stars: ✭ 39 (+34.48%)
Mutual labels:  palette

Color Thief (React)

🎨 A React component with hooks for Color Thief. Grab color palette from an image with javascript Use the official Lokesh's color-thief.

npm (scoped) Build Status codecov semantic-release GitHub

Do you like?

Please, consider supporting my work as a lot of effort takes place to create this component! Thanks a lot.

Buy Me A Coffee

Demo

See a real demo in the Codesandbox

Install

npm i -S color-thief-react
yarn add color-thief-react

Basic Usage

import Color from 'color-thief-react';
// In your render...
<Color src={IMAGE_URL}>
  {({ data, loading, error }) => (
    <div style={{ color: data }}>
      Text with the predominant color
    </div>
  )}
</Color>

API

Color

Return the predominant color of the image. You can use a React component or hook. Both have the same props.

src: Required. Link of the image


format: Format of the response. Can be rgbString, rgbArray, hslString, hslArray, hex or a CSS keyword. Default is rgbString

Color conversion is made possible by the color-convert package.

Examples

rgbString: 'rgb(89, 197, 182)' rgbArray: [89, 197, 182] hslString: 'hsl(172, 48%, 56%)' hslArray: [172, 48, 56] hex: '#59c5b6' keyword: 'mediumaquamarine'

CSS Keywords keyword: Color keywords are case-insensitive identifiers that represent a specific color, such as red, blue, black, or lightseagreen.

Keywords are matched to the closest color. See this page on Web Colors for a complete list of colors that can be returned with the keyword color format.


crossOrigin: Tag cross-origin for image


quality: Quality determines how many pixels are skipped before the next one is sampled. We rarely need to sample every single pixel in the image to get good results. The bigger the number, the faster a value will be returned. Read more in https://lokeshdhakar.com/projects/color-thief/

Usage

import { useColor } from 'color-thief-react'

const { data, loading, error } = useColor(src, format, { crossOrigin, quality})

<div style={{ color: data }}>
  Text with the predominant color
</div>
import Color from 'color-thief-react';
// In your render...
<Color src={IMAGE_URL} format="hex">
  {({ data, loading, error }) => (
    <div style={{ color: data }}>
      Text with the predominant color
    </div>
  )}
</Color>

Palette

Return a palette of colors based on the predominance of colors on the image. You can use a React component or hook. Both have the same props.

src: Required. Link of the image

colorCount: Count of colors of the palette. Default is 2

format: Format of the response. See the format section in the Color chapter for a detailed API.

crossOrigin: Tag cross-origin for image

quality: Default is 10. Quality determines how many pixels are skipped before the next one is sampled. We rarely need to sample every single pixel in the image to get good results. The bigger the number, the faster a value will be returned. Read more in https://lokeshdhakar.com/projects/color-thief/

import { Palette } from 'color-thief-react';
// In your render...
<Palette src={IMAGE_URL} colorCount={2}>
  {({ data, loading, error }) => (
    <div style={{ color: data[0], backgroundColor: data[1] }}>
      Text with the predominant color
    </div>
  )}
</Palette>
import { usePalette } from 'color-thief-react'

const { data, loading, error } = usePalette(src, colorCount, format, { crossOrigin, quality})

<div style={{ color: data[0], backgroundPalette: data[1] }}>
  Text with the predominant color
</div>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].