Forms & Inputs
Date Range
A date-range picker: a trigger showing the current range, and a popover with one or two month grids plus optional shortcut presets. The form value is the two ISO dates joined by a slash (2026-01-01/2026-01-31), which is what start/end serialise to. An incomplete range submits nothing.
Preview
Section titled “Preview”<nana-date-range></nana-date-range> No period chosen.
<script lang="ts">
import { NanaDateRange } from '$lib/components/ui/date-range';
let start = $state('');
let end = $state('');
</script>
<div class="flex flex-col items-start gap-3">
<NanaDateRange label="Statement period" bind:start bind:end />
<p class="text-sm text-foreground-muted">
{start && end ? `${start} to ${end}` : 'No period chosen.'}
</p>
</div> Installation
Section titled “Installation”Install the package for a versioned dependency:
npm install @nana-tec/ui-componentsOr copy the source in and own it:
npx @nana-tec/ui add date-range --framework web-componentsnpx @nana-tec/ui add date-range --framework svelteLands in src/lib/components/ui/date-range/ as NanaDateRange.svelte, styled with Tailwind
classes that resolve to the design tokens. Requires Tailwind v4.
Import
Section titled “Import”
Import the autoloader once, in your app's entry point. Every <nana-*> tag then works anywhere, and
each component downloads only the first time a page uses it:
import "@nana-tec/ui-components/autoloader";import "@nana-tec/ui-components/theme";The second line gives every component the Nana look and the design tokens behind it. Leave it out to style the components entirely yourself.
Import a component directly when it must be ready at once: on screen at first paint, or when you call its methods straight away. The two mix freely:
import "@nana-tec/ui-components/date-range";
Copied in with npx @nana-tec/ui add date-range? Import your project's own
@/lib/nana-ui/autoloader.js once instead; the CLI keeps it up to date.
<script lang="ts"> import { NanaDateRange } from '$lib/components/ui/date-range';
let start = $state(''); let end = $state('');</script>
<NanaDateRange label="Statement period" bind:start bind:end name="period" />A button that opens two months and a list of common ranges. With name, the form
receives period-start and period-end. Set presets={false} to hide the list.
Basic usage
Section titled “Basic usage”<nana-date-range></nana-date-range>One month
Section titled “One month”Show a single calendar with months="1".
<nana-date-range label="Single month" months="1" clearable></nana-date-range> Bounded with presets
Section titled “Bounded with presets”Constrain selectable dates with min / max, and offer quick ranges with
presets.
<nana-date-range
label="Open financial year"
min="2026-01-01"
max="2026-12-31"
start="2026-03-01"
end="2026-03-31"
presets
></nana-date-range> Sizes & states
Section titled “Sizes & states”<nana-date-range
label="Small"
size="sm"
start="2026-02-01"
end="2026-02-14"
></nana-date-range>
<nana-date-range
label="Large"
size="lg"
start="2026-02-01"
end="2026-02-14"
></nana-date-range>
<nana-date-range
label="Disabled"
disabled
start="2026-02-01"
end="2026-02-14"
></nana-date-range> Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
clearable | clearable | boolean | false | Offer a control to clear the range. |
disabled | disabled | boolean | false | Blocks interaction and leaves the value out of form submission. |
end | end | string | '' | Range end, yyyy-mm-dd. |
errorMessage | error-message | string | '' | Replaces the helper text and marks the field invalid. |
errorText | error-text | string | — | Deprecated: use error-message with invalid. Setting it also sets invalid. |
firstDayOfWeek | first-day-of-week | number | 1 | Which weekday starts the week; 0 = Sunday. |
helperText | helper-text | string | '' | Assistive text below the trigger. |
invalid | invalid | boolean | false | Marks the field invalid and shows error-message in place of the helper text. |
label | label | string | '' | Field label rendered above the trigger. |
locale | locale | — | — | BCP 47 tag for month/weekday names and the trigger's date formatting. |
max | max | string | '' | Latest selectable day, yyyy-mm-dd. |
min | min | string | '' | Earliest selectable day, yyyy-mm-dd. |
months | months | number | 2 | Number of month grids shown side by side. |
name | name | string | '' | Name the value is submitted under in a form. |
open | open | boolean | false | Whether the panel is open. |
placement | placement | PopupPlacement | 'bottom-start' | Where the panel sits relative to the trigger. |
presets | presets | boolean | false | Show the shortcut list (Today, Last 7 days, This month, …). |
required | required | boolean | false | The form will not submit while this has no value. |
size | size | DateRangeSize | 'md' | Size preset. |
start | start | string | '' | Range start, yyyy-mm-dd. |
value | value | string | — | The submitted form value: start/end. Setting it parses both ends back out. Empty while the range is incomplete, so a half-picked range submits nothing. |
Methods
| Method | Description |
|---|---|
clear(): void | Clear the range. |
Events
| Event | Description |
|---|---|
nana-change | The range changed; detail: { value }. Fires only on a complete range. |
nana-range-change | The range changed; detail: { value, start, end } |
nana-focus | The trigger gained focus |
nana-blur | The trigger lost focus |
Slots
| Slot | Description |
|---|---|
trigger | Replaces the built-in trigger button entirely. |
empty-label | Shown on the trigger when no range is selected. |
CSS parts
| Part | Description |
|---|---|
::part(base) | The root element |
::part(trigger) | The trigger button; carries invalid |
::part(panel) | The popover panel |
::part(presets) | The preset shortcut list |
::part(calendar) | A single month grid |
::part(day) | A day cell; carries outside, today, selected, range-start, range-end and in-range |
::part(day-num) | The day's number |
::part(label) | The label |
::part(req) | The required marker |
::part(trigger-label) | The trigger label |
::part(clear) | The clear |
::part(preset) | The preset |
::part(calendars) | The calendars |
::part(nav) | The nav |
::part(nav-btn) | The nav button |
::part(months) | The months |
::part(help) | The helper text |
::part(error) | The error message |
::part(lead) | The calendar icon on the field |
::part(clear-icon) | The icon in the clear control |
::part(nav-icon) | The arrow inside a month button |
CSS custom properties
| Property | Description |
|---|---|
--nana-date-range-bg | Panel background |
--nana-date-range-radius | Panel corner radius |
--nana-date-range-accent | Selection colour |
--nana-date-range-in-range-bg | Fill between the two endpoints |
NanaDateRange
| Prop | Type | Default |
|---|---|---|
startbind: | string | '' |
endbind: | string | '' |
openbind: | boolean | false |
label | string | |
placeholder | string | 'Select dates' |
min | string | |
max | string | |
locale | string | 'en' |
firstDayOfWeek | number | 0 |
months | number | 2 |
presets | boolean | true |
name | string | |
disabled | boolean | false |
isDateUnavailable | (iso: string) => boolean | |
onRangeChange | (range: CalendarRange) => void |
Also accepts Omit<HTMLAttributes<HTMLDivElement>, 'class'>.