@k8ordo/ui

DatePicker

A date input with a calendar that opens in a popover.

Import

ts
import { DatePicker } from '@k8ordo/ui';

Usage

tsx
<DatePicker aria-label="Check-in" defaultValue="2026-09-25" name="checkIn" />

Firefox draws its own calendar button inside every date input and offers no way to hide it. So in Firefox the field shows two calendar buttons.

Controlled

onChange receives the value: YYYY-MM-DD, or '' when empty. It is the same whether the date was picked from the calendar or typed.

2026-09-25

tsx
const [value, setValue] = useState('2026-09-25');

<DatePicker aria-label="Check-in" onChange={setValue} value={value} />

Min and max

tsx
<DatePicker
  aria-label="Check-in"
  defaultValue="2026-09-25"
  max="2026-10-15"
  min="2026-09-20"
/>

Disabled

tsx
<DatePicker aria-label="Check-in" defaultValue="2026-09-25" disabled />

With @k8ordo/form

A date picked from the calendar is written into the input, and an input event fires. The form sees it just as if it had been typed, so dirty state, rules and clearing an error all work.

tsx
// schema.ts
export const bookingSchema = z.object({ checkIn: z.iso.date() });

// booking-form.tsx
const checkIn = form.field('checkIn');

<FormControl
  errorText={checkIn.error}
  invalid={checkIn.invalid}
  label="Check-in"
  required={checkIn.required}
  renderInput={(props) => <DatePicker {...props} {...checkIn.input} />}
/>

Props

defaultValue?
Type: string
Default: -
invalid?
Type: boolean
Default: false
onChange?
Type: (value: string) => void
Default: -
ref?
Type: Ref<HTMLInputElement>
Default: -
value?
Type: string
Default: -
PropTypeDefault
defaultValue?string-
invalid?booleanfalse
onChange?(value: string) => void-
ref?Ref<HTMLInputElement>-
value?string-

Inherited attributes (except the ones set internally): InputHTMLAttributes<HTMLInputElement>

The wording this component draws (labels, placeholders, and so on) comes from the message dictionary unless a prop sets it. To replace it, see: i18n

k8ordo

React libraries that use Baseline features without holding back.