Skip to content

Date Picker

A date picker component for selecting single dates with calendar dropdown.

Installation

bash
npx @galaxy-stack/nebula-cli@latest add date-picker
bash
pnpm dlx @galaxy-stack/nebula-cli@latest add date-picker
bash
yarn dlx @galaxy-stack/nebula-cli@latest add date-picker
bash
bunx @galaxy-stack/nebula-cli@latest add date-picker
bash
# If you have installed galaxy-design globally
galaxy-design add date-picker

Dependencies

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

PropTypeDefaultDescriptionFramework Support
dateDateundefinedSelected dateAll
defaultDateDateundefinedDefault selected dateAll
placeholderstring'Pick a date'Placeholder textAll
disabledbooleanfalseDisable the pickerAll
minDateDateundefinedMinimum selectable dateAll
maxDateDateundefinedMaximum selectable dateAll
className / classstring''CSS class namesAll

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)

License

MIT © 2025 Bùi Trọng Hiếu (kevinbui)

Released under the MIT License.