Simple date picker
A button that opens a calendar to pick a single date, with a clear action and no time fields.
Select the button, choose a day and the calendar closes. A Limpar button appears once there is a value.
When to use
- To choose one date with no time, such as a task deadline or a filing date.
- In forms and filter bars where a compact button fits.
- When the calendar needs month and year dropdowns to reach far dates.
When not to use
- A date with a time. Use the date and time picker.
- A period. Use the date range picker.
- A date people type from a document. Use the date and time picker with
editable, or the date input. - A calendar visible on the page. Use the calendar.
Sizes
The trigger takes the size of a Button. It defaults to sm (40px).
States
Empty
Disabled
Examples
Restricted dates
disabledDates takes a react-day-picker matcher or a list of them. This example
disables weekends. In the product, deadlines also disable days before today.
Content
- Name the field by what the date means: “Prazo da tarefa”, “Data de distribuição”.
- Pass
placeholdertranslated. The default is English (“Select date”). - The date is always shown as
dd/MM/yyyy, whatever thelocale. The locale changes the calendar texts. localedefaults to pt-BR. Pass the app locale for other languages.
Accessibility
- The trigger is a Button inside a Radix Popover:
EnterorSpaceopens it,Escapecloses it and focus returns to the trigger. - Give the trigger an accessible name: pass
idand connect a visible<label>(or aFormLabel). The icon is decorative and the text is only the date or the placeholder. - The calendar is
react-day-picker: arrow keys move between days,PageUpandPageDownchange the month,EnterorSpaceselect. Disabled days havearia-disabled. - Month and year are native dropdowns (
captionLayout="dropdown"), reachable by keyboard.
Code
import { SimpleDatePicker } from "@repo/ui/simple-date-picker";
const [deadline, setDeadline] = useState<Date | undefined>();
<SimpleDatePicker
disabledDates={[{ before: new Date() }, { dayOfWeek: [0, 6] }]}
id="prazo"
onChange={setDeadline}
placeholder="Selecione a data"
value={deadline}
/>;
Props
SimpleDatePicker| Prop | Type | Default | Description |
|---|---|---|---|
disabled | boolean | false | Blocks opening the calendar |
placeholder | string | "Select date" | Text shown when no date is selected |
popoverSide | "top" | "right" | "bottom" | "left" | — | Side of the trigger where the calendar opens |
showOutsideDays | boolean | true | Shows days from the previous and next month |
showWeekNumber | boolean | false | Shows the week number column |
size | "xxs" | "xs" | "sm" | "md" | "lg" | — | Size of the trigger button |
weekStartsOn | "0" | "1" | "2" | "3" | "4" | "5" | "6" | 1 | First day of the week, from 0 (Sunday) to 6 (Saturday) |
More props| Prop | Type | Default | Description |
|---|---|---|---|
value | Date | — | Selected date. Controlled by the caller. |
onChange | (date: Date | undefined) => void | — | Called when a day is chosen, or with undefined when cleared. |
disabledDates | Matcher | Matcher[] | — | react-day-picker matchers for days that cannot be chosen. |
locale | Locale | ptBR | date-fns locale of the calendar. |
id | string | — | Id of the trigger, to connect a label. |
popoverAvoidCollisions | boolean | — | Set false to keep the calendar anchored inside scrollable parents such as dialogs. |
popoverCollisionPadding | number | — | Distance from the viewport edge before the popover flips sides. |
calendarComponents, calendarClassNames | CalendarProps['components'], CalendarProps['classNames'] | — | Customization passed to the calendar. |
className | string | — | Layout classes for the trigger. |
Known issues
| Issue | Effect |
|---|---|
The default placeholder is “Select date” and the footer button “Limpar” is hardcoded. |
The default is English next to a Portuguese product, and apps cannot translate “Limpar”. |
The component has no defaultMonth prop. |
Without a value the calendar opens on the current month, and a form cannot open it on a due date. |
The displayed date is always dd/MM/yyyy. |
Other locales cannot show their own date format. |
The trigger chevron uses opacity-50. |
Opacity lowers contrast of the icon. |
| The trigger has no accessible name of its own. | Without an external label, a screen reader announces only the date or the placeholder. |