Input
The Input
component provides a flexible input field that can be customized with various features and styles. It supports prepend and append elements, icons, debouncing, password visibility toggle, and more.
Props
Name | Type | Default | Description |
---|---|---|---|
value | string | The current value of the input. | |
onDebounce | (value: string) => void | A callback function that fires after the user has stopped typing for a specified debounce timeout. | |
debounceTimeout | number | 200 | The debounce timeout in milliseconds for the onDebounce callback. |
prepend | string | React.ReactElement | Content to prepend to the input field. | |
prefix | string | React.ReactElement | Content to be displayed before the input text. | |
prefixIcon | string | React.ReactElement | An icon to display before the input text. | |
prefixText | string | Text to display before the input text. | |
prefixPlaceholder | string | Placeholder text for the prefix. | |
suffix | string | React.ReactElement | Content to be displayed after the input text. | |
suffixIcon | string | React.ReactElement | An icon to display after the input text. Refer to the | |
suffixText | string | Text to display after the input text. | |
suffixPlaceholder | string | Placeholder text for the suffix. | |
append | string | React.ReactElement | Content to append to the input field. | |
clearable | boolean | false | If true , a clear button is displayed when there is input text. Clicking it clears the input field. |
togglePassword | boolean | false | If true , a password visibility toggle button is displayed for password input types. |
type | "text" | "password" | "number" | "email" | "tel" | "text" | The input type. |
size | "default" | "large" | "medium" | "small" | "mini" | "default" | The size of the input. |
...restProps | Various HTML input attributes and event handlers. | Additional attributes and event handlers passed down to the underlying input element. |
Try It
import { Input, Button } from '@kloktun/uikit' import DuckIcon from './duck-icon.tsx' import SearchIcon from './search-icon.tsx' export default function InputExample() { const handleDebounce = (value) => { console.log("Debounced value:", value); } return ( <div className="flex flex-col gap-4"> <Input placeholder="Enter text" /> <Input placeholder="Large enter text" size="large" /> <Input prefixPlaceholder="https://" append={<Button type="borderless">Save</Button>} /> <Input suffixText=".com" /> <Input prefixIcon={<DuckIcon />} suffixIcon={<SearchIcon />} /> <Input prefixIcon={<DuckIcon />} suffixIcon={<SearchIcon />} togglePassword type="password" onDebounce={handleDebounce} /> </div> ); }