### Install mui-color-input with npm or yarn Source: https://viclafouch.github.io/mui-color-input/docs/getting-started Install the mui-color-input package using either npm or yarn. The npm command includes the --save flag to add it to dependencies. ```bash npm install mui-color-input --save ``` ```bash yarn add mui-color-input ``` -------------------------------- ### MuiColorInput Source: https://viclafouch.github.io/mui-color-input/docs/api-reference Documentation for the MuiColorInput component, including its props and usage examples. ```APIDOC ## MuiColorInput ### Description A color input component that allows users to select or type a color value. It supports various color formats and provides a color picker popover. ### Props #### `value` - **Type**: `MuiColorInputValue` - **Required**: `true` - **Description**: The color value. The string parsing is very permissive, allowing various formats such as hex, RGB, HSL, HSV, and their alpha variants. Examples include `"#000"`, `"rgb (255, 0, 0)"`, `"hsl(0, 100%, 50%)"`, `"hsv(0, 100%, 50%)"`, and object forms like `{ r: 255, g: 0, b: 0 }`. #### `onChange` - **Default**: `undefined` - **Type**: `(color: string, colors: MuiColorInputColors) => void` - **Required**: `false` - **Description**: Called when the user updates the color value. Provides the new color value stringified and an object with the color in different formats (`hex`, `hex8`, `hsl`, `hsv`, `rgb`). #### `format` - **Default**: `"rgb"` - **Type**: `MuiColorInputFormat` - **Required**: `false` - **Description**: The format to use for the color value. The first parameter of `onChange` respects this format. Available formats: `hex`, `hex8`, `hsl`, `hsv`, `rgb`. #### `fallbackValue` - **Default**: `"black"` - **Type**: `MuiColorInputValue` - **Required**: `false` - **Description**: A fallback color value used when the user inputs an invalid color. #### `isAlphaHidden` - **Default**: `false` - **Type**: `boolean` - **Required**: `false` - **Description**: Whether to hide the alpha channel input controls. #### `adornmentPosition` - **Default**: `"start"` - **Type**: `"start" | "end"` - **Required**: `false` - **Description**: The position of the color button adornment relative to the text input. #### `disablePopover` - **Default**: `false` - **Type**: `boolean` - **Required**: `false` - **Description**: Whether to disable the color picker popover. When `true`, clicking the color button will not open the popover. #### `Adornment` - **Default**: `MuiColorInputButton` - **Type**: `(props: MuiColorButtonProps) => React.ReactNode` - **Required**: `false` - **Description**: A custom component to replace the default color button adornment. #### `PopoverProps` - **Default**: `undefined` - **Type**: `PopoverProps` - **Required**: `false` - **Description**: Props passed to the MUI Popover component (except `anchorEl`, `open`, and `children` which are managed internally). ### Examples #### Hex, 8-digit (RGBA) Hex ```jsx ``` #### RGB, RGBA ```jsx ``` #### HSL, HSLA ```jsx ``` #### HSV, HSVA ```jsx ``` #### onChange Example ```jsx const handleChange = (color, colors) => { /** color: "#ffffff" colors: { hex: "#ffffff", hex8: "#ffffffff", hsl: "hsl(0, 0%, 100%)", hsv: "hsv(0, 0%, 100%)", rgb: "rgb(255, 255, 255)" } **/ } ``` #### format Example ```jsx ``` #### fallbackValue Example ```jsx ``` #### isAlphaHidden Example ```jsx ``` #### adornmentPosition Example ```jsx ``` #### disablePopover Example ```jsx ``` #### Adornment Example ```jsx const MyCustomButton = (props) => { return ) } ``` -------------------------------- ### Override MuiColorInput styles with className Source: https://viclafouch.github.io/mui-color-input/docs/css Use the className prop to apply custom classes to the MuiColorInput component. Then target its global class names, such as .MuiColorInput-HueSlider, to override styles. ```jsx ``` -------------------------------- ### Validate color with matchIsValidColor Source: https://viclafouch.github.io/mui-color-input/docs/color-validation Use the matchIsValidColor function to check if a color string is valid within a React component. ```javascript import React from 'react' import { MuiColorInput, matchIsValidColor } from 'mui-color-input' const MyComponent = () => { const [value, setValue] = React.useState('#ffffff') const handleChange = (newValue) => { matchIsValidColor(newValue) // boolean } return } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.