# Date range picker

Choose start and end dates with linked calendars.

Access: pro. Category: Forms. Kind: primitive.

## When to use

- Use it when a product interface needs choose start and end dates with linked calendars.
- Choose it when the host application can supply the required state and keep business logic outside the presentation component.

## Alternatives

- Choose form-field instead when a labeled email field with validation and help text is the actual interface need, rather than date range picker.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Date range picker

```sh
npx shadcn@latest add @tidal-pro/date-range-picker
```

Stylesheets: `components/ui/tidal.css`, `components/ui/date-range-picker.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/date-range-picker.css";
import{TidalDateRangePicker}from"./components/ui/date-range-picker";
export default()=><div className="tidal-scope"><TidalDateRangePicker label={"Demo"} onValueChange={() => {}} value={{start:"value",end:"value"}}/></div>;
```

## Structured props

- `TidalDateRangePicker.label: string`: Required label value accepted by this exported component.
- `TidalDateRangePicker.onValueChange: (range: TidalDateRange) => void`: Callback invoked when the value change interaction is proposed.
- `TidalDateRangePicker.value: TidalDateRange`: Required value value accepted by this exported component.
- `TidalDateRangePicker.clearable?: boolean | undefined` (default true): Optional clearable value accepted by this exported component.
- `TidalDateRangePicker.description?: string | undefined`: Optional description value accepted by this exported component.
- `TidalDateRangePicker.dir?: "ltr" | "rtl" | undefined`: Optional dir value accepted by this exported component.
- `TidalDateRangePicker.endInputProps?: DateInputProps | undefined` (default {}): Optional end input props value accepted by this exported component.
- `TidalDateRangePicker.endLabel?: string | undefined` (default "End date"): Optional end label value accepted by this exported component.
- `TidalDateRangePicker.endRef?: Ref<HTMLInputElement> | undefined`: Optional end ref value accepted by this exported component.
- `TidalDateRangePicker.error?: string | undefined`: Optional error value accepted by this exported component.
- `TidalDateRangePicker.isDateDisabled?: ((iso: string) => boolean) | undefined`: Endpoint availability. Interior dates are the consumer's isRangeDisabled responsibility.
- `TidalDateRangePicker.isRangeDisabled?: ((range: TidalCompleteDateRange) => boolean) | undefined`: Optional is range disabled value accepted by this exported component.
- `TidalDateRangePicker.labels?: Partial<{ open: string; calendar: string; calendarTitle: string; shortcuts: string; clear: string; previous: string; next: string; month: string; year: string; apply: string; cancel: string; unavailable: string; instructions: string; chooseEnd: string; chooseStart: string; days: (count: number) => string; yearRange: (min: number, max: number) => string; }> | undefined` (default {}): Optional labels value accepted by this exported component.
- `TidalDateRangePicker.locale?: string | undefined` (default "en-US"): Optional locale value accepted by this exported component.
- `TidalDateRangePicker.max?: string | undefined`: Optional max value accepted by this exported component.
- `TidalDateRangePicker.maxDays?: number | undefined`: Optional max days value accepted by this exported component.
- `TidalDateRangePicker.messages?: Partial<Record<TidalRangeIssue, string>> | undefined` (default {}): Optional messages value accepted by this exported component.
- `TidalDateRangePicker.min?: string | undefined`: Optional min value accepted by this exported component.
- `TidalDateRangePicker.minDays?: number | undefined` (default 1): Optional min days value accepted by this exported component.
- `TidalDateRangePicker.months?: 1 | "auto" | 2 | undefined` (default "auto"): Optional months value accepted by this exported component.
- `TidalDateRangePicker.presets?: Array<{ label: string; value: TidalCompleteDateRange; }> | undefined` (default []): Optional presets value accepted by this exported component.
- `TidalDateRangePicker.readOnly?: boolean | undefined` (default false): Optional read only value accepted by this exported component.
- `TidalDateRangePicker.required?: boolean | undefined` (default false): Optional required value accepted by this exported component.
- `TidalDateRangePicker.startInputProps?: DateInputProps | undefined` (default {}): Optional start input props value accepted by this exported component.
- `TidalDateRangePicker.startLabel?: string | undefined` (default "Start date"): Optional start label value accepted by this exported component.
- `TidalDateRangePicker.startRef?: Ref<HTMLInputElement> | undefined`: Optional start ref value accepted by this exported component.
- `TidalDateRangePicker.theme?: "light" | "dark" | undefined`: Optional theme value accepted by this exported component.
- `TidalDateRangePicker.today?: string | undefined`: Optional today value accepted by this exported component.
- `TidalDateRangePicker.weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined` (default 1): Optional week starts on value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/date-range-picker.tsx) | [Manifest](https://tidalui.com/examples/date-range-picker.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
import "./components/ui/tidal.css";

import { useEffect, useLayoutEffect, useRef, useState } from "react";

import { ArrowUpRight, Check, RotateCcw } from "lucide-react";

import { TidalDateRangePicker, tidalRangeDays, tidalRangeIssue, type TidalDateRange } from "./components/ui/date-range-picker";

import { TidalDateDigits, tidalFormatDate, tidalParseDate } from "./components/ui/date-picker";

import { TidalButton } from "./components/ui/tidal-button";

import "./components/ui/date-picker.css";

import "./components/ui/date-range-picker.css";



const tidalExampleStyles = ".tidal-scope .date-range-specimen {\n  width: 100%;\n  max-width: 760px;\n  padding: 28px;\n  border: 1px solid var(--t-border);\n  border-radius: var(--t-radius-card);\n  background: var(--t-surface);\n  box-shadow:\n    0 2px 3px #00000004,\n    0 18px 35px -30px #00000040;\n}\n.tidal-scope .date-range-specimen > h3 {\n  font-size: 29px;\n  font-weight: 500;\n  line-height: 1.15;\n  letter-spacing: -1.1px;\n  margin: 15px 0 26px;\n}\n.tidal-scope .date-range-specimen > h3 em {\n  font:\n    italic 37px/1.15 \"Instrument Serif\",\n    Georgia,\n    serif;\n  letter-spacing: -0.8px;\n}\n\n.tidal-scope .range-demo-short-duration {\n  display: none;\n}\n.tidal-scope .range-demo-stage {\n  padding: 7px;\n  margin: 0 -7px;\n  overflow: hidden;\n  transition: height 420ms var(--t-ease-out);\n}\n.tidal-scope .range-demo-content {\n  display: flow-root;\n}\n.tidal-scope .range-demo-layout {\n  display: grid;\n  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);\n  gap: 28px;\n  align-items: center;\n}\n.tidal-scope .range-demo-layout form {\n  min-width: 0;\n}\n.tidal-scope .range-demo-form-caption {\n  display: block;\n  font-size: 11px;\n  letter-spacing: 1.3px;\n  color: var(--t-muted);\n  margin-bottom: 24px;\n}\n.tidal-scope .range-demo-ticket {\n  position: relative;\n  min-width: 0;\n  border: 1px solid var(--t-ink);\n  border-radius: 12px;\n  background: var(--t-ink);\n  color: var(--t-surface);\n  padding: 20px;\n  box-shadow:\n    0 14px 20px -15px #00000050,\n    inset 0 1px 0 #ffffff12;\n  overflow: hidden;\n  animation: range-ticket-enter 620ms var(--t-ease-out) both;\n}\n.tidal-scope .range-demo-ticket-heading {\n  display: flex;\n  justify-content: space-between;\n  gap: 8px;\n  font-size: 11px;\n  letter-spacing: 1.3px;\n  opacity: 0.65;\n  margin-bottom: 27px;\n}\n.tidal-scope .range-demo-endpoints {\n  display: grid;\n  grid-template-columns: repeat(2, minmax(0, 1fr));\n  gap: 14px;\n}\n.tidal-scope .range-demo-endpoints > div {\n  min-width: 0;\n}\n.tidal-scope .range-demo-endpoints > div > span:first-child {\n  display: block;\n  font-size: 11px;\n  letter-spacing: 1px;\n  opacity: 0.5;\n  margin-bottom: 14px;\n}\n.tidal-scope .range-demo-month {\n  display: block;\n  font-size: 11px;\n  letter-spacing: 1px;\n  text-transform: uppercase;\n  animation: range-month-enter 280ms var(--t-ease-out) both;\n}\n.tidal-scope .range-demo-endpoint-day {\n  font-size: 40px;\n  line-height: 1.1;\n  font-weight: 500;\n  letter-spacing: -2px;\n  margin: 3px 0 7px;\n}\n.tidal-scope .range-demo-endpoints time {\n  display: block;\n  font-size: 11px;\n  line-height: 1.55;\n  opacity: 0.7;\n  overflow-wrap: anywhere;\n}\n.tidal-scope .range-demo-unset {\n  display: block;\n  font-size: 26px;\n  line-height: 2.2;\n  opacity: 0.6;\n}\n.tidal-scope .range-demo-seam {\n  position: relative;\n  display: flex;\n  justify-content: center;\n  align-items: center;\n  gap: 10px;\n  font-size: 11px;\n  letter-spacing: 1.4px;\n  margin: 25px -21px 22px;\n  color: inherit;\n}\n.tidal-scope .range-demo-seam > span,\n.tidal-scope .range-demo-seam > i {\n  opacity: 0.5;\n}\n.tidal-scope .range-demo-seam:before,\n.tidal-scope .range-demo-seam:after {\n  content: \"\";\n  position: absolute;\n  width: 13px;\n  height: 13px;\n  border-radius: 50%;\n  background: var(--t-surface);\n  top: calc(50% - 6.5px);\n}\n.tidal-scope .range-demo-seam:before {\n  left: -6.5px;\n}\n.tidal-scope .range-demo-seam:after {\n  right: -6.5px;\n}\n.tidal-scope .range-demo-seam i {\n  flex: 1;\n  border-top: 1px dashed #80808080;\n}\n.tidal-scope .range-demo-duration {\n  display: flex;\n  gap: 17px;\n  align-items: center;\n  min-width: 0;\n}\n.tidal-scope .range-demo-duration > span:first-child {\n  font-size: 66px;\n  line-height: 1.1;\n  letter-spacing: -4px;\n  font-weight: 500;\n  flex-shrink: 0;\n}\n.tidal-scope .range-demo-duration > span:last-child {\n  font-size: 11px;\n  line-height: 1.65;\n  opacity: 0.7;\n  max-width: 110px;\n}\n.tidal-scope .range-demo-axis {\n  display: grid;\n  grid-template-columns: 1fr 1fr;\n  position: relative;\n  margin-top: 20px;\n  color: inherit;\n  font-size: 11px;\n  letter-spacing: 0.8px;\n  opacity: 0.8;\n}\n.tidal-scope .range-demo-axis > div {\n  position: relative;\n  grid-column: 1/-1;\n  height: 7px;\n  background: #80808055;\n  border-radius: 4px;\n  margin: 0 3px 10px;\n}\n.tidal-scope .range-demo-axis > div > span {\n  position: absolute;\n  height: 7px;\n  top: 0;\n  background: var(--t-surface);\n  transition:\n    left 420ms var(--t-ease-out),\n    width 420ms var(--t-ease-out);\n}\n.tidal-scope .range-demo-axis > div > i {\n  position: absolute;\n  top: -3px;\n  width: 3px;\n  height: 13px;\n  border-radius: 2px;\n  background: var(--t-surface);\n  transform: translateX(-50%);\n  transition: left 420ms var(--t-ease-out);\n}\n.tidal-scope .range-demo-axis > span:last-child {\n  text-align: right;\n}\n.tidal-scope .range-demo-ticket > p {\n  color: inherit;\n  font-size: 11px;\n  line-height: 1.6;\n  margin: 14px 0 0;\n  opacity: 0.5;\n}\n.tidal-scope .range-demo-actions {\n  display: flex;\n  gap: 8px;\n  margin-top: 22px;\n}\n.tidal-scope .range-demo-actions .tidal-button {\n  flex: 1;\n  min-width: 0;\n  padding: 0 9px;\n  font-size: 11px;\n  outline-offset: -5px;\n}\n.tidal-scope .range-demo-actions .tidal-button:focus-visible {\n  outline-color: currentColor;\n}\n.tidal-scope .range-demo-status {\n  display: block;\n  font-size: 11px;\n  color: var(--t-muted);\n  line-height: 1.5;\n  margin-top: 10px;\n}\n.tidal-scope .range-demo-note {\n  font-size: 11px;\n  color: var(--t-muted);\n  line-height: 1.65;\n  margin: 22px 0 0;\n}\n.tidal-scope .range-demo-complete {\n  text-align: center;\n  padding: 16px 5px 22px;\n  animation: range-ticket-enter 420ms var(--t-ease-out) both;\n}\n.tidal-scope .range-demo-complete > span {\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  width: 44px;\n  height: 44px;\n  border-radius: 50%;\n  background: var(--t-ink);\n  color: var(--t-surface);\n  margin: 0 auto 15px;\n}\n.tidal-scope .range-demo-complete h4 {\n  font-size: 22px;\n  font-weight: 500;\n  letter-spacing: -0.7px;\n  outline-offset: -5px;\n}\n.tidal-scope .range-demo-complete p {\n  font-size: 11px;\n  color: var(--t-muted);\n  margin-top: 9px;\n}\n.tidal-scope .date-range-specimen[data-phase=\"set\"] .range-demo-layout {\n  grid-template-columns: 1fr;\n}\n.tidal-scope .date-range-specimen[data-phase=\"set\"] .range-demo-ticket {\n  max-width: 300px;\n  width: 100%;\n  margin-inline: auto;\n}\n.tidal-scope .range-demo-saved-actions {\n  justify-content: center;\n}\n.tidal-scope .range-demo-saved-actions .tidal-button {\n  flex: 0 1 auto;\n  padding: 0 16px;\n}\n.tidal-scope .range-demo-saved-actions .tidal-button:last-child {\n  width: 44px;\n  padding: 0;\n}\n@keyframes range-ticket-enter {\n  from {\n    opacity: 0;\n    transform: translateY(8px);\n  }\n  to {\n    opacity: 1;\n    transform: translateY(0);\n  }\n}\n@keyframes range-month-enter {\n  from {\n    opacity: 0;\n    transform: translateY(3px);\n  }\n  to {\n    opacity: 1;\n    transform: translateY(0);\n  }\n}\n@media (max-width: 600px) {\n  .tidal-scope .date-range-specimen {\n    padding: 16px;\n  }\n  .tidal-scope .date-range-specimen > h3 {\n    font-size: 25px;\n    margin: 12px 0 16px;\n  }\n  .tidal-scope .date-range-specimen > h3 em {\n    font-size: 32px;\n  }\n  .tidal-scope .range-demo-layout {\n    grid-template-columns: 1fr;\n    gap: 16px;\n  }\n  .tidal-scope .range-demo-form-caption {\n    display: none;\n  }\n  .tidal-scope .range-demo-ticket {\n    padding: 16px;\n  }\n  .tidal-scope .range-demo-ticket-heading {\n    margin-bottom: 18px;\n  }\n  .tidal-scope .range-demo-endpoints > div > span:first-child {\n    margin-bottom: 10px;\n  }\n  .tidal-scope .range-demo-seam {\n    margin: 18px -17px 14px;\n  }\n  .tidal-scope .range-demo-duration > span:first-child {\n    font-size: 56px;\n  }\n  .tidal-scope .range-demo-axis {\n    margin-top: 14px;\n  }\n  .tidal-scope .range-demo-ticket > p {\n    margin-top: 10px;\n  }\n  .tidal-scope .range-demo-actions {\n    margin-top: 14px;\n  }\n  .tidal-scope .range-demo-note {\n    font-size: 11px;\n    margin-top: 14px;\n  }\n}\n@media (max-width: 600px) {\n  .tidal-scope .range-demo-ticket {\n    padding: 14px;\n  }\n  .tidal-scope .range-demo-ticket-heading {\n    margin-bottom: 10px;\n  }\n  .tidal-scope .range-demo-endpoints > div > span:first-child {\n    margin-bottom: 6px;\n  }\n  .tidal-scope .range-demo-endpoint-day {\n    font-size: 32px;\n    margin: 3px 0 5px;\n  }\n  .tidal-scope .range-demo-seam {\n    margin: 12px -15px 10px;\n  }\n  .tidal-scope .range-demo-duration > span:first-child {\n    font-size: 48px;\n  }\n  .tidal-scope .range-demo-axis {\n    margin-top: 12px;\n  }\n  .tidal-scope .range-demo-ticket > p {\n    display: none;\n  }\n  .tidal-scope .date-range-specimen .tidal-range-fieldset > legend {\n    margin-bottom: 10px;\n  }\n  .tidal-scope .date-range-specimen .tidal-range-native > label {\n    margin-bottom: 5px;\n  }\n  .tidal-scope .date-range-specimen .tidal-range-date-control {\n    padding: 3px;\n  }\n  .tidal-scope .date-range-specimen .tidal-range-toolbar {\n    margin-top: 6px;\n  }\n  .tidal-scope .range-demo-actions {\n    margin-top: 12px;\n  }\n}\n@media (prefers-reduced-motion: reduce) {\n  .tidal-scope .date-range-specimen * {\n    animation: none !important;\n    transition: none !important;\n  }\n  .tidal-scope .range-demo-ticket,\n  .tidal-scope .range-demo-complete,\n  .tidal-scope .range-demo-month {\n    transform: none;\n  }\n}";

const original: TidalDateRange = { start: "2026-10-26", end: "2026-11-06" };

const today = "2026-10-14",
  last = "2026-12-31",
  held = "2026-11-26";

const rules = {
  min: today,
  max: last,
  minDays: 2,
  maxDays: 45,
  isDateDisabled: (iso: string) => iso === held,
  isRangeDisabled: (range: { start: string; end: string }) =>
    range.start <= held && range.end >= held,
};

const presets = [
  { label: "7 days", value: { start: "2026-10-26", end: "2026-11-01" } },
  { label: "14 days", value: { start: "2026-10-26", end: "2026-11-08" } },
  { label: "Next sprint", value: { start: "2026-11-02", end: "2026-11-13" } },
];

export function DateRangeDemo() {
  const [range, setRange] = useState<TidalDateRange>({ ...original }),
    [error, setError] = useState(""),
    [phase, setPhase] = useState<"editing" | "setting" | "set">("editing"),
    [height, setHeight] = useState<number>();
  const start = useRef<HTMLInputElement>(null),
    end = useRef<HTMLInputElement>(null),
    title = useRef<HTMLHeadingElement>(null),
    content = useRef<HTMLDivElement>(null),
    restore = useRef(false),
    timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
  const focusOwner = useRef<HTMLElement | null>(null);
  const days = tidalRangeDays(range),
    complete = days !== null,
    valid = tidalRangeIssue(range, rules) === null;
  const firstDate = tidalParseDate(range.start),
    endDate = tidalParseDate(range.end),
    span = tidalParseDate(last)!.getTime() - tidalParseDate(today)!.getTime();
  const left = firstDate
      ? Math.max(
          0,
          Math.min(
            1,
            (firstDate.getTime() - tidalParseDate(today)!.getTime()) / span,
          ),
        )
      : 0,
    right = endDate
      ? Math.max(
          left,
          Math.min(
            1,
            (endDate.getTime() - tidalParseDate(today)!.getTime()) / span,
          ),
        )
      : left;
  useEffect(() => () => clearTimeout(timer.current), []);
  useLayoutEffect(() => {
    const active = document.activeElement;
    const canMoveFocus =
      active === document.body || active === focusOwner.current;
    if (phase === "set" && canMoveFocus) {
      title.current?.focus({ preventScroll: true });
      focusOwner.current = null;
    } else if (phase === "editing" && restore.current) {
      restore.current = false;
      if (canMoveFocus) start.current?.focus({ preventScroll: true });
      focusOwner.current = null;
    }
  }, [phase]);
  useLayoutEffect(() => {
    const node = content.current;
    if (!node) return;
    const measure = () => {
      const css = getComputedStyle(node.parentElement!);
      setHeight(
        node.offsetHeight +
          Number.parseFloat(css.paddingTop) +
          Number.parseFloat(css.paddingBottom),
      );
    };
    measure();
    const ro = new ResizeObserver(measure);
    ro.observe(node);
    return () => ro.disconnect();
  }, []);
  function edit() {
    clearTimeout(timer.current);
    focusOwner.current =
      document.activeElement instanceof HTMLElement
        ? document.activeElement
        : null;
    setError("");
    restore.current = true;
    setPhase("editing");
    if (phase === "editing") {
      restore.current = false;
      start.current?.focus({ preventScroll: true });
    }
  }
  function reset() {
    setRange({ ...original });
    edit();
  }
  return (
    <div className="date-range-specimen" data-phase={phase}>
      <div className="range-demo-stage" style={{ height }}>
        <div ref={content} className="range-demo-content">
          {phase === "set" ? (
            <div className="range-demo-complete">
              <span aria-hidden="true">
                <Check size={20} />
              </span>
              <h4 ref={title} tabIndex={-1}>
                A window of possibility.
              </h4>
              <p>Kept in this sample. No dates were booked or scheduled.</p>
            </div>
          ) : null}
          <div className="range-demo-layout">
            {phase !== "set" ? (
              <form
                noValidate
                onSubmit={(e) => {
                  e.preventDefault();
                  if (!valid) {
                    setError(
                      "Choose a complete 2–45 day window that does not cross November 26.",
                    );
                    (!range.start ? start.current : end.current)?.focus({
                      preventScroll: true,
                    });
                    return;
                  }
                  focusOwner.current =
                    (e.nativeEvent as SubmitEvent).submitter instanceof
                    HTMLElement
                      ? (e.nativeEvent as SubmitEvent).submitter
                      : document.activeElement instanceof HTMLElement
                        ? document.activeElement
                        : null;
                  setPhase("setting");
                  timer.current = setTimeout(() => setPhase("set"), 550);
                }}
              >
                <span className="range-demo-form-caption">
                  THE NEXT LITTLE CHAPTER
                </span>
                <TidalDateRangePicker
                  label="Sample planning window"
                  value={range}
                  onValueChange={(next) => {
                    setRange(next);
                    setError("");
                  }}
                  startRef={start}
                  endRef={end}
                  name="planning-window"
                  required
                  disabled={phase === "setting"}
                  today={today}
                  {...rules}
                  presets={presets}
                  description="Sample windows: 2–45 days. November 26 is held."
                  error={error}
                />
                <div className="range-demo-actions">
                  <TidalButton
                    type="button"
                    variant="secondary"
                    onClick={phase === "setting" ? edit : reset}
                  >
                    {phase === "setting" ? "Cancel sample" : "Reset sample"}
                  </TidalButton>
                  <TidalButton type="submit" loading={phase === "setting"}>
                    {phase === "setting"
                      ? "Keeping window"
                      : "Keep sample window"}
                    {phase === "editing" ? <ArrowUpRight size={13} /> : null}
                  </TidalButton>
                </div>
                {phase === "setting" ? (
                  <span className="range-demo-status" role="status">
                    Keeping this local sample…
                  </span>
                ) : null}
              </form>
            ) : null}
            <section
              className="range-demo-ticket"
              aria-label="Sample planning window readout"
              data-empty={!complete || undefined}
            >
              <div className="range-demo-ticket-heading">
                <span>THE MAKING WINDOW</span>
                <span>R / 030</span>
              </div>
              <div className="range-demo-endpoints">
                {(["start", "end"] as const).map((which, i) => {
                  const date = which === "start" ? firstDate : endDate;
                  return (
                    <div key={which}>
                      <span>{i === 0 ? "A BEGINNING" : "AN ENDING"}</span>
                      {date ? (
                        <>
                          <span
                            className="range-demo-month"
                            key={range[which]!.slice(0, 7)}
                            aria-hidden="true"
                          >
                            {tidalFormatDate(range[which]!, "en-US", {
                              month: "short",
                            })}
                          </span>
                          <div
                            className="range-demo-endpoint-day"
                            aria-hidden="true"
                          >
                            <TidalDateDigits
                              text={String(date.getUTCDate()).padStart(2, "0")}
                            />
                          </div>
                          <time dateTime={range[which]!}>
                            {tidalFormatDate(range[which]!, "en-US", {
                              weekday: "short",
                              month: "short",
                              day: "numeric",
                              year: "numeric",
                            })}
                          </time>
                        </>
                      ) : (
                        <span className="range-demo-unset">Open</span>
                      )}
                    </div>
                  );
                })}
              </div>
              <div className="range-demo-seam" aria-hidden="true">
                <i />
                <span>THE SPACE BETWEEN</span>
                <i />
              </div>
              <div className="range-demo-duration">
                <span aria-hidden="true">
                  {complete ? (
                    <TidalDateDigits text={String(days).padStart(2, "0")} />
                  ) : (
                    <span>—</span>
                  )}
                </span>
                <span>
                  <span className="range-demo-full-duration">
                    {complete
                      ? `${days} calendar ${days === 1 ? "day" : "days"}, inclusive.`
                      : "Choose both dates to see the window."}
                  </span>
                  <span
                    className="range-demo-short-duration"
                    aria-hidden="true"
                  >
                    {complete ? "days" : "open"}
                  </span>
                </span>
              </div>
              <div className="range-demo-axis" aria-hidden="true">
                <div>
                  <span
                    style={{
                      left: `${left * 100}%`,
                      width: `${(right - left) * 100}%`,
                    }}
                  />
                  <i style={{ left: `${left * 100}%` }} />
                  <i style={{ left: `${right * 100}%` }} />
                </div>
                <span>OCT 14</span>
                <span>DEC 31</span>
              </div>
              <p>
                {complete
                  ? "Date range selected."
                  : "Select a start and end date."}
              </p>
            </section>
          </div>
          {phase === "set" ? (
            <div className="range-demo-actions range-demo-saved-actions">
              <TidalButton variant="secondary" onClick={edit}>
                Adjust sample
              </TidalButton>
              <TidalButton
                variant="secondary"
                aria-label="Reset original window"
                onClick={reset}
              >
                <RotateCcw size={15} />
              </TidalButton>
            </div>
          ) : null}
        </div>
      </div>
      <p className="range-demo-note">
        Fictional availability. Nothing is booked, sent or stored.
      </p>
    </div>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <DateRangeDemo />
    </div>
  );
}

```

## Gotchas

- Keep field state, validation results, submission, and persistence in the host form workflow.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-calendar-offset-y","--t-calendar-viewport-height","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation.","Escape dismisses the open overlay where the underlying primitive supports dismissal."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

Controlled value:TidalDateRange ({start:string|null,end:string|null}) and onValueChange; initialize with useState<TidalDateRange>({start:null,end:null}). Canonical Gregorian YYYY-MM-DD civil dates0001..9999. Two real type=date inputs submit name[start]/name[end], with individual startInputProps/endInputProps name/form/ID/native handlers overriding defaults. Native edits propose immediately and compose real native onChange/onInput; calendar picks edit an isolated draft and Apply proposes once, without forged native events. Cancel/Escape/outside discard the draft. Consumers own state, resets, requests and rejected proposals. Draft snapshots caller value on open; external caller changes do not replace an open draft. Optional min/max ISO bounds, inclusive minDays(default1)/maxDays, pure endpoint isDateDisabled(iso) and pure isRangeDisabled({start,end}) for whole-range/interior availability. The component never walks every interior date; callers implement full interval rules in isRangeDisabled. Malformed/reversed bounds and invalid length limits disable the group; malformed dates, reversed/partial/blocked/outside/too-short/too-long values show linked validity without clamping caller data. An optional empty pair is valid; a partial pair is invalid, and required makes both native fields required. Consumer error blocks editable native submission. Native readOnly inputs do not participate in HTML constraint validation; consumers must validate range values before requests. Native field refs through startRef/endRef; forwarded root ref targets the native fieldset. disabled excludes both dates from submission; readOnly submits values and disables calendar/Clear. Fieldset HTML props/className compose with native form bubbling, except root onKeyDown: set start/endInputProps.onKeyDown to intercept the native shortcuts. Native Alt+ArrowDown and trigger Enter/Space open a modal Radix Popover; caller field handlers run first, and preventDefault/composition is honored. Calendar one roving day Tab stop across one/two current-month grids; Arrows, row Home/End, Page keys and Shift+Page for civil month/year movement, RTL horizontal reversal and bounded clamps. Endpoint unavailable days are focusable/inspectable but cannot be chosen. First pick starts a new draft, second pick sorts its endpoints; another pick restarts. Hover/focus previews extend a persistent per-week band with travelling endpoint caps; invalid whole ranges remain visibly striped and cannot Apply. Month/year controls and optional fixed presets browse directly. Invalid year alert is linked, caller-localizable and direction-aware. Apply returns native opening-field/start focus; Escape returns the opening control. Optional todayISO(today prop; default local civil day), weekStartsOn0..6(default1), locale(defaulten-US, Gregorian UTC/fallbacken-US), months1/2/auto(defaultauto, two at760px viewport), presets, labels/messages, clearable(defaulttrue), theme/dir. At360px and below the popup fits a complete308px month grid with seven44px day targets. Explicit months=2 retains a horizontally scrollable strip between complete month grids; auto uses one month on phones. Visual-viewport clamping keeps the popup and fixed footer inside a short or keyboard-reduced viewport. Portal reads surrounding theme/direction on open. Labels include visible calendar text, calendarTitle, shortcuts, days(count) and yearRange(min,max); messages map typed validation codes. A viewport-fitted panel follows the field group and can straddle it to keep the calendar usable. Constrained popup fixes header/presets/footer and scrolls only its grid; minimum308px per month preserves44px days on narrow surfaces. Auto mode adapts to viewport changes. Native display follows OS/browser locale; decorative readout follows locale. Requires gated @tidal-pro/date-picker for shared civil helpers/digits, and import tidal.css/date-picker.css/date-range-picker.css. Exports tidalRangeDays (inclusive/null if incomplete, malformed or reversed) and tidalRangeIssue for validation. Finite range/popup/digit motion honors reduced motion. No form wrapper, reservation, scheduling, network or storage is introduced.
