HextaUI

Date input (UI SDK): Controller

createDateInputController() sets, clears or focuses the field from anywhere. Focus a part by its unit, like "year".

"use client"

import * as React from "react"

import { Button } from "@/components/ui/button"
import { Label } from "@/components/ui/label"
import {
  DateInput,
  createDateInputController,
} from "@/components/ui/ui-sdk-date-input"

function UiSdkDateInputController() {
  const [controller] = React.useState(createDateInputController)

  return (
    <div className="flex w-full max-w-60 flex-col gap-2">
      <Label id="publish-on">Publish on</Label>
      <DateInput aria-labelledby="publish-on" controller={controller} />
      <div className="flex items-center gap-2 pt-1">
        <Button
          size="sm"
          variant="outline"
          onClick={() => controller.setValue("2026-12-25")}
        >
          Christmas
        </Button>
        <Button
          size="sm"
          variant="ghost"
          onClick={() => controller.focus("year")}
        >
          Edit year
        </Button>
        <Button size="sm" variant="ghost" onClick={() => controller.clear()}>
          Clear
        </Button>
      </div>
    </div>
  )
}

export { UiSdkDateInputController }

This adds the example as components/examples/ui-sdk-date-input/controller.tsx, together with the Date input component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/ui-sdk-date-input-controller.json

To add only the component, follow the Date input installation.

Props in this example

The Date input props this example sets, from the API reference.

PropTypeDefault
controllerFrom createDateInputController().
DateInputController–

Every prop is in the Date input API reference.

See them all, with keyboard support and accessibility notes, on the Date input page.