Zubra UI
Code for
GitHub

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

Compiled (any project)
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
One file, no dependencies (2.5 KB gzipped)
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
.zb source (to edit it with Zubra)
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
No build: a script tag, straight from this site
HTML
<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

index.html
<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>
Example.jsx
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>
  );
}
Example.vue
<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('-') } } }) -->
Example.svelte
<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>
example.component.ts
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

Properties (each is also an HTML attribute of the same name, unless marked)
PropertyTypeDefault
valuestring""
labelstring"Date"
descriptionstring""
namestring""
minstring""
maxstring""
requiredbooleanfalse
disabledbooleanfalse
Events
EventWhen
valuechangeThe 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.

Theme

Every component reads shadcn/ui's CSS variables, so any shadcn theme works. Pick a look or a colour, or paste a theme's CSS.

Look: colours, fonts, corners and motion

Accent colour