달력
달력 (Calendar)
daisyUI는 여러 인기 달력 라이브러리를 위한 스타일을 제공해요. 여러분의 필요에 맞는 걸 고르면 됩니다.
출처: 문서
본문
Calendar는 서로 다른 달력 라이브러리를 위한 스타일을 포함해요.
| 클래스명 | 타입 | 설명 |
|---|---|---|
| cally | 컴포넌트 | Cally 웹 컴포넌트용 |
| react-day-picker | 컴포넌트 | DayPicker 컴포넌트용 |
| vc | 컴포넌트 | Vanilla Calendar Pro용 |
네이티브 HTML <input type="date">를 사용해서 데이트 피커를 만들 수도 있어요.
daisyUI는 3개의 달력 라이브러리를 지원해요
daisyUI는 인기 있는 3개의 달력 라이브러리 스타일을 포함하고 있어요. 여러분의 필요에 맞춰 아무거나 골라 쓰면 됩니다. 이 라이브러리들의 CSS 파일을 import할 필요는 없어요. daisyUI가 자동으로 스타일을 입혀 줍니다.
- Cally 웹 컴포넌트 - 어디서나 동작해요
- React Day picker - React 전용
- Vanilla Calendar Pro - 어디서나 동작해요
1. Cally Calendar
Cally는 웹 컴포넌트 달력이라 어디서나 동작해요.
Cally 달력 예시
daisyUI 스타일을 사용한 예시예요.
<!--
* Import Cally web component from CDN
<script type="module" src="https://unpkg.com/cally"></script>
* Or install as a dependency:
npm i cally
* and import it in JS
import "cally";
-->
<calendar-date class="$$cally bg-base-100 border border-base-300 shadow-lg rounded-box">
<svg aria-label="Previous" class="fill-current size-4" slot="previous" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M15.75 19.5 8.25 12l7.5-7.5"></path></svg>
<svg aria-label="Next" class="fill-current size-4" slot="next" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="m8.25 4.5 7.5 7.5-7.5 7.5"></path></svg>
<calendar-month></calendar-month>
</calendar-date>
Cally 데이트 피커 예시
daisyUI 스타일과 daisyUI dropdown을 함께 사용한 예시예요.
<!--
* Import Cally web component from CDN
<script type="module" src="https://unpkg.com/cally"></script>
* Or install as a dependency:
npm i cally
* and import it in JS
import "cally";
-->
<button popovertarget="cally-popover1" class="$$input" id="cally1" style="anchor-name:--cally1">
Pick a date
</button>
<div popover id="cally-popover1" class="$$dropdown bg-base-100 rounded-box shadow-lg" style="position-anchor:--cally1">
<calendar-date class="$$cally" onchange="document.getElementById('cally1').innerText = this.value">
<svg aria-label="Previous" class="fill-current size-4" slot="previous" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15.75 19.5 8.25 12l7.5-7.5"></path></svg>
<svg aria-label="Next" class="fill-current size-4" slot="next" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m8.25 4.5 7.5 7.5-7.5 7.5"></path></svg>
<calendar-month></calendar-month>
</calendar-date>
</div>
2. React Day Picker calendar
React Day Picker는 React용 유연한 데이트 피커 컴포넌트예요.
React Day Picker 예시
npm i react-day-picker
import { useState } from "react";
import { DayPicker } from "react-day-picker";
export default function App() {
const [date, setDate] = useState<Date | undefined>();
return (
<>
<button popoverTarget="rdp-popover" className="$$input" style={{ anchorName: "--rdp" } as React.CSSProperties}>
{date ? date.toLocaleDateString() : "Pick a date"}
</button>
<div popover="auto" id="rdp-popover" className="$$dropdown" style={{ positionAnchor: "--rdp" } as React.CSSProperties}>
<DayPicker className="$$react-day-picker" mode="single" selected={date} onSelect={setDate} />
</div>
</>
);
}
3. Vanilla Calendar Pro
Vanilla Calendar Pro는 JavaScript 달력 라이브러리예요.
Vanilla Calendar Pro 예시
npm i vanilla-calendar-pro
<div id="calendar" class="$$vc"></div>
import { Calendar } from "vanilla-calendar-pro"
const calendar = new Calendar("#calendar")
calendar.init()
Vanilla Calendar Pro CDN 예시
<script src="https://cdn.jsdelivr.net/npm/vanilla-calendar-pro/index.js" defer></script>
<div id="calendar" class="$$vc"></div>
<script>
document.addEventListener("DOMContentLoaded", () => {
const { Calendar } = window.VanillaCalendarPro
const calendar = new Calendar("#calendar")
calendar.init()
})
</script>
더 알아보기 (Learn more)
daisyUI의 달력 컴포넌트와 3가지 지원 라이브러리(Cally, React Day Picker, Vanilla Calendar Pro)에 대해 더 자세히 알아보세요. 공식 문서에서 , 같은 컴포넌트와 데이트 피커 팝오버 구성 방법을 확인할 수 있어요.