Birthday Date

Web/Mobile

A labeled birthday field with separate day, month, and year inputs. Values always display as Persian digits.

لطفاً تاریخ تولد را به‌صورت روز/ماه/سال وارد کنید.

Installation

pnpm dlx cubix-ui@latest add birthday-date --base aria

Usage

Import
import {
  BirthdayDate,
  BirthdayDateControl,
  BirthdayDateDay,
  BirthdayDateDescription,
  BirthdayDateLabel,
  BirthdayDateMonth,
  BirthdayDateSeparator,
  BirthdayDateYear,
} from "@/components/cubix/birthday-date"
Example
<BirthdayDate className="w-full max-w-sm">
  <BirthdayDateLabel>تاریخ تولد</BirthdayDateLabel>
  <BirthdayDateControl>
    <BirthdayDateDay />
    <BirthdayDateSeparator />
    <BirthdayDateMonth />
    <BirthdayDateSeparator />
    <BirthdayDateYear />
  </BirthdayDateControl>
  <BirthdayDateDescription>
    لطفاً تاریخ تولد را به‌صورت روز/ماه/سال وارد کنید.
  </BirthdayDateDescription>
</BirthdayDate>

Composition

Compose label, control, help text, and error under BirthdayDate. Inside the control, day, month, and year each render as a separate input with BirthdayDateSeparator between them. Digits always display in Persian. Filling a segment moves focus to the next; Backspace on an empty segment moves back. Paste a full date to fill all parts. Use parseBirthdayDateValue and formatBirthdayDateValue for the combined string.

Structure
BirthdayDate
├── BirthdayDateLabel
├── BirthdayDateControl
│   ├── BirthdayDateDay
│   ├── BirthdayDateSeparator
│   ├── BirthdayDateMonth
│   ├── BirthdayDateSeparator
│   └── BirthdayDateYear
├── BirthdayDateDescription
└── BirthdayDateError

Accessibility

Each segment has its own accessible name (day, month, year). Auto-advance and Backspace keep keyboard entry on one path without trapping focus. BirthdayDateDescription and BirthdayDateError are announced through aria-describedby, and invalid sets aria-invalid on every segment. Set name on the root to submit a single hidden value for the full date.

Examples

Description

Add helper text below the control for format hints or guidance.

لطفاً تاریخ تولد را به‌صورت روز/ماه/سال وارد کنید.

Filled

Pass defaultValue on each segment to show a complete date.

لطفاً تاریخ تولد را به‌صورت روز/ماه/سال وارد کنید.

Invalid

Set invalid on the root to apply destructive styles and show BirthdayDateError.

Disabled

Disable the field to block every segment. The control uses a muted fill; label and description stay readable.

این فیلد فعلاً قابل ویرایش نیست.

Sizes

Two heights ship by default: default (40px) and lg (48px). Use className for any other size.

ارتفاع ۴۰ پیکسل

ارتفاع ۴۸ پیکسل

In a form

Set name on the root so the combined date is submitted with the form, and pair the field with Cubix Button.

ثبت‌نام

برای ادامه، تاریخ تولد خود را وارد کنید.

لطفاً تاریخ تولد را به‌صورت روز/ماه/سال وارد کنید.

Custom styling

Every part accepts a className merged with the shipped cn helper. Here each segment uses a filled surface instead of the default outline.

با className می‌توانید ظاهر را سفارشی کنید.

API Reference

Note: Parts render data-slot attributes (birthday-date, birthday-date-label, birthday-date-control, birthday-date-day, birthday-date-month, birthday-date-year, birthday-date-separator, birthday-date-description, birthday-date-error) for targeting in tests and parent selectors. Use the same props on Base UI, React Aria, and Radix.

BirthdayDate

PropTypeDefaultDescription
size"default" | "lg""default"Height for the control: default 40px, lg 48px. Inherited by BirthdayDateControl unless overridden. Use className for other heights.
disabledbooleanfalseDisables the field and prevents interaction. Forwarded to the segments on every base.
invalidbooleanfalseMarks the field as invalid and shows BirthdayDateError when present.
namestring-Writes a hidden input with the combined day/month/year value (Persian digits, slash-separated) for form submit.
classNamestring-Additional Tailwind classes merged with the root styles (last one wins).

BirthdayDateControl

PropTypeDefaultDescription
size"default" | "lg"-Overrides the size from BirthdayDate. Height matches the default and lg sizes.
childrenReact.ReactNode-Compose BirthdayDateDay, BirthdayDateSeparator, BirthdayDateMonth, BirthdayDateSeparator, and BirthdayDateYear. The control is a layout row only - each segment has its own input box.
classNamestring-Additional Tailwind classes merged with the control styles (last one wins).

BirthdayDateDay / Month / Year

PropTypeDefaultDescription
part"day" | "month" | "year"-Fixed by BirthdayDateDay (2 digits), BirthdayDateMonth (2 digits), and BirthdayDateYear (4 digits). Values always display as Persian digits.
placeholderstringروز / ماه / سالHint text shown when the segment is empty.
inputMode"numeric""numeric"Locked to numeric so mobile keyboards show a number pad.
classNamestring-Additional Tailwind classes merged with the segment styles (last one wins).
...propsOmit<React.ComponentProps<'input'>, 'type' | 'inputMode' | 'spellCheck' | 'maxLength'>-Native input attributes (value, onChange, defaultValue, ...) are forwarded. type, inputMode, spellCheck, and maxLength stay locked. Use parseBirthdayDateValue / formatBirthdayDateValue for the combined string.

BirthdayDateSeparator

PropTypeDefaultDescription
childrenReact.ReactNode"/"Separator between day, month, and year. Defaults to /.
classNamestring-Additional Tailwind classes merged with the separator styles (last one wins).

BirthdayDateLabel / Description / Error

PropTypeDefaultDescription
classNamestring-Additional Tailwind classes merged with the part styles (last one wins).
...propsHTML attributes-Native attributes for the rendered element are forwarded.