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.
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
Choose something else when
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
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.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Optional class hook applied to the public root element owned by the component. |
name | string | — | Configures name for this component. |
value | string | — | Configures value for this component. |
min | string | — | Configures min for this component. |
max | string | — | Configures max for this component. |
size | Size | — | Configures size for this component. |
year | number | — | Configures year for this component. |
month | number | — | Configures month for this component. |
open | boolean | — | Configures open for this component. |
Complete TypeScript API
Import from @tavojs/ui/date-picker. Published exports: DatePicker, DatePickerProps.
DatePickerProps
| Property | Type | Required | Description |
|---|---|---|---|
children | Child | No | Inherited children attribute accepted by DatePicker. |
className | string | No | Optional class hook applied to the public root element owned by the component. |
sx | Sx | No | Inherited sx attribute accepted by DatePicker. |
id | string | No | Inherited id attribute accepted by DatePicker. |
role | string | No | Inherited role attribute accepted by DatePicker. |
style | Record<string, unknown> | No | Inherited style attribute accepted by DatePicker. |
title | string | No | Inherited title attribute accepted by DatePicker. |
tabIndex | number | No | Inherited tabIndex attribute accepted by DatePicker. |
hidden | boolean | No | Inherited hidden attribute accepted by DatePicker. |
disabled | boolean | No | Inherited disabled attribute accepted by DatePicker. |
onClick | TavoEventHandler<MouseEvent> | No | Inherited onClick attribute accepted by DatePicker. |
onChange | TavoEventHandler<Event> | No | Inherited onChange attribute accepted by DatePicker. |
onInput | TavoEventHandler<Event> | No | Inherited onInput attribute accepted by DatePicker. |
onKeyDown | TavoEventHandler<KeyboardEvent> | No | Inherited onKeyDown attribute accepted by DatePicker. |
onFocus | TavoEventHandler<FocusEvent> | No | Inherited onFocus attribute accepted by DatePicker. |
onBlur | TavoEventHandler<FocusEvent> | No | Inherited onBlur attribute accepted by DatePicker. |
name | string | No | Configures name for this component. |
inputLabel | string | No | Inherited inputLabel attribute accepted by DatePicker. |
value | string | No | Configures value for this component. |
min | string | No | Configures min for this component. |
max | string | No | Configures max for this component. |
size | Size | No | Configures size for this component. |
year | number | No | Configures year for this component. |
month | number | No | Configures month for this component. |
open | boolean | No | Configures open for this component. |
renderCalendarWhenClosed | boolean | No | Inherited renderCalendarWhenClosed attribute accepted by DatePicker. |
onValueChange | (value: string) => void | No | Inherited onValueChange attribute accepted by DatePicker. |
State ownership and DOM target
| Concern | Contract |
|---|---|
| State | Use open, value to supply rendered state. Update it through the documented callback or native event handler. |
| DOM target | Root 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
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
| Contract | Current value |
|---|---|
| Maturity | stable |
| Category | forms |
| Component import | @tavojs/ui/date-picker |
| Explicit CSS import | @tavojs/ui/css/date-picker |
| Preview | Interactive preview available on this page |