Skip to main content

TypeScript

This package is written in TypeScript. So you don't need to create your own types. Here an example if you use TypeScript.

Nota bene: Props are defined within the MuiColorInputProps interface.

import React from 'react';
import {
MuiColorInput,
MuiColorInputColors,
MuiColorInputFormat,
MuiColorInputValue,
} from 'mui-color-input';

const MyComponent = () => {
const [value, setValue] = React.useState<MuiColorInputValue>('#ffffff');

const handleChange = (newValue: string, colors: MuiColorInputColors) => {
setValue(newValue);
};

const format: MuiColorInputFormat = 'hex';

return (
<MuiColorInput value={value} onChange={handleChange} format={format} />
);
};