# Input: Controlled

> `onValueChange` hands you the string directly, so there’s no `event.target.value` to unwrap. `onChange` still works too.

Example: https://hextaui.com/docs/input/examples/controlled
Component docs: https://hextaui.com/docs/input.md

## Add this example

```bash
npx shadcn@latest add https://hextaui.com/r/input-controlled.json
```

This adds `components/examples/input/controlled.tsx` with the Input component and the HextaUI theme tokens.

## Source

```tsx title="components/examples/input/controlled.tsx"
"use client"

import * as React from "react"

import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"

const limit = 32

export function InputControlled() {
  const [value, setValue] = React.useState("Quarterly planning")

  return (
    <div className="flex w-full max-w-sm flex-col gap-2">
      <Label htmlFor="input-controlled">Project name</Label>
      <Input
        id="input-controlled"
        value={value}
        maxLength={limit}
        onValueChange={setValue}
        aria-describedby="input-controlled-count"
      />
      <p
        id="input-controlled-count"
        className="text-end text-sm text-muted-foreground tabular-nums"
      >
        {value.length}/{limit}
      </p>
    </div>
  )
}
```

## Props in this example

### Input

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `string \| number \| string[]` | – |  |
| `onValueChange` | `(value: string, details) => void` | – | Called with the new value on every change. |

## More Input examples

- [Sizes](https://hextaui.com/docs/input/examples/sizes.md)
- [With a description](https://hextaui.com/docs/input/examples/description.md)
- [Invalid](https://hextaui.com/docs/input/examples/invalid.md)
- [Native validation](https://hextaui.com/docs/input/examples/native-validation.md)
- [Disabled](https://hextaui.com/docs/input/examples/disabled.md)
- [Read only](https://hextaui.com/docs/input/examples/read-only.md)
- [File](https://hextaui.com/docs/input/examples/file.md)
- [Input types](https://hextaui.com/docs/input/examples/types.md)
- [With a button](https://hextaui.com/docs/input/examples/with-button.md)
- [Grid](https://hextaui.com/docs/input/examples/grid.md)
- [Long content](https://hextaui.com/docs/input/examples/long-content.md)
- [Right to left](https://hextaui.com/docs/input/examples/rtl.md)
