date-field
A labelled date on the native <input type="date">: the platform's own calendar on every device, typed entry in the visitor's own date format, min and max, form submission under name and the browser's validation. The value is "YYYY-MM-DD" (or "" when empty). value is two-way.
Try it: events appear here (valuechange).
Source: date-field.zb, and its registry item.
Install
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/date-field.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/date-field.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/date-field.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/date-field.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/date-field.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/date-field.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/date-field.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/date-field.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/date-field.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/date-field.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/date-field.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/date-field.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-field.js"></script>The compiled install writes src/components/zubra/date-field.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-field
label="Delivery date"
description="We deliver Monday to Friday."
name="delivery"
min="2026-01-01"
></date-field>
<script type="module">
import './components/zubra/date-field.js';
const element = document.querySelector('date-field');
element.value = '2026-12-04';
element.addEventListener('valuechange', (event) => console.log('valuechange', event.detail));
</script>import './components/zubra/date-field.js';
const value = '2026-12-04';
export function DateFieldExample() {
return (
<date-field
label="Delivery date"
description="We deliver Monday to Friday."
name="delivery"
min="2026-01-01"
value={value}
onvaluechange={(event) => console.log('valuechange', event.detail)}
></date-field>
);
}<script setup>
import './components/zubra/date-field.js';
const value = '2026-12-04';
const onValuechange = (event) => console.log('valuechange', event.detail);
</script>
<template>
<date-field
label="Delivery date"
description="We deliver Monday to Friday."
name="delivery"
min="2026-01-01"
:value.prop="value"
@valuechange="onValuechange"
></date-field>
</template>
<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) --><script>
import './components/zubra/date-field.js';
const value = '2026-12-04';
</script>
<date-field
label="Delivery date"
description="We deliver Monday to Friday."
name="delivery"
min="2026-01-01"
{value}
onvaluechange={(event) => console.log('valuechange', event.detail)}
></date-field>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/date-field.js';
@Component({
selector: 'app-date-field-example',
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<date-field
label="Delivery date"
description="We deliver Monday to Friday."
name="delivery"
min="2026-01-01"
[value]="value"
(valuechange)="onValuechange($event)"
></date-field>
`,
})
export class DateFieldExample {
value = '2026-12-04';
onValuechange(event: Event) {
console.log('valuechange', (event as CustomEvent).detail);
}
}API
| Property | Type | Default |
|---|---|---|
value | string | "" |
label | string | "Date" |
description | string | "" |
name | string | "" |
min | string | "" |
max | string | "" |
required | boolean | false |
disabled | boolean | false |
| Event | When |
|---|---|
valuechange | The date changed; detail is "YYYY-MM-DD", or "". |
Size
1.0 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.3 KB.