StacklyUI
Components/Date Picker

Date PickerNew

A polished date field — a formatted trigger wired to the dependency-free Calendar in a popover. Single or range mode, dual-month panels, quick-pick presets, colour-coded markers, a clearable value, and native form support.

01

Preview & playground

Edit the code — the preview updates live. Try changing props, text, or classes.

playground.tsx
function Demo() {
  const [date, setDate] = useState()
  return (
    <div className="w-64">
      <DatePicker value={date} onChange={setDate} placeholder="Pick a date" />
    </div>
  )
}
render(<Demo />)
02

Examples

Common variations — edit any of them live.

Range with presets

Two months side by side, plus a rail of one-click shortcuts.

playground.tsx
function Demo() {
  const [range, setRange] = useState()
  const days = (n) => {
    const to = new Date()
    const from = new Date()
    from.setDate(to.getDate() - (n - 1))
    return { from, to }
  }
  return (
    <div className="w-72">
      <DatePicker
        mode="range"
        value={range}
        onChange={setRange}
        placeholder="Pick a range"
        presets={[
          { label: "Last 7 days", value: () => days(7) },
          { label: "Last 30 days", value: () => days(30) },
        ]}
      />
    </div>
  )
}
render(<Demo />)

Bounded & custom format

Weekdays only for the next 60 days, with a long-form label.

playground.tsx
function Demo() {
  const [date, setDate] = useState()
  const today = new Date()
  const in60 = new Date()
  in60.setDate(today.getDate() + 60)
  return (
    <div className="w-64">
      <DatePicker
        value={date}
        onChange={setDate}
        fromDate={today}
        toDate={in60}
        disabledDate={(d) => d.getDay() === 0 || d.getDay() === 6}
        formatOptions={{ weekday: "short", month: "long", day: "numeric" }}
        placeholder="Weekdays only"
      />
    </div>
  )
}
render(<Demo />)
03

Installation

Copy the source into your project with the registry CLI:

$pnpm dlx shadcn@latest add @stacklyui/date-picker

Or install the package and import it:

$pnpm add @stacklyui/ui motion
04

Usage

Built on the self-contained Calendar + Popover — native Date + Intl, no react-day-picker or date-fns. Set mode to single or range (range defaults to two side-by-side months). The trigger label is formatted with Intl.DateTimeFormat — tune it with formatOptions + locale, or pass a fully custom format function. Bound the window with fromDate / toDate, grey out days with disabledDate, drop event dots with markers, and add one-click ranges with presets. clearable shows a reset ×; closeOnSelect closes once a (complete) selection is made. Works controlled (value + onChange) or uncontrolled (defaultValue), and emits hidden inputs when you pass name (name.from / name.to in range mode).