# Input

Text input with sizes, validation and masks.

## How to use it

Associate a label using htmlFor and id. Use invalid for the visual error state and aria-describedby to explain how to fix it.



## Import


```tsx
import { Input } from "@kivora/nextjs";
```


Examples run in a Client Component. Also import the hooks, icons and dependencies used. This is the web API; consult the native guide for React Native.

## Example


```tsx
<div style={{ display: "grid", gap: 16, width: "100%", maxWidth: 360 }}>
  <Label htmlFor="demo-email">Email</Label><Input id="demo-email" type="email" placeholder="you@example.com" />
</div>
```


## Mask

```tsx
<Input aria-label="Phone" mask="000 000 000" placeholder="600 000 000" />
```


## Error

```tsx
<div style={{ display: "grid", gap: 16, width: "100%", maxWidth: 360 }}>
  <Input aria-label="Email" invalid defaultValue="incomplete email" aria-describedby="email-error" /><p id="email-error">Enter a valid email.</p>
</div>
```


## API: Input


```typescript
Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>
```


| Property | Type | Required | Description |
| --- | --- | --- | --- |
| alt | string | No | Alternative text for the image. |
| aria-label | string | No | Accessible name of the control. |
| autoComplete | HTMLInputAutoCompleteAttribute | No | Tell the browser which autocomplete type to use. |
| checked | boolean | No | Controlled selection state. |
| children | ReactNode | No | Content or child elements of the component. |
| className | string | No | Additional CSS classes to customize the element. |
| defaultChecked | boolean | No | Initial selection of the control. |
| defaultValue | string \| number \| readonly string[] | No | Initial value when the component manages its own state. |
| definitions | Record<string, RegExp> | No | See the published type. |
| disabled | boolean | No | Disable interaction with the control. |
| id | string | No | Element identifier; associates labels and descriptions. |
| invalid | boolean | No | Enable the visual error state. |
| lazy | boolean | No | See the published type. |
| mask | string \| RegExp | No | Mask or regular expression applied to input. |
| max | string \| number | No | Maximum allowed value. |
| maxLength | number | No | Maximum number of characters. |
| min | string \| number | No | Minimum allowed value. |
| name | string | No | Name used to identify the control in forms. |
| onAccept | ((value: string, maskRef: unknown, event?: InputEvent) => void) | No | Receives changes accepted by the mask. |
| onChange | ChangeEventHandler<HTMLInputElement, HTMLInputElement> | No | Change event. Check the type: some controls return an object, others a DOM event. |
| onClick | MouseEventHandler<HTMLInputElement> | No | Action performed when the element is activated. |
| onComplete | ((value: string, maskRef: unknown, event?: InputEvent) => void) | No | Callback when input or an operation is complete. |
| onSubmit | SubmitEventHandler<HTMLInputElement> | No | Form submission event. |
| overwrite | boolean | No | See the published type. |
| placeholder | string | No | Short hint displayed when there is no value. |
| placeholderChar | string | No | See the published type. |
| required | boolean | No | Indicates that a value is required. |
| role | AriaRole | No | Semantic role of the element. Keep the default role unless a change is justified. |
| size | "default" \| "sm" \| "lg" \| null | No | Visual size of the component. |
| src | string | No | Resource path or URL. |
| step | string \| number | No | Increment between values. |
| style | CSSProperties | No | React inline styles. |
| tabIndex | number | No | Keyboard focus order and availability. |
| title | string | No | Title or supplementary information. |
| type | HTMLInputTypeAttribute | No | Operation type or mode; values depend on the component. |
| unmask | boolean \| "typed" | No | Control the format of the value returned by the mask. |
| value | string \| number \| readonly string[] | No | Controlled value. Update it from the change callback. |

Source: https://kivora.pro/docs/componentes/input
