Skip to content
Nana UI

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.

View .md Download
Statement period

No period chosen.

Install the package for a versioned dependency:

npm install @nana-tec/ui-components

Or copy the source in and own it:

npx @nana-tec/ui add date-range --framework web-components
npx @nana-tec/ui add date-range --framework svelte

Lands in src/lib/components/ui/date-range/ as NanaDateRange.svelte, styled with Tailwind classes that resolve to the design tokens. Requires Tailwind v4.

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.

<nana-date-range></nana-date-range>

Show a single calendar with months="1".

Constrain selectable dates with min / max, and offer quick ranges with presets.

Properties

PropertyAttributeTypeDefaultDescription
clearableclearablebooleanfalseOffer a control to clear the range.
disableddisabledbooleanfalseBlocks interaction and leaves the value out of form submission.
endendstring''Range end, yyyy-mm-dd.
errorMessageerror-messagestring''Replaces the helper text and marks the field invalid.
errorTexterror-textstring—Deprecated: use error-message with invalid. Setting it also sets invalid.
firstDayOfWeekfirst-day-of-weeknumber1Which weekday starts the week; 0 = Sunday.
helperTexthelper-textstring''Assistive text below the trigger.
invalidinvalidbooleanfalseMarks the field invalid and shows error-message in place of the helper text.
labellabelstring''Field label rendered above the trigger.
localelocale——BCP 47 tag for month/weekday names and the trigger's date formatting.
maxmaxstring''Latest selectable day, yyyy-mm-dd.
minminstring''Earliest selectable day, yyyy-mm-dd.
monthsmonthsnumber2Number of month grids shown side by side.
namenamestring''Name the value is submitted under in a form.
openopenbooleanfalseWhether the panel is open.
placementplacementPopupPlacement'bottom-start'Where the panel sits relative to the trigger.
presetspresetsbooleanfalseShow the shortcut list (Today, Last 7 days, This month, …).
requiredrequiredbooleanfalseThe form will not submit while this has no value.
sizesizeDateRangeSize'md'Size preset.
startstartstring''Range start, yyyy-mm-dd.
valuevaluestring—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

MethodDescription
clear(): voidClear the range.

Events

EventDescription
nana-changeThe range changed; detail: { value }. Fires only on a complete range.
nana-range-changeThe range changed; detail: { value, start, end }
nana-focusThe trigger gained focus
nana-blurThe trigger lost focus

Slots

SlotDescription
triggerReplaces the built-in trigger button entirely.
empty-labelShown on the trigger when no range is selected.

CSS parts

PartDescription
::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

PropertyDescription
--nana-date-range-bgPanel background
--nana-date-range-radiusPanel corner radius
--nana-date-range-accentSelection colour
--nana-date-range-in-range-bgFill between the two endpoints

NanaDateRange

PropTypeDefault
startbind:string''
endbind:string''
openbind:booleanfalse
labelstring
placeholderstring'Select dates'
minstring
maxstring
localestring'en'
firstDayOfWeeknumber0
monthsnumber2
presetsbooleantrue
namestring
disabledbooleanfalse
isDateUnavailable(iso: string) => boolean
onRangeChange(range: CalendarRange) => void

Also accepts Omit<HTMLAttributes<HTMLDivElement>, 'class'>.