Date Picker
A highly flexible, headless-inspired calendar component. It renders a month view based on a provided date, giving you full control over navigation and layout.
Props
Prop | Type | Default | Description |
|---|---|---|---|
componentId | string | undefined | The unique identifier for the component wrapper. |
variant | string | '' | Custom variant class for theming. |
currentDate | string | new Date().toISOString() | ISO 8601 formatted date string that determines the displayed month. Supports $bindable. |
startDate | string | undefined | Selected start date (ISO 8601). Supports $bindable. |
endDate | string | undefined | Selected end date (ISO 8601). Supports $bindable. |
weekDays | string[] | ['Mon', 'Tue', ...] | Array of week day names to display in the header. |
hideRollingDays | boolean | false | Whether to hide days from previous/next months. |
Samples
1. Single Month with External Navigation
Control the displayed month by updating the currentDate prop from outside.
March
Mon
Tue
Wed
Thu
Fri
Sat
Sun
0
<script>1
import { DatePicker } from 'fluid-ui-svelte/components';2
import { Button, Container } from 'fluid-ui-svelte/base';3
4
let currentDate = $state(new Date().toISOString());5
6
const changeMonth = (increment: number) => {7
const date = new Date(currentDate);8
date.setMonth(date.getMonth() + increment);9
currentDate = date.toISOString();10
};11
</script>12
13
<Container class="flex flex-col gap-4">14
<Container class="flex gap-2">15
<Button onclick={() => changeMonth(-1)}>Prev</Button>16
<Button onclick={() => changeMonth(1)}>Next</Button>17
</Container>18
<DatePicker bind:currentDate componentId="calendar-single" />19
</Container>2. Multi Calendar
Connect multiple calendars to the same state variables.
March
Mon
Tue
Wed
Thu
Fri
Sat
Sun
April
Mon
Tue
Wed
Thu
Fri
Sat
Sun
0
<script>1
import { DatePicker } from 'fluid-ui-svelte/components';2
import { Button, Container } from 'fluid-ui-svelte/base';3
4
const multiCalendarState = $state({5
currentDate: new Date().toISOString(),6
startDate: '',7
endDate: ''8
});9
10
const changeMonthMulti = (inc: number) => {11
const d = new Date(multiCalendarState.currentDate);12
d.setMonth(d.getMonth() + inc);13
multiCalendarState.currentDate = d.toISOString();14
};15
</script>16
17
<Container class="flex flex-col gap-4">18
<Container class="flex gap-2">19
<Button onclick={() => changeMonthMulti(-1)}>Prev</Button>20
<Button onclick={() => changeMonthMulti(1)}>Next</Button>21
</Container>22
23
<Container class="flex gap-8 flex-wrap">24
<DatePicker 25
bind:currentDate={multiCalendarState.currentDate} 26
bind:startDate={multiCalendarState.startDate} 27
bind:endDate={multiCalendarState.endDate} 28
/>29
<DatePicker 30
currentDate={new Date(new Date(multiCalendarState.currentDate).setMonth(new Date(multiCalendarState.currentDate).getMonth() + 1)).toISOString()} 31
bind:startDate={multiCalendarState.startDate} 32
bind:endDate={multiCalendarState.endDate} 33
/>34
</Container>35
</Container>