my/ui

Command Palette

Search for a command to run...

All components

Calendar With Time Input

calendar

Origin UI component.

responsive · 600px

Install

Same command in any shadcn project — React (Vite/CRA), Next.js, Remix, Astro, and more:

$npx shadcn@latest add https://your-domain/r/comp-503.json

Usage

import Cmp from "@/registry/origin-ui/comp-503";

export default function Demo() {
  return <Cmp />;
}

Component source

"use client";

import { ClockIcon } from "lucide-react";
import { useId, useState } from "react";

import { Calendar } from "@/components/ui/calendar";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";

export default function Component() {
  const id = useId();
  const [date, setDate] = useState<Date | undefined>(new Date());

  return (
    <div>
      <div className="rounded-md border">
        <Calendar
          className="p-2"
          mode="single"
          onSelect={setDate}
          selected={date}
        />
        <div className="border-t p-3">
          <div className="flex items-center gap-3">
            <Label className="text-xs" htmlFor={id}>
              Enter time
            </Label>
            <div className="relative grow">
              <Input
                className="peer appearance-none ps-9 [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none"
                defaultValue="12:00:00"
                id={id}
                step="1"
                type="time"
              />
              <div className="pointer-events-none absolute inset-y-0 start-0 flex items-center justify-center ps-3 text-muted-foreground/80 peer-disabled:opacity-50">
                <ClockIcon aria-hidden="true" size={16} />
              </div>
            </div>
          </div>
        </div>
      </div>
      <p
        aria-live="polite"
        className="mt-4 text-center text-muted-foreground text-xs"
        role="region"
      >
        Time input -{" "}
        <a
          className="underline hover:text-foreground"
          href="https://daypicker.dev/"
          rel="noreferrer noopener nofollow"
          target="_blank"
        >
          React DayPicker
        </a>
      </p>
    </div>
  );
}

Source: Origin UI