# Duration input

Enter an exact numeric duration with consumer-defined units and bounds.

Access: pro. Category: Forms. Kind: composite.

## When to use

- Use it when a page needs enter an exact numeric duration with consumer-defined units and bounds.
- 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 duration input.

## 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 Duration input

```sh
npx shadcn@latest add @tidal-pro/duration-input
```

Stylesheets: `components/ui/tidal.css`, `components/ui/duration-input.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/duration-input.css";
import{TidalDurationInput}from"./components/ui/duration-input";
export default()=><div className="tidal-scope"><TidalDurationInput label={"Demo"} onUnitChange={() => {}} onValueChange={() => {}} unit={"value"} units={[{value:"value",label:"Demo"}]} value={"value"}/></div>;
```

## Structured props

- `TidalDurationInput.label: ReactNode`: Required label value accepted by this exported component.
- `TidalDurationInput.onUnitChange: (unit: string, event: ChangeEvent<HTMLSelectElement>) => void`: Callback invoked when the unit change interaction is proposed.
- `TidalDurationInput.onValueChange: (value: string, event: DurationEvent) => void`: Callback invoked when the value change interaction is proposed.
- `TidalDurationInput.unit: string`: Required unit value accepted by this exported component.
- `TidalDurationInput.units: ReadonlyArray<TidalDurationUnit>`: Required units value accepted by this exported component.
- `TidalDurationInput.value: string`: Required value value accepted by this exported component.
- `TidalDurationInput.decrementButtonProps?: StepButtonProps | undefined`: Optional decrement button props value accepted by this exported component.
- `TidalDurationInput.decrementButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional decrement button ref value accepted by this exported component.
- `TidalDurationInput.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalDurationInput.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalDurationInput.error?: ReactNode`: Optional error value accepted by this exported component.
- `TidalDurationInput.incrementButtonProps?: StepButtonProps | undefined`: Optional increment button props value accepted by this exported component.
- `TidalDurationInput.incrementButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional increment button ref value accepted by this exported component.
- `TidalDurationInput.labels?: Partial<{ value: string; unit: string; decrement: string; increment: string; required: string; invalidConfiguration: string; }> | undefined`: Optional labels value accepted by this exported component.
- `TidalDurationInput.readOnly?: boolean | undefined` (default false): Optional read only value accepted by this exported component.
- `TidalDurationInput.unitSelectProps?: UnitSelectProps | undefined`: Optional unit select props value accepted by this exported component.
- `TidalDurationInput.unitSelectRef?: Ref<HTMLSelectElement> | undefined`: Optional unit select ref value accepted by this exported component.
- `TidalDurationInput.valueInputProps?: ValueInputProps | undefined`: Optional value input props value accepted by this exported component.
- `TidalDurationInput.valueInputRef?: Ref<HTMLInputElement> | undefined`: Optional value input ref value accepted by this exported component.

## Complete usage example

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

```tsx
"use client";

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

import { useState } from "react";

import { TidalDurationInput, type TidalDurationUnit } from "./components/ui/duration-input";

import "./components/ui/duration-input.css";



const tidalExampleStyles = ".tidal-scope .duration-input-demo {\n  container-type: inline-size;\n  display: grid;\n  gap: 14px;\n  width: 100%;\n  max-width: 620px;\n  min-width: 0;\n}\n\n.tidal-scope .duration-input-demo-actions {\n  display: flex;\n  flex-wrap: wrap;\n  gap: 8px;\n}\n\n.tidal-scope .duration-input-demo-actions button {\n  min-height: 44px;\n  min-width: 44px;\n  padding: 8px 14px;\n  border: 1px solid var(--t-border);\n  border-radius: 10px;\n  background: var(--t-surface);\n  color: var(--t-ink);\n  font:\n    500 12px/1.4 Inter,\n    sans-serif;\n  cursor: pointer;\n}\n\n.tidal-scope .duration-input-demo-actions button:first-child {\n  background: var(--t-ink);\n  color: var(--t-surface);\n  border-color: var(--t-ink);\n}\n\n.tidal-scope .duration-input-demo-actions button:focus-visible {\n  outline: 2px solid var(--t-accent);\n  outline-offset: 2px;\n}\n\n.tidal-scope .duration-input-demo footer {\n  display: grid;\n  gap: 3px;\n  min-width: 0;\n  font-size: 11px;\n  line-height: 1.55;\n  color: var(--t-muted);\n  overflow-wrap: anywhere;\n}\n\n.tidal-scope .duration-input-demo footer output {\n  color: var(--t-ink);\n}\n\n@container (max-width: 320px) {\n  .tidal-scope .duration-input-demo-actions button {\n    flex: 1 1 110px;\n  }\n}";

const UNITS: readonly TidalDurationUnit[] = [
  { value: "minutes", label: "Minutes", min: "0", max: "180", step: "5" },
  { value: "hours", label: "Hours", min: "0", max: "72", step: "0.25" },
  { value: "days", label: "Days", min: "0", max: "30", step: "0.5" },
];

const INITIAL_VALUE = "30";

const INITIAL_UNIT = "minutes";

export function DurationInputDemo() {
  const [value, setValue] = useState(INITIAL_VALUE);
  const [unit, setUnit] = useState(INITIAL_UNIT);
  const [status, setStatus] = useState("Set the review window.");

  return (
    <form
      className="duration-input-demo"
      action="/local-duration-preview"
      method="post"
      onSubmit={(event) => {
        event.preventDefault();
        const data = new FormData(event.currentTarget);
        setStatus(
          `Local preview: ${String(data.get("durationValue") ?? "")} ${String(data.get("durationUnit") ?? "")}.`,
        );
      }}
      onReset={() => {
        setValue(INITIAL_VALUE);
        setUnit(INITIAL_UNIT);
        setStatus("The sample duration was reset.");
      }}
    >
      <TidalDurationInput
        label="Review window"
        description="Choose a numeric amount and unit for this local brief. Units are not converted automatically."
        value={value}
        unit={unit}
        units={UNITS}
        onValueChange={(next) => {
          setValue(next);
          setStatus(`Value changed to ${next || "empty"}.`);
        }}
        onUnitChange={(next) => {
          setUnit(next);
          setStatus(`Unit changed to ${next}.`);
        }}
        valueInputProps={{ name: "durationValue", required: true }}
        unitSelectProps={{ name: "durationUnit", required: true }}
      />
      <div className="duration-input-demo-actions">
        <button type="submit">Prepare preview</button>
        <button type="reset">Reset</button>
      </div>
      <footer>
        <output aria-live="polite">{status}</output>
        <span>Local sample only. Nothing is scheduled or saved.</span>
      </footer>
    </form>
  );
}

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

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--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."],"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."}

label, controlled exact decimal string value, controlled unit string, consumer-owned units with unique nonblank values and exact string labels, and value/unit callbacks are required. Each unit may supply exact string min/max/step bounds or step any; every definition is checked before controls render, and a disabled unit cannot be the current selection. The component does not convert values when units change. Native number editing and 44px decrement/increment actions propose exact step changes within the selected bounds. Optional description/error, disabled/readOnly, root attributes/ref, native number/select props and refs, and decrement/increment button props and refs are supported. Read-only unit values retain native form serialization through a hidden mirror; disabled values remain natively omitted. Native handlers run first and prevention in either input event stops the single proposal. Consumers own form submission, validation policy, conversion, persistence and outcomes. No date, clock, schedule, request, network or storage behavior is bundled.
