dentil

Date of Birth Input

DOBInput is three numeric fields instead of a calendar, which is faster for dates decades back. Focus moves on as soon as a field can't take another digit. Type 31 02 1990: the result stays undefined because the date isn't real.

@dentil/dob-input
On this page
Result: undefined

Installation

pnpm dlx shadcn@latest add @dentil/dob-input
npx shadcn@latest add @dentil/dob-input
yarn dlx shadcn@latest add @dentil/dob-input
bunx --bun shadcn@latest add @dentil/dob-input

Files land in components/dentil/dob-input/. Uses the stock shadcn input-group and react-number-format.

API reference

DOBInput

PropTypeDefaultDescription
value{ day; month; year } | null | undefined—Day and month are 1-based.
onChange(value: DOB | undefined) => void—Called on every keystroke: with the date once the three fields form a real date with a four-digit year, and undefined otherwise. 31/02 never reaches you.
disabledbooleanfalseDisables the three fields.
…propsComponentProps<'input'>—Other props (id, aria-invalid, aria-describedby, onBlur…) are passed to the day input. aria-invalid also reaches month and year.