# P calendar 18

> Calendar with time input

A shadcn/ui block from the [@coss](https://coss.com/ui) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/coss/p-calendar-18).

- Page, with a live preview: https://shadcn.exchange/r/coss/p-calendar-18
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/coss/p-calendar-18-light-ce79c07160144f54.png
- Registry item: https://coss.com/ui/r/p-calendar-18.json
- Categories: calendar, input, field
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://coss.com/ui/r/p-calendar-18.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- npm packages: `lucide-react`
- Registry items: `@coss/calendar`, `@coss/field`, `@coss/input-group`

## Files

### `registry/default/particles/p-calendar-18.tsx`

```tsx
"use client";

import { ClockIcon } from "lucide-react";
import { useState } from "react";
import { Calendar } from "@/registry/default/ui/calendar";
import { Field, FieldLabel } from "@/registry/default/ui/field";
import {
  InputGroup,
  InputGroupAddon,
  InputGroupInput,
} from "@/registry/default/ui/input-group";

export default function Particle() {
  const [date, setDate] = useState<Date | undefined>(() => new Date());
  const [month, setMonth] = useState<Date>(() => new Date());
  const [timeValue, setTimeValue] = useState("12:00:00");

  const handleDayPickerSelect = (selectedDate: Date | undefined) => {
    setDate(selectedDate);
    if (selectedDate) {
      setMonth(selectedDate);
    }
  };

  const handleTimeChange = (e: React.ChangeEvent<HTMLInputElement>) => {
    setTimeValue(e.target.value);
  };

  return (
    <div className="flex flex-col gap-2">
      <Calendar
        mode="single"
        month={month}
        onMonthChange={setMonth}
        onSelect={handleDayPickerSelect}
        selected={date}
      />
      <Field className="flex-row items-center gap-3">
        <FieldLabel className="whitespace-nowrap text-xs">
          Enter time
        </FieldLabel>
        <InputGroup className="grow">
          <InputGroupInput
            aria-label="Select time"
            className="*:[input]:[&::-webkit-calendar-picker-indicator]:hidden *:[input]:[&::-webkit-calendar-picker-indicator]:appearance-none"
            onChange={handleTimeChange}
            step="1"
            type="time"
            value={timeValue}
          />
          <InputGroupAddon>
            <ClockIcon aria-hidden="true" />
          </InputGroupAddon>
        </InputGroup>
      </Field>
    </div>
  );
}
```
