Date Picker
A date picker is a form field that opens a Calendar in a popover and shows the chosen date, such as a release date.
When to use
Section titled “When to use”- Use it for one date in a form, near today: a release date, a deadline.
- In long forms where people know the exact date, such as a birth date or a contract date years ago, a native date input (
<input type="date">) is faster to type. - Show the date as
14 Nov 2026. Send it to the backend as ISO2026-11-14, never as the displayed text.
Anatomy
Section titled “Anatomy”- 1Trigger showing the date
- 2Calendar icon
- 3Calendar in a popover
- 4Selected day
An outline Button with a calendar icon and the date, or the placeholder “Pilih tanggal” in muted-foreground. Clicking it opens the calendar in a Popover; picking a day closes it.
| React | Vue | Flutter | Type | Default | Use |
|---|---|---|---|---|---|
value, onValueChange |
v-model |
ShadDatePicker onChanged |
Date / DateValue / DateTime |
none | The chosen date. |
placeholder |
placeholder |
placeholder |
text | Pick a date |
Shown before a date is picked, such as “Pilih tanggal”. |
disabled |
disabled |
enabled: false |
boolean | false |
Turns the field off. |
locale |
locale |
the app’s locale |
locale | English (en-GB) | Month names, and how the date reads. For Indonesian, id from react-day-picker/locale or "id-ID". |
dateFormat |
formatDate |
text / function | the locale’s short date (14 Aug 2026) |
A date-fns pattern, when the date needs another shape. |
import { useState } from "react"import { id } from "react-day-picker/locale"import { DatePicker } from "@/components/ui/date-picker"
export default function DatePickerDemo() { const [date, setDate] = useState<Date>() return <DatePicker locale={id} value={date} onValueChange={setDate} placeholder="Pilih tanggal" className="w-56" />}<script setup lang="ts">import type { DateValue } from "@internationalized/date"import { shallowRef } from "vue"import { DatePicker } from "@/components/ui/date-picker"
const date = shallowRef<DateValue>()</script>
<template> <DatePicker v-model="date" locale="id-ID" placeholder="Pilih tanggal" class="w-56" /></template>// A date field that opens a calendar. Dates read "15 Nov 2026"; the app runs with locale: Locale('id').import 'package:flutter/widgets.dart';import 'package:shadcn_ui/shadcn_ui.dart';
class DatePickerDemo extends StatelessWidget { const DatePickerDemo({super.key});
@override Widget build(BuildContext context) { return ShadDatePicker( width: 256, placeholder: const Text('Pilih tanggal'), initialMonth: DateTime(2026, 11), weekStartsOn: 1, formatDate: (date) => DateFormat('d MMM yyyy', 'id').format(date), ); }}Install
Section titled “Install”npx shadcn@latest add https://design.sosialoka.tech/r/react/date-picker.jsonnpx shadcn-vue@latest add https://design.sosialoka.tech/r/vue/date-picker.jsonAccessibility
Section titled “Accessibility”- Opening the picker puts focus on the chosen day, or today, so the arrow keys work straight away.
- Enter picks the day and closes the popover; Escape closes it. Either way, focus goes back to the button.
- Give the field a visible label with Field, such as “Tanggal rilis”.
