Calendar
Calendar (캘린더)
날짜를 고르는 캘린더 컴포넌트예요. 화면에 바로 펼쳐서 보여 줄 수도 있고(tiled), 팝업으로 띄울 수도 있어요. 단일 날짜부터 범위·다중·주 단위 선택까지 지원해요.
출처: 문서
본문
소개 (Intro)
캘린더 컴포넌트예요. 펼쳐서 보여 주거나(tiled) 팝업으로 표시할 수 있어요.
설치 (Install)
import { createApp } from 'vue'
import { Calendar } from '@nutui/nutui'
const app = createApp()
app.use(Calendar)
데모 (Demos)
아래 항목들은 원문 문서의 대화형 데모로 제공돼요.
- 단일 날짜 선택 (Select Single Date) —
demo: calendar single - 날짜 범위 선택 (Select Date Range) —
demo: calendar range - 다중 날짜 선택 (Select Multiple Date) —
demo: calendar multiple - 주 단위 선택 (Select Week) —
demo: calendar week - 비활성 날짜 커스터마이즈 (Customize the disable date) —
demo: calendar disabled - 단일 빠른 선택 (Quick Select Single) —
demo: calendar single-quick - 범위 빠른 선택 (Quick Select Range) —
demo: calendar range-quick - 커스텀 버튼 (Custom Button) —
demo: calendar custom - 펼쳐서 표시 (Tiled Display) —
demo: calendar tiled
주 단위 선택 (Select Week)
주 단위 선택을 켜면 한 주의 시작과 끝 날짜가 first-day-of-week에 따라 결정돼요. 예를 들어 first-day-of-week가 0이면 한 주의 시작은 일요일이고, 그 외의 경우에는 월요일이에요.
비활성 날짜 커스터마이즈 (Customize the disable date)
disabled-date 함수 콜백을 설정하면 특정 날짜를 선택할 수 없게 만들 수 있어요.
type이 range일 때 이 함수를 설정했다면, 선택 결과에서 비활성 날짜를 직접 걸러 내야 해요.
API
Props
| Attribute | Description | Type | Default |
|---|---|---|---|
| v-model:visible | whether to show | boolean | false |
| type | Calendar type :one range multiple week(V4.0.1) |
string | one |
| poppable | Whether to display the pop-up window | boolean | true |
| is-auto-back-fill | Automatic backfill | boolean | false |
| title | whether to show title | string | Calendar |
| default-value | Default value, select single date : string,other: string[] |
string | string[] | null |
| start-date | The start date | string | Today |
| end-date | The end date | string | 365 days from today |
| show-today | Whether to show today's mark | boolean | true |
| start-text | Range selection, start part of the text | string | Start |
| end-text | Range selection, end part of the text | string | End |
| confirm-text | Bottom confirm button text | string | Confirm |
| show-title | Whether to show the calendar title | boolean | true |
| show-sub-title | Whether to display the date title | boolean | true |
| to-date-animation | Whether to use scroll animation | boolean | true |
| first-day-of-week | Set the start day of week | 0-6 | 0 |
| disabled-date | A function that determines whether the date is disabled takes a year - month - day as an argument. A Boolean value should be returned. |
function | - |
Events
| Event | Description | Arguments |
|---|---|---|
| choose | Triggered after selection or by clicking the confirm button,Array of dates (including year, month, day and week) | (string | string[])[] |
| close | Triggered when closed | - |
| select | Triggered after click/select | (string | string[])[] |
Slots
| Name | Description |
|---|---|
| btn | Below the custom calendar header, you can add custom actions |
| day | Date information |
| top-info | Date top information |
| bottom-info | Date bottom information |
footer-infov4.1.6 |
Custom calendar Footer, replace confirm btn |
Methods (메서드)
ref로 Calendar 인스턴스를 얻은 다음 인스턴스 메서드를 호출할 수 있어요.
| Name | Description | Arguments |
|---|---|---|
| scrollToDate | Scroll to the month of the specified date:'2021-12-30' | string |
initPosition v4.0.1 |
Initialize scroll position |
Theming
CSS Variables
The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.
| Name | Default Value |
|---|---|
| --nut-calendar-primary-color | var(--nut-primary-color) |
| --nut-calendar-choose-color | var(--nut-primary-color) |
| --nut-calendar-choose-font-color | var(--nut-primary-color) |
| --nut-calendar-base-color | #333333 |
| --nut-calendar-disable-color | #d1d0d0 |
| --nut-calendar-base-font | var(--nut-font-size-3) |
| --nut-calendar-title-font | var(--nut-font-size-4) |
| --nut-calendar-title-font-weight | 500 |
| --nut-calendar-sub-title-font | var(--nut-font-size-2) |
| --nut-calendar-text-font | var(--nut-font-size-1) |
| --nut-calendar-day-font | 16px |
| --nut-calendar-day-active-border-radius | 0px |
| --nut-calendar-day-font-weight | 500 |
| --nut-calendar-day67-font-color | var(--nut-primary-color) |
| --nut-calendar-month-title-font-size | inherit |
더 알아보기 (Learn more)
- 원문 문서: Calendar — NutUI v4 영문 문서
- NutUI 저장소: jd-opensource/nutui