# Time input (UI SDK): Controller

> `createTimeInputController()` sets, clears or focuses the field from anywhere. Focus a part by its unit, like `"minute"`.

Canonical: https://hextaui.com/docs/ui-sdk-time-input/examples/controller

Component docs: https://hextaui.com/docs/ui-sdk-time-input

## Add this example

```bash
npx shadcn@latest add https://hextaui.com/r/ui-sdk-time-input-controller.json
```

This adds `components/examples/ui-sdk-time-input/controller.tsx` with the Time input component and the HextaUI theme tokens.

## Source

```tsx title="components/examples/ui-sdk-time-input/controller.tsx"
"use client"

import * as React from "react"

import { Button } from "@/components/ui/button"
import { Label } from "@/components/ui/label"
import {
  TimeInput,
  createTimeInputController,
} from "@/components/ui/ui-sdk-time-input"

function now() {
  const date = new Date()
  return `${String(date.getHours()).padStart(2, "0")}:${String(
    date.getMinutes()
  ).padStart(2, "0")}`
}

function UiSdkTimeInputController() {
  const [controller] = React.useState(createTimeInputController)
  const [value, setValue] = React.useState<string | null>(null)

  return (
    <div className="flex w-full max-w-56 flex-col gap-2">
      <Label id="log-time">Logged at</Label>
      <TimeInput
        aria-labelledby="log-time"
        controller={controller}
        onValueChange={(next) => setValue(next)}
      />
      <div className="flex items-center gap-2 pt-1">
        <Button
          size="sm"
          variant="outline"
          onClick={() => controller.setValue(now())}
        >
          Now
        </Button>
        <Button
          size="sm"
          variant="ghost"
          onClick={() => controller.focus("minute")}
        >
          Edit minutes
        </Button>
        <Button size="sm" variant="ghost" onClick={() => controller.clear()}>
          Clear
        </Button>
      </div>
      <p className="m-0 text-xs text-muted-foreground tabular-nums">
        {value ? `Value ${value}` : "Value null"}
      </p>
    </div>
  )
}

export { UiSdkTimeInputController }
```

## Props in this example

### TimeInput

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `onValueChange` | `(value: string \| null, details) => void` | – | Runs once every part holds something, and with null when one is emptied. |
| `controller` | `TimeInputController` | – | From createTimeInputController(). |

## More Time input examples

- [Clock and seconds](https://hextaui.com/docs/ui-sdk-time-input/examples/clock)
- [Min and max](https://hextaui.com/docs/ui-sdk-time-input/examples/min-max)
- [Invalid](https://hextaui.com/docs/ui-sdk-time-input/examples/range)
- [Locale](https://hextaui.com/docs/ui-sdk-time-input/examples/locale)
- [Form](https://hextaui.com/docs/ui-sdk-time-input/examples/form)
- [Disabled](https://hextaui.com/docs/ui-sdk-time-input/examples/disabled)
- [Read-only](https://hextaui.com/docs/ui-sdk-time-input/examples/read-only)
- [Right to left](https://hextaui.com/docs/ui-sdk-time-input/examples/rtl)
