Navigated to /docs/ui/components/date-picker

DatePicker

Date input and calendar popover composition.

Preview

A live, theme-aware example rendered with the published component.

Loading preview…

Import

Import from the focused entry point below, or use the same named export from @tavojs/ui. Both are public APIs; measure the built application when comparing their bundle cost.

TSX
tsximport { DatePicker } from "@tavojs/ui/date-picker";

The component import loads compiled component CSS. Enable tavoUi() for your project theme variables, or import @tavojs/ui/theme.css once for the package default theme. The equivalent CSS-safe component alias is @tavojs/ui/css/date-picker.

When to use

Use it when

Use `DatePicker` for date input with a calendar popover. For a plain native date field, use `TextInput type="date"`

Choose something else when

Avoid DatePicker when wrapping controls without labels or accessible names.

Examples

These examples include imports and local state where interaction requires it. Render the exported component in a page after completing UI installation. Demo state stays in the mounted component; connect file handling, persistence, and data loading to your application as needed.

DatePicker example

TSXCreate: src/components/examples/DatePickerExample1.tsx
tsximport { createTavo } from "@tavojs/core";
import { DatePicker } from "@tavojs/ui/date-picker";
import { Text, Button } from "@tavojs/ui";

type State = { date: string; open: boolean };

export const DatePickerExample1 = createTavo<Record<string, never>, State>({
  model: () => ({ date: "2026-09-07", open: false }),
  view: ({ state, model }) => (
    <>
      <Text>Due date</Text>
      <Button onClick={() => model.set("open", !state.open)}>Toggle calendar</Button>
        <DatePicker
          inputLabel="Due date"
          name="due"
          value={state.date}
          year={2026}
          month={8}
          open={state.open}
          onValueChange={(date) => model.patch({ date, open: false })}
        />
      <Text>Due: {state.date || "No date selected"}</Text>
    </>
  )
});

Common props and defaults

A curated starting point. The complete TypeScript API below includes additional props and compound member contracts.

PropTypeDefaultDescription
classNamestring

Optional class hook applied to the public root element owned by the component.
namestring

Configures name for this component.
valuestring

Configures value for this component.
minstring

Configures min for this component.
maxstring

Configures max for this component.
sizeSize

Configures size for this component.
yearnumber

Configures year for this component.
monthnumber

Configures month for this component.
openboolean

Configures open for this component.

Complete TypeScript API

Import from @tavojs/ui/date-picker. Published exports: DatePicker, DatePickerProps.

DatePickerProps

PropertyTypeRequiredDescription
childrenChild

No

Inherited children attribute accepted by DatePicker.

classNamestring

No

Optional class hook applied to the public root element owned by the component.

sxSx

No

Inherited sx attribute accepted by DatePicker.

idstring

No

Inherited id attribute accepted by DatePicker.

rolestring

No

Inherited role attribute accepted by DatePicker.

styleRecord<string, unknown>

No

Inherited style attribute accepted by DatePicker.

titlestring

No

Inherited title attribute accepted by DatePicker.

tabIndexnumber

No

Inherited tabIndex attribute accepted by DatePicker.

hiddenboolean

No

Inherited hidden attribute accepted by DatePicker.

disabledboolean

No

Inherited disabled attribute accepted by DatePicker.

onClickTavoEventHandler<MouseEvent>

No

Inherited onClick attribute accepted by DatePicker.

onChangeTavoEventHandler<Event>

No

Inherited onChange attribute accepted by DatePicker.

onInputTavoEventHandler<Event>

No

Inherited onInput attribute accepted by DatePicker.

onKeyDownTavoEventHandler<KeyboardEvent>

No

Inherited onKeyDown attribute accepted by DatePicker.

onFocusTavoEventHandler<FocusEvent>

No

Inherited onFocus attribute accepted by DatePicker.

onBlurTavoEventHandler<FocusEvent>

No

Inherited onBlur attribute accepted by DatePicker.

namestring

No

Configures name for this component.

inputLabelstring

No

Inherited inputLabel attribute accepted by DatePicker.

valuestring

No

Configures value for this component.

minstring

No

Configures min for this component.

maxstring

No

Configures max for this component.

sizeSize

No

Configures size for this component.

yearnumber

No

Configures year for this component.

monthnumber

No

Configures month for this component.

openboolean

No

Configures open for this component.

renderCalendarWhenClosedboolean

No

Inherited renderCalendarWhenClosed attribute accepted by DatePicker.

onValueChange(value: string) => void

No

Inherited onValueChange attribute accepted by DatePicker.

State ownership and DOM target

ConcernContract
StateUse open, value to supply rendered state. Update it through the documented callback or native event handler.
DOM targetRoot props target the Popover wrapper. Use inputLabel for the nested native date input; name, value, min, and max configure that input.

Anatomy and related components

This component exposes one public component root rather than a compound member API.

Limitations

Avoid DatePicker when wrapping controls without labels or accessible names.

Use only the documented props, entry points, and compound members. Internal DOM nesting and CSS class names can change without becoming part of the public component contract.

Accessibility

Form components pass through native attributes and should be paired with visible labels or accessible names.

  • Use Field, FormLabel, FormControlLabel, or aria-label for labeling.

  • Preserve native input semantics whenever possible.

  • Expose validation with error text and aria-invalid where relevant.

Component status

ContractCurrent value
Maturitystable
Categoryforms
Component import@tavojs/ui/date-picker
Explicit CSS import@tavojs/ui/css/date-picker
PreviewInteractive preview available on this page