Skip to content

Calendar ​

A neo-brutalist style calendar component built on v-calendar DatePicker, supporting single date and date range selection. It features the signature brutal style with thick borders and hard shadows, along with visual feedback for selected state, range state, and today highlight.

Demo ​

Preview

基础用法

M
T
W
T
F
S
S
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1

v-model 绑定(选中日期:未选择)

M
T
W
T
F
S
S
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1

日期范围选择(isRange)

点击选择起始日期,再点击选择结束日期
M
T
W
T
F
S
S
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1

禁用状态

M
T
W
T
F
S
S
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1

Installation ​

pnpm dlx brutx-vue@latest add calendar

Additional dependency required:

bash
pnpm add v-calendar

Usage ​

Single Date Selection ​

vue
<script setup>
import { ref } from 'vue'
import { Calendar } from 'brutx-ui-vue/calendar'

const date = ref(null)
</script>

<template>
    <Calendar v-model="date" />
</template>

Date Range Selection ​

vue
<script setup>
import { ref } from 'vue'
import { Calendar } from 'brutx-ui-vue/calendar'

const dateRange = ref(null)
</script>

<template>
    <Calendar v-model="dateRange" :is-range="true" />
</template>

Disabled State ​

vue
<template>
    <Calendar :disabled="true" />
</template>

Locale ​

Calendar reads the code from the locale pack provided through provideLocale. If the pack has no code, it uses zh-CN. Set locale to a v-calendar locale code to override the language for one calendar:

vue
<Calendar locale="en-US" />

API Reference ​

Calendar — Props
NameTypeDefaultDescription
modelValue
Nullable
Date | Date[] | null | undefined
undefined
The selected date, updated with v-model; single mode uses a Date, range mode uses an array containing the start and end dates, and an empty selection is null.
Details

Declared type

Date | Date[] | null | undefined

Literal values

  • null

Default value details

Resolved value
undefined

Source

Calendar.vue:32

packages/ui/src/components/calendar/Calendar.vue

isRange
boolean | undefined
false
Enables date-range selection; modelValue should represent the start and end dates.
Details

Declared type

boolean | undefined

Literal values

  • false
  • true

Default value details

Resolved value
false

Source

Calendar.vue:33

packages/ui/src/components/calendar/Calendar.vue

disabled
boolean | undefined
false
Disables date selection interaction in the calendar.
Details

Declared type

boolean | undefined

Literal values

  • false
  • true

Default value details

Resolved value
false

Source

Calendar.vue:34

packages/ui/src/components/calendar/Calendar.vue

class
string | undefined
undefined
CSS classes added to the calendar root container.
Details

Declared type

string | undefined

Default value details

Resolved value
undefined

Source

Calendar.vue:35

packages/ui/src/components/calendar/Calendar.vue

events
CalendarEvent[] | undefined
[]

Factory evaluated per instance

Provides calendar events to mark; each item has a date and title and may include custom fields.
Details

Declared type

CalendarEvent[] | undefined

Referenced types

CalendarEvent
Type definition — CalendarEvent
export interface CalendarEvent {
    date: Date | string
    title: string
    [key: string]: unknown
}

Default value details

Resolved value
[]

Source

Calendar.vue:36

packages/ui/src/components/calendar/Calendar.vue

eventRenderer
((event: CalendarEvent) => unknown) | undefined
undefined
Callback for customizing event display content; receives a CalendarEvent and returns renderable content.
Details

Declared type

((event: CalendarEvent) => unknown) | undefined

Referenced types

CalendarEvent
Type definition — CalendarEvent
export interface CalendarEvent {
    date: Date | string
    title: string
    [key: string]: unknown
}

Default value details

Resolved value
undefined

Source

Calendar.vue:37

packages/ui/src/components/calendar/Calendar.vue

mode
"default" | "card" | undefined
"default"
Sets how event markers are rendered: default uses dots and tooltips, while card uses calendar cards and badges.
Details

Declared type

"default" | "card" | undefined

