Skip to content

TimePicker

Form

A labeled native time input with minute or second precision.

Controlled minutesSeconds precisionTime boundsDisabled schedule
Open preview

Responsive viewport — resize the window to explore. Direction and density apply only to this preview. Theme applies to the docs too.

Usage

Use value/onChange or defaultValue with a local HH:mm string. Set step in seconds for finer precision. This input represents a time of day without a date or timezone; perform any timezone conversion in your application.

Import
import { TimePicker } from "@/components/ui/time-picker";

Shipped as editable source in src/components/ui/time-picker.tsx in both apps. Copy the implementation below when moving it to another project. Copy the complete example from Source code for all imports and state. Add "use client" when using hooks or event handlers. See installation and theming for project setup.

Component source

The complete implementation is included in both apps. It uses the React, Radix, Lucide, and shared-core dependencies already installed in Apex. Keep your project’s semantic theme tokens when reusing it.

src/components/ui/time-picker.tsx
"use client";
import { useId, type ComponentProps } from "react";
import { Input } from "@dashboardpack/core/components/ui/input";
import { Label } from "@dashboardpack/core/components/ui/label";
import { cn } from "@dashboardpack/core/lib/utils";
export function TimePicker({
  label,
  className,
  id,
  step = 60,
  ...props
}: Omit<ComponentProps<"input">, "type"> & { label: string }) {
  const generated = useId();
  const controlId = id ?? generated;
  return (
    <div className={cn("space-y-2", className)}>
      <Label htmlFor={controlId}>{label}</Label>
      <Input id={controlId} type="time" step={step} {...props} />
    </div>
  );
}

API reference

Common props and defaults. Slot-specific props are named below; native elements also accept their standard HTML attributes. The component TypeScript definitions are the complete type reference.

TimePicker props
PropType / DefaultDescription
labelstring

Default: required

Visible field name.
value / defaultValuestring

Default: —

Local HH:mm or HH:mm:ss value.
onChangeChangeEventHandler<HTMLInputElement>

Default: —

Native input change callback.
stepnumber

Default: 60

Precision in seconds.
min / maxstring

Default: —

Native local-time bounds.
disabled / required / namenative input attributes

Default: —

Native form behavior.

Build with these too