Talisman LogoTalisman Logo Design System
Browse documentation
Components

Date input

A masked text field for typing a date. It accepts only digits, inserts the separators and reports a Date once the value is complete and valid.

Stableimport { DateInput } from "@repo/ui/date-input";Source

Digite apenas números.

format
size
variant
<DateInput format="DMY" hint="Digite apenas números." label="Data do protocolo" size="sm" variant="default" />

Type digits only: the slashes are added for you. The component default format is MDY, so pass format="DMY" for Brazilian dates.

When to use

  • To type a known date quickly: protocol date, hearing date, deadline.
  • In dense forms and filters where a calendar would take too much room.
  • When users paste dates from other systems.

When not to use

  • Picking a date by browsing a calendar. Use Date picker.
  • A period with a start and an end. Use Date range.
  • A time of day. The component has no time mask.

Formats

format sets the order of day, month and year and where the slashes go.

Format Mask Use for
DMY 00/00/0000 Brazilian dates. Pass it explicitly.
MDY 00/00/0000 Default. United States order.
YMD 0000/00/00 Sortable dates and technical data.

Variants

variant sets the validation state, as in Input.

Data do protocolo.

Data inválida. Use dia, mês e ano.

Data confirmada.

Sizes

Size Height Use for
lg 56px Prominent forms.
md 48px Touch devices.
sm 40px Default. Forms and dialogs.
xsm 36px Compact layouts and filters.
xxs 32px Dense tables and toolbars.

States

Hover and focus come from the browser: point at a field or press Tab to see them.

Icon

Behavior

  • onChange fires only when all eight digits form a real date. February 30th or month 13 never reach it.
  • onClear fires when the user empties the field.
  • onInputStatusChange reports empty, invalid or valid while typing, so a form can flag a half-typed date that onChange never saw.
  • Non-numeric keys are blocked and pasted text is stripped to its digits.

Content

  • Label with the meaning of the date: “Data do protocolo”, “Prazo de resposta”.
  • Do not repeat the format in the label. The placeholder already shows it.
  • Use the hint for the error: “Data inválida. Use dia, mês e ano.”

Do and don’t

DoPass format DMY so the order matches what Brazilian users expect.
Don'tDon't rely on the default. MDY reads 03/04/2025 as March 4th.

Accessibility

  • A native <input type="text"> with a label linked by a generated id. Without label, pass aria-label.
  • hint is referenced through aria-describedby, merged with any value you pass.
  • variant="error" sets aria-invalid. Say the error in the hint, not with color alone.
  • The mask hides nothing from assistive technology: the user hears the digits and slashes typed so far.
  • Focus changes the border of the shell to the focus token.
  • Hit targets run from 32px to 56px, above the 24px minimum.

Code

import { DateInput } from "@repo/ui/date-input";

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

<DateInput
  format="DMY"
  label="Data do protocolo"
  onChange={setDate}
  onClear={() => setDate(undefined)}
  value={date}
/>;

Props

PropTypeDefaultDescription
disabledbooleanfalseDisables the field
format"DMY" | "MDY" | "YMD"MDYOrder of day, month and year. The component default is MDY, so Brazilian forms must pass DMY
highlightbooleanfalseDraws a highlight border to call attention to the field
hintstring—Helper or error text below the field. Its color follows `variant`
iconLeadingReactNode—Icon on the leading side, sized to 16px
iconTrailingReactNode—Icon on the trailing side, sized to 16px
labelstring—Label above the field, linked to the input
onChange(date: Date) => void—Called with a `Date` once the typed date is complete and valid
onClear() => void—Called when the user empties the field
onInputStatusChange(status: "empty" | "invalid" | "valid") => void—Reports whether the typed text is `empty`, `invalid` or `valid`, so forms can flag half-typed dates
size"lg" | "md" | "sm" | "xsm" | "xxs"smHeight, padding and type size
trailingTextstring—Secondary text at the end of the label row
valueDate—Controlled date
variant"blocked" | "default" | "error" | "ghost" | "success"defaultValidation state. `error` also sets `aria-invalid`; `blocked` disables the field

DateInput also accepts the Input props label, hint, trailingText, size, variant, highlight and disabled, plus native input attributes. It ignores left, right, type and placeholder.

Known issues

Issue Effect
The default format is MDY. Brazilian forms that forget format="DMY" read and write dates in the wrong order.
The placeholder is fixed to “00/00/0000” and cannot be changed. Apps cannot show a translated hint such as “dd/mm/aaaa”.
Disabled uses opacity-50 and hover uses hover:bg-neutral-black/5 on the shell. Translucent fills, which the repository avoids. Disabled text loses contrast.
The label and hint are a raw <label> and <p> with text-xs, and the input sets style={{ outline: "none" }}. They do not follow the Typography tokens, and the inline style cannot be overridden by classes.
It copies the Input styles instead of reusing them. The two components can drift apart when Input changes.
Edit this page on GitHub