Date Range Picker
Facilitates the selection of date ranges through an input and calendar-based interface.
<script lang="ts">
import { type DateRange, DateRangePicker } from "bits-ui";
import CalendarBlank from "phosphor-svelte/lib/CalendarBlank";
import CaretLeft from "phosphor-svelte/lib/CaretLeft";
import CaretRight from "phosphor-svelte/lib/CaretRight";
import { cn } from "$lib/utils/index.js";
let value: DateRange = $state({ start: undefined, end: undefined });
</script>
<DateRangePicker.Root
bind:value
weekdayFormat="short"
fixedWeeks={true}
class="flex w-full max-w-[340px] flex-col gap-1.5"
>
<DateRangePicker.Label class="block select-none text-sm font-medium"
>Rental Days</DateRangePicker.Label
>
<div
class="flex h-input w-full select-none items-center rounded-input border border-border-input bg-background px-2 py-3 text-sm tracking-[0.01em] text-foreground focus-within:border-border-input-hover focus-within:shadow-date-field-focus hover:border-border-input-hover"
>
{#each ["start", "end"] as const as type}
<DateRangePicker.Input {type}>
{#snippet children({ segments })}
{#each segments as { part, value }}
<div class="inline-block select-none">
{#if part === "literal"}
<DateRangePicker.Segment
{part}
class="p-1 text-muted-foreground"
>
{value}
</DateRangePicker.Segment>
{:else}
<DateRangePicker.Segment
{part}
class="rounded-5px px-1 py-1 hover:bg-muted focus:bg-muted focus:text-foreground focus-visible:!ring-0 focus-visible:!ring-offset-0 aria-[valuetext=Empty]:text-muted-foreground"
>
{value}
</DateRangePicker.Segment>
{/if}
</div>
{/each}
{/snippet}
</DateRangePicker.Input>
{#if type === "start"}
<div aria-hidden="true" class="px-1 text-muted-foreground">–</div>
{/if}
{/each}
<DateRangePicker.Trigger
class="ml-auto inline-flex size-8 items-center justify-center rounded-[5px] text-foreground/60 transition-all hover:bg-muted active:bg-dark-10"
>
<CalendarBlank class="size-6" />
</DateRangePicker.Trigger>
</div>
<DateRangePicker.Content sideOffset={6} class="z-50">
<DateRangePicker.Calendar
class="mt-6 rounded-15px border border-dark-10 bg-background-alt p-[22px] shadow-popover"
>
{#snippet children({ months, weekdays })}
<DateRangePicker.Header class="flex items-center justify-between">
<DateRangePicker.PrevButton
class="inline-flex size-10 items-center justify-center rounded-9px bg-background-alt transition-all hover:bg-muted active:scale-98"
>
<CaretLeft class="size-6" />
</DateRangePicker.PrevButton>
<DateRangePicker.Heading class="text-[15px] font-medium" />
<DateRangePicker.NextButton
class="inline-flex size-10 items-center justify-center rounded-9px bg-background-alt transition-all hover:bg-muted active:scale-98"
>
<CaretRight class="size-6" />
</DateRangePicker.NextButton>
</DateRangePicker.Header>
<div
class="flex flex-col space-y-4 pt-4 sm:flex-row sm:space-x-4 sm:space-y-0"
>
{#each months as month}
<DateRangePicker.Grid
class="w-full border-collapse select-none space-y-1"
>
<DateRangePicker.GridHead>
<DateRangePicker.GridRow
class="mb-1 flex w-full justify-between"
>
{#each weekdays as day}
<DateRangePicker.HeadCell
class="w-10 rounded-md text-xs !font-normal text-muted-foreground"
>
<div>{day.slice(0, 2)}</div>
</DateRangePicker.HeadCell>
{/each}
</DateRangePicker.GridRow>
</DateRangePicker.GridHead>
<DateRangePicker.GridBody>
{#each month.weeks as weekDates}
<DateRangePicker.GridRow class="flex w-full">
{#each weekDates as date}
<DateRangePicker.Cell
{date}
month={month.value}
class="relative m-0 size-10 overflow-visible !p-0 text-center text-sm focus-within:relative focus-within:z-20"
>
<DateRangePicker.Day
class={cn(
"group relative inline-flex size-10 items-center justify-center overflow-visible whitespace-nowrap rounded-9px border border-transparent bg-background bg-transparent p-0 text-sm font-normal text-foreground transition-all hover:border-foreground focus-visible:!ring-foreground data-[disabled]:pointer-events-none data-[outside-month]:pointer-events-none data-[highlighted]:rounded-none data-[selection-end]:rounded-9px data-[selection-start]:rounded-9px data-[highlighted]:bg-muted data-[selected]:bg-muted data-[selection-end]:bg-foreground data-[selection-start]:bg-foreground data-[selected]:font-medium data-[selection-end]:font-medium data-[selection-start]:font-medium data-[disabled]:text-foreground/30 data-[selected]:text-foreground data-[selection-end]:text-background data-[selection-start]:text-background data-[unavailable]:text-muted-foreground data-[unavailable]:line-through data-[selection-start]:focus-visible:ring-2 data-[selection-start]:focus-visible:!ring-offset-2 data-[selected]:[&:not([data-selection-start])]:[&:not([data-selection-end])]:rounded-none data-[selected]:[&:not([data-selection-start])]:[&:not([data-selection-end])]:focus-visible:border-foreground data-[selected]:[&:not([data-selection-start])]:[&:not([data-selection-end])]:focus-visible:!ring-0 data-[selected]:[&:not([data-selection-start])]:[&:not([data-selection-end])]:focus-visible:!ring-offset-0"
)}
>
<div
class="absolute top-[5px] hidden size-1 rounded-full bg-foreground transition-all group-data-[today]:block group-data-[selected]:bg-background"
></div>
{date.day}
</DateRangePicker.Day>
</DateRangePicker.Cell>
{/each}
</DateRangePicker.GridRow>
{/each}
</DateRangePicker.GridBody>
</DateRangePicker.Grid>
{/each}
</div>
{/snippet}
</DateRangePicker.Calendar>
</DateRangePicker.Content>
</DateRangePicker.Root>
import typography from "@tailwindcss/typography";
import animate from "tailwindcss-animate";
import { fontFamily } from "tailwindcss/defaultTheme";
/** @type {import('tailwindcss').Config} */
export default {
darkMode: "class",
content: ["./src/**/*.{html,js,svelte,ts}"],
theme: {
container: {
center: true,
screens: {
"2xl": "1440px",
},
},
extend: {
colors: {
border: {
DEFAULT: "hsl(var(--border-card))",
input: "hsl(var(--border-input))",
"input-hover": "hsl(var(--border-input-hover))",
},
background: {
DEFAULT: "hsl(var(--background) / <alpha-value>)",
alt: "hsl(var(--background-alt) / <alpha-value>)",
},
foreground: {
DEFAULT: "hsl(var(--foreground) / <alpha-value>)",
alt: "hsl(var(--foreground-alt) / <alpha-value>)",
},
muted: {
DEFAULT: "hsl(var(--muted) / <alpha-value>)",
foreground: "hsl(var(--muted-foreground))",
},
dark: {
DEFAULT: "hsl(var(--dark) / <alpha-value>)",
4: "hsl(var(--dark-04))",
10: "hsl(var(--dark-10))",
40: "hsl(var(--dark-40))",
},
accent: {
DEFAULT: "hsl(var(--accent) / <alpha-value>)",
foreground: "hsl(var(--accent-foreground) / <alpha-value>)",
},
destructive: {
DEFAULT: "hsl(var(--destructive) / <alpha-value>)",
},
contrast: {
DEFAULT: "hsl(var(--contrast) / <alpha-value>)",
},
},
fontFamily: {
sans: ["Inter", ...fontFamily.sans],
mono: ["Source Code Pro", ...fontFamily.mono],
alt: ["Courier", ...fontFamily.sans],
},
fontSize: {
xxs: "10px",
},
borderWidth: {
6: "6px",
},
borderRadius: {
card: "16px",
"card-lg": "20px",
"card-sm": "10px",
input: "9px",
button: "5px",
"5px": "5px",
"9px": "9px",
"10px": "10px",
"15px": "15px",
},
height: {
input: "3rem",
"input-sm": "2.5rem",
},
boxShadow: {
mini: "var(--shadow-mini)",
"mini-inset": "var(--shadow-mini-inset)",
popover: "var(--shadow-popover)",
kbd: "var(--shadow-kbd)",
btn: "var(--shadow-btn)",
card: "var(--shadow-card)",
"date-field-focus": "var(--shadow-date-field-focus)",
},
opacity: {
8: "0.08",
},
scale: {
80: ".80",
98: ".98",
99: ".99",
},
},
keyframes: {
"accordion-down": {
from: { height: "0" },
to: { height: "var(--bits-accordion-content-height)" },
},
"accordion-up": {
from: { height: "var(--bits-accordion-content-height)" },
to: { height: "0" },
},
"caret-blink": {
"0%,70%,100%": { opacity: "1" },
"20%,50%": { opacity: "0" },
},
},
animation: {
"accordion-down": "accordion-down 0.2s ease-out",
"accordion-up": "accordion-up 0.2s ease-out",
"caret-blink": "caret-blink 1.25s ease-out infinite",
},
},
plugins: [typography, animate],
};
@import url("https://fonts.googleapis.com/css2?family=Source+Code+Pro:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600;1,700&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap");
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
:root {
/* Colors */
--background: 0 0% 100%;
--background-alt: 0 0% 100%;
--foreground: 0 0% 9%;
--foreground-alt: 0 0% 32%;
--muted: 240 5% 96%;
--muted-foreground: 0 0% 9% / 0.4;
--border: 240 6% 10%;
--border-input: 240 6% 10% / 0.17;
--border-input-hover: 240 6% 10% / 0.4;
--border-card: 240 6% 10% / 0.1;
--dark: 240 6% 10%;
--dark-10: 240 6% 10% / 0.1;
--dark-40: 240 6% 10% / 0.4;
--dark-04: 240 6% 10% / 0.04;
--accent: 204 94% 94%;
--accent-foreground: 204 80% 16%;
--destructive: 347 77% 50%;
/* black */
--constrast: 0 0% 0%;
/* Shadows */
--shadow-mini: 0px 1px 0px 1px rgba(0, 0, 0, 0.04);
--shadow-mini-inset: 0px 1px 0px 0px rgba(0, 0, 0, 0.04) inset;
--shadow-popover: 0px 7px 12px 3px hsla(var(--dark-10));
--shadow-kbd: 0px 2px 0px 0px rgba(0, 0, 0, 0.07);
--shadow-btn: 0px 1px 0px 1px rgba(0, 0, 0, 0.03);
--shadow-card: 0px 2px 0px 1px rgba(0, 0, 0, 0.04);
--shadow-date-field-focus: 0px 0px 0px 3px rgba(24, 24, 27, 0.17);
}
.dark {
/* Colors */
--background: 0 0% 5%;
--background-alt: 0 0% 8%;
--foreground: 0 0% 95%;
--foreground-alt: 0 0% 70%;
--muted: 240 4% 16%;
--muted-foreground: 0 0% 100% / 0.4;
--border: 0 0% 96%;
--border-input: 0 0% 96% / 0.17;
--border-input-hover: 0 0% 96% / 0.4;
--border-card: 0 0% 96% / 0.1;
--dark: 0 0% 96%;
--dark-40: 0 0% 96% / 0.4;
--dark-10: 0 0% 96% / 0.1;
--dark-04: 0 0% 96% / 0.04;
--accent: 204 90 90%;
--accent-foreground: 204 94% 94%;
--destructive: 350 89% 60%;
/* white */
--constrast: 0 0% 100%;
/* Shadows */
--shadow-mini: 0px 1px 0px 1px rgba(0, 0, 0, 0.3);
--shadow-mini-inset: 0px 1px 0px 0px rgba(0, 0, 0, 0.5) inset;
--shadow-popover: 0px 7px 12px 3px hsla(0deg 0% 0% / 30%);
--shadow-kbd: 0px 2px 0px 0px rgba(255, 255, 255, 0.07);
--shadow-btn: 0px 1px 0px 1px rgba(0, 0, 0, 0.2);
--shadow-card: 0px 2px 0px 1px rgba(0, 0, 0, 0.4);
--shadow-date-field-focus: 0px 0px 0px 3px rgba(244, 244, 245, 0.1);
}
}
@layer base {
* {
@apply border-border;
}
html {
-webkit-text-size-adjust: 100%;
font-variation-settings: normal;
}
body {
@apply bg-background text-foreground;
font-feature-settings:
"rlig" 1,
"calt" 1;
}
/* Mobile tap highlight */
/* https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-tap-highlight-color */
html {
-webkit-tap-highlight-color: rgba(128, 128, 128, 0.5);
}
::selection {
background: #fdffa4;
color: black;
}
/* === Scrollbars === */
::-webkit-scrollbar {
@apply w-2;
@apply h-2;
}
::-webkit-scrollbar-track {
@apply !bg-transparent;
}
::-webkit-scrollbar-thumb {
@apply rounded-card-lg !bg-dark-10;
}
::-webkit-scrollbar-corner {
background: rgba(0, 0, 0, 0);
}
/* Firefox */
/* https://developer.mozilla.org/en-US/docs/Web/CSS/scrollbar-color#browser_compatibility */
html {
scrollbar-color: var(--bg-muted);
}
.antialised {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
}
@layer utilities {
.step {
counter-increment: step;
}
.step:before {
@apply absolute inline-flex h-9 w-9 items-center justify-center rounded-full border-4 border-background bg-muted text-center -indent-px font-mono text-base font-medium;
@apply ml-[-50px] mt-[-4px];
content: counter(step);
}
}
@layer components {
*:not(body):not(.focus-override) {
outline: none !important;
&:focus-visible {
@apply focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground focus-visible:ring-offset-2 focus-visible:ring-offset-background;
}
}
.link {
@apply inline-flex items-center gap-1 rounded-sm font-medium underline underline-offset-4 hover:text-foreground/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground focus-visible:ring-offset-2 focus-visible:ring-offset-background;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
/* Firefox */
input[type="number"] {
-moz-appearance: textfield;
}
}
Structure
<script lang="ts">
import { DateRangePicker } from "bits-ui";
</script>
<DateRangePicker.Root>
<DateRangePicker.Label />
{#each ["start", "end"] as const as type}
<DateRangePicker.Input {type}>
{#snippet children({ segments })}
{#each segments as { part, value }}
<DateRangePicker.Segment {part}>
{value}
</DateRangePicker.Segment>
{/each}
{/snippet}
</DateRangePicker.Input>
{/each}
<DateRangePicker.Trigger />
<DateRangePicker.Content>
<DateRangePicker.Calendar>
{#snippet children({ months, weekdays })}
<DateRangePicker.Header>
<DateRangePicker.PrevButton />
<DateRangePicker.Heading />
<DateRangePicker.NextButton />
</DateRangePicker.Header>
{#each months as month}
<DateRangePicker.Grid>
<DateRangePicker.GridHead>
<DateRangePicker.GridRow>
{#each weekdays as day}
<DateRangePicker.HeadCell>
{day}
</DateRangePicker.HeadCell>
{/each}
</DateRangePicker.GridRow>
</DateRangePicker.GridHead>
<DateRangePicker.GridBody>
{#each month.weeks as weekDates}
<DateRangePicker.GridRow>
{#each weekDates as date}
<DateRangePicker.Cell {date} month={month.value}>
<DateRangePicker.Day>
{date.day}
</DateRangePicker.Day>
</DateRangePicker.Cell>
{/each}
</DateRangePicker.GridRow>
{/each}
</DateRangePicker.GridBody>
</DateRangePicker.Grid>
{/each}
{/snippet}
</DateRangePicker.Calendar>
</DateRangePicker.Content>
</DateRangePicker.Root>
Placeholder State
Bits UI provides flexible options for controlling and synchronizing the DateRangePicker
component's placeholder
state.
Two-Way Binding
Use the bind:placeholder
directive for effortless two-way synchronization between your local state and the DateRangePicker
component's placeholder.
<script lang="ts">
import { DateRangePicker } from "bits-ui";
let placeholder = $state(new CalendarDateTime(2024, 8, 3, 12, 30));
</script>
<DateRangePicker.Root bind:placeholder>
<!-- ... -->
</DateField.Root>
This setup enables toggling the DateRangePicker
component's placeholder via the custom button and ensures the local placeholder
state is synchronized with the DateRangePicker
component's placeholder should it change from within the component.
Change Handler
You can also use the onPlaceholderChange
prop to update local state when the component's placeholder
changes. This is useful when you don't want two-way binding for one reason or another, or you want to perform additional logic when the DateRangePicker
component's placeholder changes.
<script lang="ts">
import { DateRangePicker } from "bits-ui";
let placeholder = $state(new CalendarDateTime(2024, 8, 3, 12, 30));
</script>
<DateRangePicker.Root
bind:placeholder
onPlaceholderChange={(p) => {
placeholder = placeholder.set({ year: 2025 });
}}
>
<!-- ... -->
</DateRangePicker.Root>
Controlled
Sometimes, you may want complete control over the placeholder
state, meaning you will be "kept in the loop" and be required to apply the state change yourself. While you will rarely need this, it's possible to do so by setting the controlledPlaceholder
prop to true
.
You will then be responsible for updating a local placeholder state variable that is passed as the placeholder
prop to the DateRangePicker.Root
component.
<script lang="ts">
import { DateRangePicker } from "bits-ui";
let myPlaceholder = $state();
</script>
<DateRangePicker.Root
controlledPlaceholder
placeholder={myPlaceholder}
onPlaceholderChange={(p) => (myPlaceholder = p)}
>
<!-- ... -->
</DateRangePicker.Root>
See the Controlled State documentation for more information about controlled states.
Value State
The value
represents the currently selected date within the DateRangePicker
component.
Bits UI provides flexible options for controlling and synchronizing the DateRangePicker
component's value state.
Two-Way Binding
Use the bind:value
directive for effortless two-way synchronization between your local state and the DateRangePicker
component's value.
<script lang="ts">
import { DateRangePicker } from "bits-ui";
let value = $state({
start: new CalendarDateTime(2024, 8, 3, 12, 30),
end: new CalendarDateTime(2024, 8, 4, 12, 30),
});
</script>
<button
onclick={() => {
value = {
start: value.start.add({ days: 1 }),
end: value.end.add({ days: 1 }),
};
}}
>
Add 1 day
</button>
<DateRangePicker.Root bind:value>
<!-- ... -->
</DateRangePicker.Root>
This setup enables toggling the component's value via the custom button and ensures the local value
state is synchronized with the component's value, should it change from within the component.
Change Handler
You can also use the onValueChange
prop to update local state when the component's value changes. This is useful when you don't want two-way binding for one reason or another, or you want to perform additional logic when the component's value changes.
<script lang="ts">
import { DateRangePicker } from "bits-ui";
let value = $state({
start: new CalendarDateTime(2024, 8, 3, 12, 30),
end: new CalendarDateTime(2024, 8, 4, 12, 30),
});
</script>
<DateRangePicker.Root
bind:value
onValueChange={(v) => {
value = {
start: v.start.set({ hour: v.start.hour + 1 }),
end: v.end.set({ hour: v.end.hour + 1 }),
};
}}
>
<!-- ... -->
</DateRangePicker.Root>
Controlled
Sometimes, you may want complete control over the component's value
state, meaning you will be "kept in the loop" and be required to apply the state change yourself. While you will rarely need this, it's possible to do so by setting the controlledValue
prop to true
.
You will then be responsible for updating a local value state variable that is passed as the value
prop to the DateRangePicker.Root
component.
<script lang="ts">
import { DateRangePicker } from "bits-ui";
let myValue = $state();
</script>
<DateRangePicker.Root controlledValue value={myValue} onValueChange={(v) => (myValue = v)}>
<!-- ... -->
</DateRangePicker.Root>
See the Controlled State documentation for more information about controlled states.
Open State
The open
prop is used to determine whether the DateRangePicker
is open or closed. Bits UI provides flexible options for controlling and synchronizing the open state.
Two-Way Binding
Use the bind:open
directive for effortless two-way synchronization between your local state and the DateRangePicker
's internal state.
<script lang="ts">
import { DateRangePicker } from "bits-ui";
let myOpen = $state(false);
</script>
<button onclick={() => (myOpen = true)}> Open </button>
<DateRangePicker.Root bind:open={myOpen}>
<!-- ... -->
</DateRangePicker.Root>
This setup enables toggling the DateRangePicker
via the custom button and ensures the local myOpen
state updates when the state changes through any internal means (e.g., clicking on the trigger).
Change Handler
You can also use the onOpenChange
prop to update local state when the DateRangePicker
's open
state changes. This is useful when you don't want two-way binding for one reason or another, or you want to perform additional logic when the state changes.
<script lang="ts">
import { DateRangePicker } from "bits-ui";
let myOpen = $state(false);
</script>
<DateRangePicker.Root
open={myOpen}
onOpenChange={(open) => {
myOpen = open;
// additional logic here.
}}
>
<!-- ... -->
</DateRangePicker.Root>
Controlled
Sometimes, you may want complete control over the component's open
state, meaning you will be "kept in the loop" and be required to apply the state change yourself. While you'll rarely need this, it's possible to do so by setting the controlledOpen
prop to true
.
You will then be responsible for updating a local state variable that is passed as the open
prop to the DateRangePicker.Root
component.
<script lang="ts">
import { DateRangePicker } from "bits-ui";
let myOpen = $state(false);
</script>
<DateRangePicker.Root controlledOpen open={myOpen} onOpenChange={(o) => (myOpen = o)}>
<!-- ... -->
</DateRangePicker.Root>
See the Controlled State documentation for more information about controlled states.
API Reference
The root date picker component.
Property | Type | Description |
---|---|---|
value $bindable | DateRange | The selected date range. Default: undefined |
onValueChange | function | A function that is called when the selected date changes. Default: undefined |
controlledValue | boolean | Whether or not the value is controlled or not. If Default: false |
placeholder $bindable | DateValue | The placeholder date, which is used to determine what date to start the segments from when no value exists. Default: undefined |
onPlaceholderChange | function | A function that is called when the placeholder date changes. Default: undefined |
controlledPlaceholder | boolean | Whether or not the placeholder is controlled or not. If Default: false |
readonlySegments | EditableSegmentPart[] | An array of segments that should be readonly, which prevent user input on them. Default: undefined |
isDateUnavailable | function | A function that returns whether or not a date is unavailable. Default: undefined |
minValue | DateValue | The minimum valid date that can be entered. Default: undefined |
maxValue | DateValue | The maximum valid date that can be entered. Default: undefined |
granularity | enum | The granularity to use for formatting the field. Defaults to Default: undefined |
hideTimeZone | boolean | Whether or not to hide the time zone segment of the field. Default: false |
hourCycle | enum | The hour cycle to use for formatting times. Defaults to the locale preference Default: undefined |
locale | string | The locale to use for formatting dates. Default: 'en-US' |
disabled | boolean | Whether or not the accordion is disabled. Default: false |
readonly | boolean | Whether or not the field is readonly. Default: false |
required | boolean | Whether or not the date field is required. Default: false |
closeOnRangeSelect | boolean | Whether or not to close the popover when a date range is selected. Default: true |
disableDaysOutsideMonth | boolean | Whether or not to disable days outside the current month. Default: false |
pagedNavigation | boolean | Whether or not to use paged navigation for the calendar. Paged navigation causes the previous and next buttons to navigate by the number of months displayed at once, rather than by one month. Default: false |
preventDeselect | boolean | Whether or not to prevent the user from deselecting a date without selecting another date first. Default: false |
weekdayFormat | enum | The format to use for the weekday strings provided via the Default: 'narrow' |
weekStartsOn | number | The day of the week to start the calendar on. 0 is Sunday, 1 is Monday, etc. Default: 0 |
calendarLabel | string | The accessible label for the calendar. Default: undefined |
fixedWeeks | boolean | Whether or not to always display 6 weeks in the calendar. Default: false |
isDateDisabled | function | A function that returns whether or not a date is disabled. Default: undefined |
numberOfMonths | number | The number of months to display at once. Default: 1 |
open $bindable | boolean | The open state of the popover content. Default: false |
onOpenChange | function | A callback that fires when the open state changes. Default: undefined |
controlledOpen | boolean | Whether or not the open state is controlled or not. If Default: false |
onEndValueChange | function | A function that is called when the end date changes. Default: undefined |
onStartValueChange | function | A function that is called when the start date changes. Default: undefined |
ref $bindable | HTMLDivElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
child | Snippet | Use render delegation to render your own element. See delegation docs for more information. Default: undefined |
Data Attribute | Value | Description |
---|---|---|
data-invalid | '' | Present on the root element when the calendar is invalid. |
data-disabled | '' | Present on the root element when the calendar is disabled. |
data-readonly | '' | Present on the root element when the calendar is readonly. |
data-calendar-root | '' | Present on the root element. |
The label for the date field.
Property | Type | Description |
---|---|---|
ref $bindable | HTMLSpanElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
child | Snippet | Use render delegation to render your own element. See delegation docs for more information. Default: undefined |
Data Attribute | Value | Description |
---|---|---|
data-invalid | '' | Present on the element when the field is invalid |
data-date-field-label | '' | Present on the element. |
The field input component which contains the segments of the date field.
Property | Type | Description |
---|---|---|
name | string | The name of the input field used for form submission. If provided a hidden input will be rendered alongside the field. Default: undefined |
type required | enum | The type of field to render (start or end). Default: undefined |
ref $bindable | HTMLDivElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
child | Snippet | Use render delegation to render your own element. See delegation docs for more information. Default: undefined |
Data Attribute | Value | Description |
---|---|---|
data-invalid | '' | Present on the element when the field is invalid. |
data-disabled | '' | Present on the element when the field is disabled. |
data-date-field-input | '' | Present on the element. |
A segment of the date field.
Property | Type | Description |
---|---|---|
part required | SegmentPart | The part of the date to render. Default: undefined |
ref $bindable | HTMLSpanElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
child | Snippet | Use render delegation to render your own element. See delegation docs for more information. Default: undefined |
Data Attribute | Value | Description |
---|---|---|
data-invalid | '' | Present on the element when the field is invalid |
data-disabled | '' | Present on the element when the field is disabled |
data-segment | enum | The type of segment the element represents. |
data-date-field-segment | '' | Present on the element. |
A component which toggles the opening and closing of the popover on press.
Property | Type | Description |
---|---|---|
ref $bindable | HTMLButtonElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
child | Snippet | Use render delegation to render your own element. See delegation docs for more information. Default: undefined |
Data Attribute | Value | Description |
---|---|---|
data-state | enum | Whether the popover is open or closed. |
data-popover-trigger | '' | Present on the trigger element. |
The contents of the popover which are displayed when the popover is open.
Property | Type | Description |
---|---|---|
side | enum | The preferred side of the anchor to render the floating element against when open. Will be reversed when collisions occur. Default: bottom |
sideOffset | number | The distance in pixels from the anchor to the floating element. Default: 0 |
align | enum | The preferred alignment of the anchor to render the floating element against when open. This may change when collisions occur. Default: start |
alignOffset | number | The distance in pixels from the anchor to the floating element. Default: 0 |
arrowPadding | number | The amount in pixels of virtual padding around the viewport edges to check for overflow which will cause a collision. Default: 0 |
avoidCollisions | boolean | When Default: true |
collisionBoundary | union | A boundary element or array of elements to check for collisions against. Default: undefined |
collisionPadding | union | The amount in pixels of virtual padding around the viewport edges to check for overflow which will cause a collision. Default: 0 |
sticky | enum | The sticky behavior on the align axis. Default: partial |
hideWhenDetached | boolean | When Default: true |
updatePositionStrategy | enum | The strategy to use when updating the position of the content. When Default: optimized |
strategy | enum | The positioning strategy to use for the floating element. When Default: fixed |
preventScroll | boolean | When Default: false |
customAnchor | union | Use an element other than the trigger to anchor the content to. If provided, the content will be anchored to the provided element instead of the trigger. Default: null |
onInteractOutside | function | Callback fired when an outside interaction event completes, which is either a Default: undefined |
onInteractOutsideStart | function | Callback fired when an outside interaction event starts, which is either a Default: undefined |
onFocusOutside | function | Callback fired when focus leaves the dismissable layer. You can call Default: undefined |
interactOutsideBehavior | enum | The behavior to use when an interaction occurs outside of the floating content. Default: close |
onEscapeKeydown | function | Callback fired when an escape keydown event occurs in the floating content. You can call Default: undefined |
escapeKeydownBehavior | enum | The behavior to use when an escape keydown event occurs in the floating content. Default: close |
onOpenAutoFocus | function | Event handler called when auto-focusing the content as it is opened. Can be prevented. Default: undefined |
onCloseAutoFocus | function | Event handler called when auto-focusing the content as it is closed. Can be prevented. Default: undefined |
trapFocus | boolean | Whether or not to trap the focus within the content when open. Default: true |
preventOverflowTextSelection | boolean | When Default: true |
forceMount | boolean | Whether or not to forcefully mount the content. This is useful if you want to use Svelte transitions or another animation library for the content. Default: false |
dir | enum | The reading direction of the app. Default: ltr |
ref $bindable | HTMLDivElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
child | Snippet | Use render delegation to render your own element. See delegation docs for more information. Default: undefined |
Data Attribute | Value | Description |
---|---|---|
data-state | enum | Whether the popover is open or closed. |
data-popover-content | '' | Present on the content element. |
The calendar component containing the grids of dates.
Data Attribute | Value | Description |
---|---|---|
data-invalid | '' | Present on the root element when the calendar is invalid. |
data-disabled | '' | Present on the root element when the calendar is disabled. |
data-readonly | '' | Present on the root element when the calendar is readonly. |
data-calendar-root | '' | Present on the root element. |
The header of the calendar.
Property | Type | Description |
---|---|---|
ref $bindable | HTMLElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
child | Snippet | Use render delegation to render your own element. See delegation docs for more information. Default: undefined |
Data Attribute | Value | Description |
---|---|---|
data-disabled | '' | Present on the header element when the calendar is disabled. |
data-readonly | '' | Present on the header element when the calendar is readonly. |
data-calendar-header | '' | Present on the header element. |
The previous button of the calendar.
Property | Type | Description |
---|---|---|
ref $bindable | HTMLButtonElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
child | Snippet | Use render delegation to render your own element. See delegation docs for more information. Default: undefined |
Data Attribute | Value | Description |
---|---|---|
data-disabled | '' | Present on the prev button element when the calendar or this button is disabled. |
data-calendar-prev-button | '' | Present on the prev button element. |
The heading of the calendar.
Property | Type | Description |
---|---|---|
ref $bindable | HTMLDivElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
child | Snippet | Use render delegation to render your own element. See delegation docs for more information. Default: undefined |
Data Attribute | Value | Description |
---|---|---|
data-disabled | '' | Present on the heading element when the calendar is disabled. |
data-readonly | '' | Present on the heading element when the calendar is readonly. |
data-calendar-heading | '' | Present on the heading element. |
The next button of the calendar.
Property | Type | Description |
---|---|---|
ref $bindable | HTMLButtonElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
child | Snippet | Use render delegation to render your own element. See delegation docs for more information. Default: undefined |
Data Attribute | Value | Description |
---|---|---|
data-disabled | '' | Present on the next button element when the calendar or this button is disabled. |
data-calendar-next-button | '' | Present on the next button element. |
The grid of dates in the calendar, typically representing a month.
Property | Type | Description |
---|---|---|
ref $bindable | HTMLTableElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
child | Snippet | Use render delegation to render your own element. See delegation docs for more information. Default: undefined |
Data Attribute | Value | Description |
---|---|---|
data-disabled | '' | Present on the grid element when the calendar is disabled. |
data-readonly | '' | Present on the grid element when the calendar is readonly. |
data-calendar-grid | '' | Present on the grid element. |
A row in the grid of dates in the calendar.
Property | Type | Description |
---|---|---|
ref $bindable | HTMLTableRowElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
child | Snippet | Use render delegation to render your own element. See delegation docs for more information. Default: undefined |
Data Attribute | Value | Description |
---|---|---|
data-disabled | '' | Present on the grid row element when the calendar is disabled. |
data-readonly | '' | Present on the grid row element when the calendar is readonly. |
data-calendar-grid-row | '' | Present on the grid row element. |
The head of the grid of dates in the calendar.
Property | Type | Description |
---|---|---|
ref $bindable | HTMLTableSectionElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
child | Snippet | Use render delegation to render your own element. See delegation docs for more information. Default: undefined |
Data Attribute | Value | Description |
---|---|---|
data-disabled | '' | Present on the grid head element when the calendar is disabled. |
data-readonly | '' | Present on the grid head element when the calendar is readonly. |
data-calendar-grid-head | '' | Present on the grid head element. |
A cell in the head of the grid of dates in the calendar.
Property | Type | Description |
---|---|---|
ref $bindable | HTMLTableCellElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
child | Snippet | Use render delegation to render your own element. See delegation docs for more information. Default: undefined |
Data Attribute | Value | Description |
---|---|---|
data-disabled | '' | Present on the head cell element when the calendar is disabled. |
data-readonly | '' | Present on the head cell element when the calendar is readonly. |
data-calendar-head-cell | '' | Present on the head cell element. |
The body of the grid of dates in the calendar.
Property | Type | Description |
---|---|---|
ref $bindable | HTMLTableSectionElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
child | Snippet | Use render delegation to render your own element. See delegation docs for more information. Default: undefined |
Data Attribute | Value | Description |
---|---|---|
data-disabled | '' | Present on the grid element when the calendar is disabled. |
data-readonly | '' | Present on the grid element when the calendar is readonly. |
data-calendar-grid-body | '' | Present on the grid body element. |
A cell in the calendar grid.
Property | Type | Description |
---|---|---|
date | DateValue | The date for the cell. Default: undefined |
month | DateValue | The current month the date is being displayed in. Default: undefined |
ref $bindable | HTMLTableCellElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
child | Snippet | Use render delegation to render your own element. See delegation docs for more information. Default: undefined |
Data Attribute | Value | Description |
---|---|---|
data-disabled | '' | Present when the day is disabled. |
data-unavailable | '' | Present when the day is unavailable. |
data-today | '' | Present when the day is today. |
data-outside-month | '' | Present when the day is outside the current month. |
data-outside-visible-months | '' | Present when the day is outside the visible months. |
data-focused | '' | Present when the day is focused. |
data-selected | '' | Present when the day is selected. |
data-value | '' | The date in the format "YYYY-MM-DD". |
data-calendar-cell | '' | Present on the cell element. |
A day in the calendar grid.
Property | Type | Description |
---|---|---|
ref $bindable | HTMLDivElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
child | Snippet | Use render delegation to render your own element. See delegation docs for more information. Default: undefined |
Data Attribute | Value | Description |
---|---|---|
data-disabled | '' | Present when the day is disabled. |
data-unavailable | '' | Present when the day is unavailable. |
data-today | '' | Present when the day is today. |
data-outside-month | '' | Present when the day is outside the current month. |
data-outside-visible-months | '' | Present when the day is outside the visible months. |
data-focused | '' | Present when the day is focused. |
data-selected | '' | Present when the day is selected. |
data-value | '' | The date in the format "YYYY-MM-DD". |
data-calendar-day | '' | Present on the day element. |