@uiw/react-color-editable-input
Version:
Color Editable Input
73 lines (55 loc) • 2.61 kB
Markdown
React Color Editable Input
===
[](https://jaywcjlove.github.io/#/sponsor)
[](https://bundlephobia.com/package/@uiw/react-color-editable-input) [](https://www.npmjs.com/package/@uiw/react-color-editable-input) [](https://uiwjs.github.io/npm-unpkg/#/pkg/@uiw/react-color/file/README.md)
EditableInput Component is a subcomponent of [**`@react-color`**](https://uiwjs.github.io/react-color).
<!--rehype:ignore:start-->
[](https://uiwjs.github.io/react-color/#/editable-input)
<!--rehype:ignore:end-->
## Install
```bash
npm i @uiw/react-color-editable-input
```
## Usage
```jsx mdx:preview
import React, { useState } from 'react';
import { hsvaToHex } from '@uiw/color-convert';
import EditableInput from '@uiw/react-color-editable-input';
export default function Demo() {
const [hsva, setHsva] = useState({ h: 209, s: 36, v: 90, a: 1 });
return (
<div style={{ padding: '0 10px 0 20px' }}>
<EditableInput
label="Hex"
value={hsvaToHex(hsva)}
style={{ width: 68, alignItems: 'flex-start' }}
/>
</div>
);
}
```
## Props
```ts
import React from 'react';
export interface EditableInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange'> {
prefixCls?: string;
value?: string | number;
label?: React.ReactNode;
labelStyle?: React.CSSProperties;
placement?: 'top' | 'left' | 'bottom' | 'right';
inputStyle?: React.CSSProperties;
onChange?: (evn: React.ChangeEvent<HTMLInputElement>, value: string | number) => void;
renderInput?: (props: React.InputHTMLAttributes<HTMLInputElement>, ref: React.Ref<HTMLInputElement>) => React.ReactNode;
}
declare const EditableInput: React.ForwardRefExoticComponent<EditableInputProps & React.RefAttributes<HTMLInputElement>>;
export default EditableInput;
```
<!--footer-dividing-->
## Contributors
As always, thanks to our amazing contributors!
<a href="https://github.com/uiwjs/react-color/graphs/contributors">
<img src="https://uiwjs.github.io/react-color/coverage/CONTRIBUTORS.svg" />
</a>
Made with [contributors](https://github.com/jaywcjlove/github-action-contributors).
## License
Licensed under the MIT License.