DatePicker

A trigger button that opens a calendar popup for selecting a single date, with full keyboard navigation, min/max bounds, and no external date library.

Installation

npx @obi/ui add date-picker

Preview

Arrow keys navigate the calendar grid.

Usage

'use client';

import { useState } from 'react';
import { DatePicker } from '@/src/components/DatePicker/DatePicker';

export default function Example() {
  const [date, setDate] = useState<Date | null>(null);

  return (
    <div className="max-w-xs flex flex-col gap-4">
      <DatePicker
        label="Appointment date"
        placeholder="Pick a date"
        value={date}
        onChange={setDate}
        hint="Arrow keys navigate the calendar grid."
      />
      <DatePicker
        label="Disabled"
        value={null}
        onChange={() => {}}
        disabled
      />
    </div>
  );
}

Props

NameTypeDefaultDescription
valueDate | nullundefinedThe currently selected date (controlled).
onChange(date: Date) => voidundefinedCalled when the user selects a day.
placeholderstring'Pick a date'Text shown when no date is selected.
minDateundefinedEarliest selectable date.
maxDateundefinedLatest selectable date.
disabledbooleanfalseDisables the trigger.
labelstringundefinedVisible label above the trigger.
hintstringundefinedHelper text below the trigger.
errorstringundefinedError message; applies error border styling.
classNamestring''Additional classes on the root wrapper.