Talisman LogoTalisman Logo Design System
Browse documentation
Components

Date and time picker

Picks a date, a time, or both from a popover with a calendar and time fields, with optional typing in the field.

Stableimport { DateTimePicker } from "@repo/ui/date-picker";Source

Select the field to open the calendar. Choose a day, set the time and select Salvar.

When to use

  • To choose a date with a time, such as a hearing or a deadline with an hour.
  • To choose only a time (mode="time").
  • To choose a date that people may also type, with editable.

When not to use

Examples

Date only

granularity="day" hides the time fields. closeOnSelect closes the popover after a day is chosen.

Time only

Typing a date

With editable the field accepts dd/MM/yyyy and applies a mask. Typing a date that is disabled shows an error under the field.

Weekdays only

disableWeekends disables Saturday and Sunday. Combine it with calendarProps.disabled for other restrictions, such as holidays.

Two months

view="double" shows two months side by side, which helps when the next date is usually in the following month.

Title and close button

States

Disabled

Read only

The value looks normal, but the field never opens.

Content

  • Name the field by the event: “Data da audiência”, “Prazo de contestação”.
  • The default placeholder is “Selecione uma data” and the editable one is “dd/mm/aaaa”. Pass placeholder for a more specific hint.
  • Pass locale for the calendar. It defaults to pt-BR, as do all labels. Pass labels to translate every string.
  • Always pass defaultMonth or a value when the output must be predictable. Without them the calendar opens on the current month.

Accessibility

  • The trigger is a button that opens a Radix Popover. Focus is not moved into the popover on open, so the user keeps typing or tabbing from the field. Focus leaving both the field and the popover closes it.
  • The popover opens on focus as well as on click.
  • The calendar is react-day-picker: arrow keys move between days, PageUp and PageDown change month, Enter or Space select. Disabled days cannot be selected.
  • The month and year selects, the previous and next buttons and the close button have aria-labels that come from labels. The hour, minute and second inputs also have names, and ArrowLeft and ArrowRight move between them.
  • In editable mode the input has aria-label (the placeholder) unless you pass id with an external <label>. Errors are linked with aria-describedby, and the field sets aria-invalid. Enter closes the popover.
  • Pass aria-describedby and aria-invalid from your form to link help text and errors.

Code

import { DateTimePicker } from "@repo/ui/date-picker";

const [date, setDate] = useState<Date | undefined>();

<DateTimePicker
  granularity="minute"
  onChange={setDate}
  placeholder="Selecione a data da audiência"
  value={date}
/>;

Props

DateTimePicker
PropTypeDefaultDescription
disabledbooleanfalseBlocks opening the calendar and typing
disableWeekendsbooleanfalseDisables Saturday and Sunday in the calendar
editablebooleanfalseLets people type the date in the field (dd/MM/yyyy)
granularity"day" | "hour" | "minute" | "second"secondSmallest unit shown in the time controls
hourCycle"12" | "24"24Shows the time in 24 hours or 12 hours with AM/PM
mode"date-time" | "time"date-timeCalendar and time (default) or time only
placeholderstring"Selecione uma data"Text shown when no date is selected
readOnlybooleanfalseShows the value but never opens the calendar
view"single" | "double"singleOne month or two months side by side
More props
PropTypeDefaultDescription
valueDate—Selected date and time. Controlled by the caller.
onChange(date: Date | undefined) => void—Called when the date or the time changes, or when the user clears it.
defaultMonthDate—Month shown when there is no value. It does not select a date.
localeLocaleptBRdate-fns locale for the calendar and the displayed date.
displayFormat{ hour24?: string; hour12?: string }—date-fns format of the displayed value.
yearRangenumber50Years offered before and after the current year in the year select.
closeOnSelectbooleanfalseCloses the popover after a day is chosen.
align"start" | "center" | "end""end"Alignment of the popover to the trigger.
title / titleLabelboolean / stringfalse / "Título"Shows a heading at the top of the popover. Pass titleLabel translated.
dismissablebooleanfalseShows a close button at the top of the popover.
calendarProps{ disabled, components, classNames }—Restrictions and customization of the calendar.
containerHTMLElement | null—Portal target of the popover. Use it inside themed wrappers.
labelsobject—Every user-visible string: placeholder, clearButton, saveButton, closeButton, prevMonth, nextMonth, monthSelect, yearSelect, hour, minute, second, unavailableDate.
weekStartsOn, showWeekNumber, showOutsideDaysCalendar props—Passed to the calendar.
id, triggerId, aria-describedby, aria-invalidstring / AriaAttributes—Attributes for forms. `triggerId` goes to the button, `id` to the input when editable.

Known issues

Issue Effect
The popover opens when the trigger receives focus. Tabbing through a form opens the calendar on every date field, and it covers the next fields.
Disabled editable fields use opacity-50, and hover uses hover:bg-neutral-black/5. Translucent fills and opacity lower contrast and ignore the solid-background rule.
The popover has a hardcoded rgba(0,0,0,0.15) shadow and a hsl(var(--stroke-tertiary)) border. The colors do not come from the shared tokens, so a theme change does not reach them.
titleLabel defaults to “Título” and the weekend error message “Por favor, informe um dia útil” is hardcoded. Apps cannot translate the weekend message, and the default title is generic.
Without value and defaultMonth, the calendar opens on new Date(). The first month depends on the clock, which makes screenshots and tests unstable.
The calendar days (day_button) define hover but no focus-visible style. Keyboard users rely on the browser default outline to see the focused day.
Today uses bg-black/5 and the selected day border-white/15 and text-neutral-black. Translucent fills and fixed colors do not adapt to Dark and Darker themes.
Edit this page on GitHub