Inspector Date

About this component

Inspector Date

Settings row for a date, a time, or both: the row reads the value the way anyone would write it down and opens a real month calendar, while a time on its own keeps the platform's own field inline, since a time has no month to show.

Usage

The import and the props worth knowing about, in one place.

import { InspectorDate } from "@/components/beste/component/inspector-date";

// Uncontrolled. The value is the format the platform uses, which is also what a
// form submits and what new Date() parses.
<InspectorDate label="Publish on" defaultValue="2026-08-01" />

// Controlled
<InspectorDate label="Publish on" value={date} onValueChange={setDate} />

// A time, or both at once
<InspectorDate label="Opens at" mode="time" value={time} onValueChange={setTime} />
<InspectorDate label="Starts" mode="datetime" value={start} onValueChange={setStart} />

<InspectorDate
  label="Deadline"
  icon={CalendarClockIcon}  // optional leading icon; the mode brings its own
  tone="outline"            // "muted" (default) | "outline" | "ghost"
  size="sm"                 // "sm" | "default" | "lg"
  mode="datetime"
  min="2026-01-01T00:00"    // in the same format as the value
  max="2026-12-31T23:59"
  step={900}                // granularity in seconds
  name="deadline"           // takes part in a form
  required
  value={deadline}
  onValueChange={setDeadline}
/>

// The row's reading is deterministic on purpose, so the server and the browser
// agree on it. Bring your own locale where it can only run in one place:
<InspectorDate
  label="Publish on"
  value={date}
  onValueChange={setDate}
  formatValue={(iso) => new Date(iso).toLocaleDateString("tr-TR", { dateStyle: "long" })}
/>

// A clear button inside the panel, and a week that starts on Monday
<InspectorDate label="Publish on" clearable weekStartsOn={1} value={date} onValueChange={setDate} />

// The value is what a form submits, what `new Date()` parses, and what comes back
// out, and the calendar never turns it into anything else. Parsing is deliberately not
// `new Date("2026-08-01")`: a bare date string is read as UTC midnight, which is the
// evening before anywhere west of Greenwich.

Props

Read from the component's own type, so this cannot drift from what it accepts.

PropTypeDefaultDescription
label*string—Label rendered on the left, inside the row.
iconLucideIcon—Optional leading icon shown before the label. Defaults to the mode's own.
valuestring—Controlled value, in the format the platform uses: `2026-07-25` for a date, `14:30` for a time, `2026-07-25T14:30` for both. That is also what a form submits and what `new Date()` parses, so nothing has to be converted twice.
defaultValuestring—Initial value in uncontrolled mode.
onValueChange(value: string) => void—Fires whenever a day is picked, a time typed, or the value cleared.
onOpenChange(open: boolean) => void—Fires when the calendar opens or closes.
mode"date" | "time" | "datetime""date"What is being picked.
minstring—Earliest allowed value, in the same format.
maxstring—Latest allowed value, in the same format.
stepnumber—Granularity in seconds, for the time half.
formatValue(value: string) => string—How the value reads on the row. Use it to bring your own locale, which is the one thing this cannot do for you without guessing where it is running.
emptyLabelstring—What the row reads while there is no value.
clearableboolean—Offer a button that clears the value.
weekStartsOn0 | 1 | 2 | 3 | 4 | 5 | 6—Which day starts the week: 0 is Sunday, 1 is Monday.
disabledboolean—Block interaction and dim the row.
readOnlyboolean—Show the value but refuse edits.
tone"muted" | "outline" | "ghost""muted"Surface treatment: filled (default), hairline outline, or bare until hover.
size"sm" | "default" | "lg""default"Row height preset.
namestring—Name of the field, so the row can take part in a form.
idstring—Id of the field. One is generated when it is left out.
classNamestring—
aria-labelstring—Accessible name. Falls back to `label`.

More Inspector components

View all Inspector