KCalendar
A container that displays data in calendar form.
Install
bash
pnpm add @ikun-ui/calendar
bash
yarn add @ikun-ui/calendar
bash
npm install @ikun-ui/calendar
Basic usage
A basic calendar component with Year/Month switch.
Card mode
Nested inside a container element for rendering in limited space.
Custom render
Custom rendering via slots.
Calendar Props
Name | Type | Default | Description |
---|---|---|---|
mode | month | year | year | The display mode of the calendar. |
value | Dayjs | - | The current selected date. |
fullscreen | boolean | true | Whether to display in full-screen. |
validRange | [Dayjs, Dayjs] | [] | To set valid range. |
disabledDate | (currentDate: Dayjs) => boolean | - | Function that specifies the dates that cannot be selected. |
locale | object | default | The calendar's locale. |
cls | string | '' | Additional class for component |
attrs | any | {} | Additional attributes |
Calendar Events
Name | Description | Type |
---|---|---|
select | Callback for when a date is selected, include source info. | (v: { date: Dayjs, source: 'month' | 'year' })=> void |
panelChange | Callback for when panel changes. | (v: { date: Dayjs, mode: 'month' | 'year' })=> void |
Calendar Slots
Name | Description |
---|---|
header | Content of the header. |
monthFullCell | Content of the month cell, the content will override the cell |
monthCell | Content of the month cell, the content will be appended to the cell |
dateFullCell | Content of the date cell, the content will override the cell. |
dateCell | Content of the date cell, the content will be appended to the cell |
Header slot params
typescript
interface SelectOption {
label: string;
value: string;
id: string;
}
typescript
interface HeaderSlotPa {
// Current mode
mode: 'year' | 'month';
// Select callback of ‘year’
handleYearSelect: (v: { detail: SelectOption }) => void;
// Select callback of ‘month’
handleMonthSelect: (v: { detail: SelectOption }) => void;
// Switch mode callback
handleMYClick: (v: 'year' | 'month') => void;
// Select rendering data of ‘year’
yearList: Array<SelectOption>;
// Select rendering data of ‘month’
monthList: Array<SelectOption>;
// The value of the year selector
year: SelectOption;
// The value of the month selector
month: SelectOption;
}
dateCell slot params
typescript
interface dateCellSlotPa {
// Data used for rendering
date: { instance: Dayjs };
}
dateFullCell slot params
typescript
interface dateFullCellSlotPa {
// Data used for rendering
date: { instance: Dayjs };
}
MonthCell slot params
typescript
interface monthCellSlotPa {
// Data used for rendering
month: Dayjs;
}
MonthFullCell slot params
typescript
interface monthFullCellSlotPa {
// Data used for rendering
month: Dayjs;
}