Literal values

  • "card"
  • "default"

Default value details

Resolved value
"default"

Source

Calendar.vue:38

packages/ui/src/components/calendar/Calendar.vue

locale
string | undefined
undefined
The v-calendar locale code; defaults to the current useLocale() language-pack code, with zh-CN as the fallback.
Details

Declared type

string | undefined

Default value details

Resolved value
undefined

Source

Calendar.vue:40

packages/ui/src/components/calendar/Calendar.vue

retroHeader
boolean | undefined
false
Shows a retro wall-calendar header decoration; the decorative elements carry no accessibility semantics.
Details

Declared type

boolean | undefined

Literal values

  • false
  • true

Default value details

Resolved value
false

Source

Calendar.vue:42

packages/ui/src/components/calendar/Calendar.vue

Calendar — Events
NameSignature or typeDescription
@update:modelValue
[value: Date | Date[] | null]
Emits the updated date value when the user changes the selected date or range.
Details

Declared type

[value: Date | Date[] | null]

Literal values

  • null

Source

Calendar.vue

packages/ui/src/components/calendar/Calendar.vue

Slots ​

These slots are supported by the underlying v-calendar DatePicker and forwarded by Calendar for customizing the header and date cells:

SlotScopeDescription
header-prev-button—Custom previous month navigation button (defaults to ChevronLeft icon)
header-title{ title: string }Custom header title (defaults to bold uppercase display)
header-next-button—Custom next month navigation button (defaults to ChevronRight icon)
day-content{ day: object, dayProps: object, dayEvents: object }Custom date cell content

Event Markers ​

Use the events prop to mark events on the calendar. Two display modes are supported.

Data Type ​

ts
interface CalendarEvent {
    date: Date | string    // Event date
    title: string          // Event title
    [key: string]: unknown // Additional custom fields
}

When an event date is passed as a YYYY-MM-DD string, Calendar parses it as a local calendar date for that day instead of relying on native Date UTC/time-zone inference for date-only strings. Full datetime strings still use native Date / ISO datetime semantics; for cross-time-zone consistency, pass a Date object or a full ISO string with an explicit offset.

Default Mode ​

Dot indicators with Tooltip, ideal for calendars with fewer events:

vue
<script setup>
import { Calendar } from 'brutx-ui-vue/calendar'

const events = [
    { date: '2025-07-15', title: 'Team Meeting' },
    { date: '2025-07-20', title: 'Product Launch' },
    { date: '2025-07-20', title: 'Code Review' },
]
</script>

<template>
    <Calendar :events="events" />
</template>

Card Mode ​

Adaptive-height cards with capsule badges, ideal for calendars with many events:

vue
<script setup>
import { Calendar } from 'brutx-ui-vue/calendar'

const events = [
    { date: '2025-07-15', title: 'Team Meeting' },
    { date: '2025-07-20', title: 'Product Launch' },
    { date: '2025-07-20', title: 'Code Review' },
]
</script>

<template>
    <Calendar :events="events" mode="card" />
</template>

Custom Event Rendering ​

Use eventRenderer to customize how events are rendered:

vue
<script setup>
import { Calendar } from 'brutx-ui-vue/calendar'
import { h } from 'vue'

const events = [
    { date: '2025-07-15', title: 'Team Meeting', color: 'red' },
    { date: '2025-07-20', title: 'Product Launch', color: 'blue' },
]

function renderEvent(event) {
    return h('span', { style: { color: event.color } }, event.title)
}
</script>

<template>
    <Calendar :events="events" :event-renderer="renderEvent" />
</template>

Accessibility ​

  • Keyboard Interaction: Supported via v-calendar's built-in support; use arrow keys to navigate between dates, Enter / Space to select a date, Escape to close the popup panel (if applicable)
  • ARIA Attributes: v-calendar automatically manages semantic attributes such as role="grid" and role="gridcell" for the date grid
  • Focus Management: Navigation buttons can be focused via Tab key, and date cells support arrow key navigation

Brute force builds.