Calendar
DayPicker v10의 날짜 계산과 키보드 탐색을 유지합니다. 선택한 날짜는 inset으로, 기간의 중간 날짜는 연결된 표면으로 구분합니다.
@neumorphism-ui/calendar미리보기
날짜 선택
2026년 9월
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
기간 선택
2026년 9월
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
설치
설치: calendar
npx shadcn@latest add @neumorphism-ui/calendarCLI가 npm 의존성, base 토큰, utils와 컴포넌트 소스를 순서대로 확인하고 설치합니다.
Registry를 처음 사용한다면 namespace 설정 을 먼저 완료하세요.
사용법
사용법: 설치
npx shadcn@latest add @neumorphism-ui/calendar @neumorphism-ui/buttonImport
Calendar import 코드
"use client";
import * as React from "react";
import type { DateRange } from "@daypicker/react";
import { enUS, ko, ja, zhCN } from "@daypicker/react/locale";
import { Calendar } from "@/components/ui/calendar";
import { Button } from "@/components/ui/button";Example
Calendar 사용 코드
const locales = { en: enUS, ko, ja, zh: zhCN };
const copy = {
en: { single: "Single date", range: "Date range", clear: "Clear range", empty: "No date selected" },
ko: { single: "날짜 선택", range: "기간 선택", clear: "기간 초기화", empty: "선택한 날짜 없음" },
ja: { single: "日付選択", range: "期間選択", clear: "期間をクリア", empty: "日付未選択" },
zh: { single: "选择日期", range: "选择范围", clear: "清除范围", empty: "未选择日期" },
};
function stamp(date: Date) {
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
}
export default function CalendarExample({ locale = "ko" }: { locale?: keyof typeof copy }) {
const text = copy[locale];
const [date, setDate] = React.useState<Date | undefined>(new Date(2026, 8, 15));
const [range, setRange] = React.useState<DateRange | undefined>({ from: new Date(2026, 8, 12), to: new Date(2026, 8, 17) });
return <div className="flex max-w-full flex-wrap items-start gap-6">
<section data-calendar="single" aria-label={text.single} className="grid max-w-full gap-3"><h3 className="text-sm font-semibold">{text.single}</h3><Calendar mode="single" selected={date} onSelect={setDate} defaultMonth={new Date(2026, 8)} today={new Date(2026, 8, 15)} disabled={new Date(2026, 8, 20)} locale={locales[locale]} /><output aria-live="polite" data-testid="calendar-value" className="text-sm text-[var(--muted-foreground)]">{date ? stamp(date) : text.empty}</output></section>
<section data-calendar="range" aria-label={text.range} className="grid max-w-full gap-3"><h3 className="text-sm font-semibold">{text.range}</h3><Calendar mode="range" selected={range} onSelect={setRange} defaultMonth={new Date(2026, 8)} today={new Date(2026, 8, 15)} locale={locales[locale]} /><output aria-live="polite" data-testid="calendar-range" className="text-sm text-[var(--muted-foreground)]">{range?.from ? `${stamp(range.from)} / ${range.to ? stamp(range.to) : "…"}` : text.empty}</output><Button size="sm" variant="ghost" className="w-fit justify-self-start" onClick={() => setRange(undefined)}>{text.clear}</Button></section>
</div>;
}API 레퍼런스
| 컴포넌트 | 속성 | 타입 | 기본값 | 설명 |
|---|---|---|---|---|
Calendar | mode | "single" | "multiple" | "range" | — | 날짜 선택 방식을 지정합니다. |
Calendar | selected / onSelect | Date | Date[] | DateRange / callback | — | 선택 값과 변경 콜백을 연결합니다. |
Calendar | disabled / locale / startMonth / endMonth | DayPickerProps | — | 비활성 날짜, 언어, 이동 가능한 월을 지정합니다. |
접근성
- 01
방향키로 날짜를 이동하고 Enter 또는 Space로 선택합니다.
- 02
기간의 시작·끝, 오늘, 비활성 날짜를 별도로 표시합니다. 라이브러리의 접근성 라벨을 유지하세요.