date-range
A check-in and check-out date, as one value { start, end } ("YYYY-MM-DD" strings). A form control: invalid until both are set and end is after start.
Try it: events appear here (valuechange).
Source: date-range.zb, and its registry item.
Install
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/date-range.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/date-range.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/date-range.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/date-range.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/date-range.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/date-range.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/date-range.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/date-range.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/date-range.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/date-range.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/date-range.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/date-range.json
<link rel="stylesheet" href="https://zubra-js.github.io/zubra-ui/themes/default.css">
<script type="module" src="https://zubra-js.github.io/zubra-ui/cdn/date-range.js"></script>The compiled install writes src/components/zubra/date-range.js and the theme, and adds @zubra/runtime to your dependencies. The one-file install writes the same path as a plain custom element that needs nothing installed (or download it and load it with a <script type="module">); it's smaller on a page with one to three components, the shared runtime with more.
Usage
<date-range name="stay" min="2026-01-01"></date-range>
<script type="module">
import './components/zubra/date-range.js';
const element = document.querySelector('date-range');
element.value = { start: '2026-12-18', end: '2026-12-22' };
element.addEventListener('valuechange', (event) => console.log('valuechange', event.detail));
</script>import './components/zubra/date-range.js';
const value = { start: '2026-12-18', end: '2026-12-22' };
export function DateRangeExample() {
return (
<date-range
name="stay"
min="2026-01-01"
value={value}
onvaluechange={(event) => console.log('valuechange', event.detail)}
></date-range>
);
}<script setup>
import './components/zubra/date-range.js';
const value = { start: '2026-12-18', end: '2026-12-22' };
const onValuechange = (event) => console.log('valuechange', event.detail);
</script>
<template>
<date-range
name="stay"
min="2026-01-01"
:value.prop="value"
@valuechange="onValuechange"
></date-range>
</template>
<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) --><script>
import './components/zubra/date-range.js';
const value = { start: '2026-12-18', end: '2026-12-22' };
</script>
<date-range
name="stay"
min="2026-01-01"
{value}
onvaluechange={(event) => console.log('valuechange', event.detail)}
></date-range>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/date-range.js';
@Component({
selector: 'app-date-range-example',
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<date-range
name="stay"
min="2026-01-01"
[value]="value"
(valuechange)="onValuechange($event)"
></date-range>
`,
})
export class DateRangeExample {
value = { start: '2026-12-18', end: '2026-12-22' };
onValuechange(event: Event) {
console.log('valuechange', (event as CustomEvent).detail);
}
}API
| Property | Type | Default |
|---|---|---|
valueproperty only | { start, end } | {"start":"","end":""} |
min | string | "" |
disabled | boolean | false |
| Event | When |
|---|---|
valuechange | Either date changed; detail is the new { start, end }. |
Size
1.4 KB gzipped for the component, plus the runtime, which every Zubra component on a page shares (up to 22.1 KB, all of it). On its own, with the parts of the runtime it uses, it's 17.9 KB.