Skip to content

DatePicker

DatePicker is a read-only text field that opens the calendar in a popover (single or range). For an inline calendar with time and toggles, see DatePickerAdvanced.

import { DatePicker } from "phoundry-ui";

Single date

Loading interactive example…

View source
single-date.svelte
<script lang="ts">
import { DatePicker } from "phoundry-ui";
let singleDate = $state<Date | null>(null);
function formatDate(d: Date | null): string {
if (!d) return "none";
return d.toLocaleDateString();
}
</script>
<DatePicker
value={singleDate}
onchange={(d: Date) => {
singleDate = d;
}}
/>
<p class="mt-2 text-xs text-txt-tertiary">Selected: {formatDate(singleDate)}</p>

Date range

Loading interactive example…

View source
date-range.svelte
<script lang="ts">
import { DatePicker } from "phoundry-ui";
let rangeStart = $state<Date | null>(null);
let rangeEnd = $state<Date | null>(null);
function formatDate(d: Date | null): string {
if (!d) return "none";
return d.toLocaleDateString();
}
</script>
<DatePicker
mode="range"
{rangeStart}
{rangeEnd}
onrangechange={(s: Date, e: Date) => {
rangeStart = s;
rangeEnd = e;
}}
/>
<p class="mt-2 text-xs text-txt-tertiary">
Range: {formatDate(rangeStart)} - {formatDate(rangeEnd)}
</p>

Trigger size

Loading interactive example…

View source
trigger-size.svelte
<script lang="ts">
import { DatePicker } from "phoundry-ui";
let singleDate = $state<Date | null>(null);
</script>
<div class="flex flex-wrap items-end gap-3">
<DatePicker
value={singleDate}
onchange={(d: Date) => {
singleDate = d;
}}
inputSize="sm"
/>
<DatePicker
value={singleDate}
onchange={(d: Date) => {
singleDate = d;
}}
inputSize="lg"
/>
</div>
<p class="mt-2 text-xs text-txt-tertiary">
Same selection; <code>inputSize</code> only affects the field height.
</p>

Bounds, Monday week, placeholder

Loading interactive example…

View source
bounds-monday-week-placeholder.svelte
<script lang="ts">
import { DatePicker } from "phoundry-ui";
let singleDate = $state<Date | null>(null);
let constrainedDate = $state<Date | null>(null);
const minBoundary = new Date(2026, 4, 1);
const maxBoundary = new Date(2026, 4, 31);
function formatDate(d: Date | null): string {
if (!d) return "none";
return d.toLocaleDateString();
}
</script>
<div class="flex flex-wrap items-end gap-4">
<DatePicker
value={constrainedDate}
onchange={(d: Date) => {
constrainedDate = d;
}}
minDate={minBoundary}
maxDate={maxBoundary}
weekStartsOn={1}
placeholder="Pick a May 2026 date"
/>
<DatePicker
value={singleDate}
onchange={(d: Date) => (singleDate = d)}
disabled
placeholder="Disabled trigger"
/>
</div>
<p class="mt-2 text-xs text-txt-tertiary">
Constrained: {formatDate(constrainedDate)}
</p>

DatePicker props

From phoundry-ui@0.4.21

NameTypeDefaultDescription
valueDate | nullnullSelected date (single mode).
rangeStartDate | nullnullRange start date (range mode).
rangeEndDate | nullnullRange end date (range mode).
mode"single" | "range"'single'Selection mode.
onchange(date: Date) => void—Called when a single date is selected.
onrangechange(start: Date, end: Date) => void—Called when a range is completed.
minDateDate—Earliest selectable date.
maxDateDate—Latest selectable date.
disabledbooleanfalseDisable the input and picker.
weekStartsOn0 | 10First day of week: 0 = Sunday, 1 = Monday.
placeholderstring'Select date'Placeholder when empty.
inputSize"sm" | "md" | "lg"'md'Size of the read-only trigger field (passed to TextInput).
classstring''Additional CSS classes on the wrapper.

Usage tips

  • Use minDate and maxDate to constrain selectable dates.
  • In range mode, the first click sets the start and the second click sets the end.
  • Set weekStartsOn={1} for Monday-first calendars (ISO standard).

CSS styling

.ph-date-picker is the stable identification hook for DatePicker. Part selectors and --_ph-* properties are internal. Component CSS is scoped and unlayered; Consumer classes remain additive and utility overrides may lose precedence.

inputSize continues to select the nested TextInput control size. Date formatting, range selection, and callbacks are unchanged.

Keep the shared component stylesheet and a named Theme imported. Decorative motion respects reduced-motion preferences.

Documentation is licensed under CC BY 4.0. Phoundry names and marks remain reserved.