Date Picker
A date picker component for selecting single dates with calendar dropdown.
Installation
bash
npx @galaxy-stack/nebula-cli@latest add date-pickerbash
pnpm dlx @galaxy-stack/nebula-cli@latest add date-pickerbash
yarn dlx @galaxy-stack/nebula-cli@latest add date-pickerbash
bunx @galaxy-stack/nebula-cli@latest add date-pickerbash
# If you have installed galaxy-design globally
galaxy-design add date-pickerDependencies
This component automatically installs the following dependencies:
- React:
react-day-picker,date-fns - Vue:
radix-vue,vue-datepicker - Angular:
@radix-ng/primitives,date-fns - React Native: Not available (use date-time-picker instead)
- Flutter: Not available (use built-in DatePicker)
No manual installation needed!
Usage
Basic Example
tsx
import { DatePicker } from "@/components/ui/date-picker"
export default function DatePickerDemo() {
return <DatePicker placeholder="Pick a date" />
}vue
<script setup lang="ts">
import { DatePicker } from '@/components/ui/date-picker'
</script>
<template>
<DatePicker placeholder="Pick a date" />
</template>With Form
tsx
import { useForm } from "react-hook-form"
import { Form, FormField, FormItem, FormLabel, FormControl, FormMessage } from "@/components/ui/form"
import { DatePicker } from "@/components/ui/date-picker"
import { Button } from "@/components/ui/button"
export default function DatePickerForm() {
const form = useForm({
defaultValues: {
date: undefined,
},
})
function onSubmit(values: { date: Date }) {
console.log(values)
}
return (
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
<FormField
control={form.control}
name="date"
render={({ field }) => (
<FormItem>
<FormLabel>Date of Birth</FormLabel>
<FormControl>
<DatePicker {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<Button type="submit">Submit</Button>
</form>
</Form>
)
}API Reference
Props
| Prop | Type | Default | Description | Framework Support |
|---|---|---|---|---|
date | Date | undefined | Selected date | All |
defaultDate | Date | undefined | Default selected date | All |
placeholder | string | 'Pick a date' | Placeholder text | All |
disabled | boolean | false | Disable the picker | All |
minDate | Date | undefined | Minimum selectable date | All |
maxDate | Date | undefined | Maximum selectable date | All |
className / class | string | '' | CSS class names | All |
Accessibility
- Keyboard Navigation: Arrow keys to navigate calendar, Enter to select
- Screen Reader: Uses proper ARIA labels and live regions
- Focus Management: Focus trap in calendar dropdown
- WCAG Compliance: WCAG 2.1 Level AA compliant
Author
Bùi Trọng Hiếu (kevinbui)
- GitHub: @buikevin
- Email: kevinbui210191@gmail.com
License
MIT © 2025 Bùi Trọng Hiếu (kevinbui)
