DateRangeField
A date window with native calendars, useful presets and clear boundaries.
Live — this one is real
Usage
"use client";
import { useState } from "react";
import { DateRangeField } from "mizu-ui";
export function Example() {
const [range, setRange] = useState({
start: "2026-10-15",
end: "2026-10-21",
});
return (
<DateRangeField
label="Reporting window"
value={range}
onValueChange={setRange}
defaultValue={{ start: "2026-10-15", end: "2026-10-21" }}
min="2026-01-01"
max="2026-12-31"
hint="Choose a window, or start with a preset."
presets={[
{
label: "Sample week",
value: { start: "2026-10-15", end: "2026-10-21" },
},
{
label: "Sample month",
value: { start: "2026-10-01", end: "2026-10-21" },
},
]}
/>
);
}
It starts with "use client" because it keeps state or passes functions to components, so it pastes into a Next.js page as it is. Other React setups ignore the directive.
Source & setup
Add this component to your project with the shadcn CLI. The command copies its source into your configured UI directory, with base.css, Mizu’s tokens, and the stylesheets that hold its rules. Each rule lives in one stylesheet, so components you add together never repeat CSS. In a project without a components.json, run npx shadcn@latest init 0xuser64bit/mizu/preset first: plain init installs shadcn’s theme into your global CSS. Then load the fonts.
npx shadcn@latest add 0xuser64bit/mizu/date-range-fieldEvery component imports from its own path, its name in kebab case. To paste the example, replace its mizu-ui import with:
import { DateRangeField } from "@/components/ui/mizu/date-range-field";For npm imports, import mizu-ui/styles.css once. Fonts are optional via mizu-ui/fonts.css. Override --mizu-* tokens or use className for local styling. Uses native React and CSS; install the package peers for root imports. A Client Component: its source starts with “use client”.
Inspect forms/DateRangeField.tsx
Source is included in the npm package under src/forms/DateRangeField.tsx.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| label / hint / error | string / ReactNode / string | — | Group name, shared help and external validation feedback. |
| value / defaultValue / onValueChange | DateRange / DateRange / function | — | Controlled or initial { start, end } date-only strings. Empty strings preserve an incomplete range. defaultValue is also the reset target. |
| presets | readonly DateRangePreset[] | — | Named { label, value } ranges. Incomplete, invalid and out-of-bounds presets are disabled. |
| min / max | string | — | Inclusive boundaries in YYYY-MM-DD format. Dates are compared without local timezone conversion. |
| startName / endName | string | "start" / "end" | Native form-data field names. |
| required / disabled / readOnly | boolean | — | Native validation and interaction states. Clear empties both dates; Reset restores the initial defaultValue. |
Accessibility
A fieldset and legend group two individually labelled native date inputs. Help and errors describe both inputs. End cannot precede start; invalid ranges block native form submission. Native calendars retain platform keyboard behavior and locale formatting. Native form reset restores defaultValue and reports the range through onValueChange.
Motion
Native date picking and immediate value changes; no forced travel.