Function ColorPicker

A customizable color picker component for Next.js projects.

This component provides a user interface for selecting colors, including:

  • A saturation-value area for picking the color's saturation and brightness
  • A hue slider for selecting the base hue
  • An input field for entering hex color values
  • A color preview box

The component is highly customizable through props, allowing for custom styling and dimensions to fit various design requirements.

<ColorPicker
initialColor={{ r: 255, g: 0, b: 0 }}
onChange={(color) => console.log(color)}
width={300}
height={200}
/>

ColorPickerProps for detailed prop descriptions

Properties

contextTypes?: ValidationMap<any>

Lets you specify which legacy context is consumed by this component.

Legacy React Docs

defaultProps?: Partial<ColorPickerProps>

Used to define default values for the props accepted by the component.

React Docs

type Props = { name?: string }

const MyComponent: FC<Props> = (props) => {
return <div>{props.name}</div>
}

MyComponent.defaultProps = {
name: 'John Doe'
}

Use values for destructuring assignments instead.

displayName?: string

Used in debugging messages. You might want to set it explicitly if you want to display a different name for debugging purposes.

Legacy React Docs


const MyComponent: FC = () => {
return <div>Hello!</div>
}

MyComponent.displayName = 'MyAwesomeComponent'
propTypes?: WeakValidationMap<ColorPickerProps>

Used to declare the types of the props accepted by the component. These types will be checked during rendering and in development only.

We recommend using TypeScript instead of checking prop types at runtime.