Calendar
支持单选、多选与日期范围选择的 Brutalist 公历日历组件,采用 2px 硬边框、自适应硬阴影面板与可组合年月标题栏。
Brutalist Calendar 是支持单选(single)、多选(multiple)与日期范围(range)的公历控件,采用 36px 日期格、28px 翻月按钮、2px 硬边框与亮暗自适应 4px 硬阴影面板设计。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<proto-ui-brutalist-calendar-root id="calendar-caption-demo">
<proto-ui-brutalist-calendar-caption>
<proto-ui-brutalist-calendar-previous
aria-label="Previous month"
>
‹
</proto-ui-brutalist-calendar-previous>
<proto-ui-brutalist-select-root id="calendar-month">
<!-- Month Select -->
</proto-ui-brutalist-select-root>
<proto-ui-brutalist-select-root id="calendar-year">
<!-- Year Select -->
</proto-ui-brutalist-select-root>
<proto-ui-brutalist-calendar-next aria-label="Next month">
›
</proto-ui-brutalist-calendar-next>
</proto-ui-brutalist-calendar-caption>
<proto-ui-brutalist-calendar-heading
class="sr-only"
></proto-ui-brutalist-calendar-heading>
<proto-ui-brutalist-calendar-grid>
<proto-ui-brutalist-calendar-weekdays>
<!-- 7 Weekday slots with offset 0..6 -->
</proto-ui-brutalist-calendar-weekdays>
<!-- 6 Row slots (index 0..5), each with 7 Day slots (offset 0..41) -->
</proto-ui-brutalist-calendar-grid>
</proto-ui-brutalist-calendar-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
import { bindCalendarCaption } from '@proto.ui/prototypes-base/calendar';
const root = document.querySelector('#calendar-caption-demo');
setElementProps(root, {
locale: 'en-US',
weekStartsOn: 0,
today: '2026-10-08',
});
// Connect month/year Select controls via bindCalendarCaption(source, { month, year })
</script>将于 0.3.0-rc.1 及后续版本中提供;可在工作区中直接从 @proto.ui/prototypes-brutalist/calendar 引入。
import { CalendarRoot, CalendarCaption, CalendarPrevious, CalendarHeading, CalendarNext, CalendarGrid, CalendarWeekdays, CalendarWeekday, CalendarRow, CalendarDay,} from '@proto.ui/prototypes-brutalist/calendar';
export function BrutalistCalendarExample() { return ( <CalendarRoot mode="single" defaultMonth="2026-10" defaultValue="2026-10-12" today="2026-10-08"> <CalendarCaption> <CalendarPrevious a11yLabel="Previous month" /> <CalendarHeading /> <CalendarNext a11yLabel="Next month" /> </CalendarCaption> <CalendarGrid> <CalendarWeekdays> {Array.from({ length: 7 }, (_, offset) => ( <CalendarWeekday key={offset} offset={offset} /> ))} </CalendarWeekdays> {Array.from({ length: 6 }, (_, row) => ( <CalendarRow key={row} index={row}> {Array.from({ length: 7 }, (_, col) => ( <CalendarDay key={col} offset={row * 7 + col} /> ))} </CalendarRow> ))} </CalendarGrid> </CalendarRoot> );}结构、键盘导航与年月组合
Section titled “结构、键盘导航与年月组合”- Calendar 由十个部件组成:
Root、Caption、Heading、Previous、Next、Grid、Weekdays、Weekday、Row与Day。 - 默认渲染覆盖当月所需的 4–6 周,设置
fixedWeeks={true}固定渲染 6 周;多余行与日期格自动隐藏并移出焦点路径。 - 不直接读取系统时钟:请由宿主传入
YYYY-MM-DD格式的today高亮今天(自动输出aria-current="date")。 direction="rtl"自动镜像左右方向键;如需在Caption中嵌入月份/年份下拉选择,可使用bindCalendarCaption(source, { month, year })与同族Select联动(退出时调用dispose())。
| 模式 | 受控值 / 初始值 | 变更事件 |
|---|---|---|
single | value / defaultValue:YYYY-MM-DD | onValueChange({ value }) |
multiple | values / defaultValues:readonly string[] | onValuesChange({ values }) |
range | range / defaultRange:{ from?, to? } | onRangeChange({ range }) |
使用默认月份标题栏的单日选择视图。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<proto-ui-brutalist-calendar-root id="calendar-basic">
<proto-ui-brutalist-calendar-caption>
<proto-ui-brutalist-calendar-previous
aria-label="Previous month"
>
‹
</proto-ui-brutalist-calendar-previous>
<proto-ui-brutalist-calendar-heading></proto-ui-brutalist-calendar-heading>
<proto-ui-brutalist-calendar-next aria-label="Next month">
›
</proto-ui-brutalist-calendar-next>
</proto-ui-brutalist-calendar-caption>
<proto-ui-brutalist-calendar-grid>
<proto-ui-brutalist-calendar-weekdays>
<!-- 7 Weekday slots with offset 0..6 -->
</proto-ui-brutalist-calendar-weekdays>
<!-- 6 Row slots (index 0..5), each with 7 Day slots (offset 0..41) -->
</proto-ui-brutalist-calendar-grid>
</proto-ui-brutalist-calendar-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#calendar-basic'), {
mode: 'single',
defaultMonth: '2026-10',
defaultValue: '2026-10-12',
today: '2026-10-08',
});
</script>mode="range" 提供首尾圆角衔接与连续中段高亮。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<proto-ui-brutalist-calendar-root id="calendar-range">
<proto-ui-brutalist-calendar-caption>
<proto-ui-brutalist-calendar-previous
aria-label="Previous month"
>
‹
</proto-ui-brutalist-calendar-previous>
<proto-ui-brutalist-calendar-heading></proto-ui-brutalist-calendar-heading>
<proto-ui-brutalist-calendar-next aria-label="Next month">
›
</proto-ui-brutalist-calendar-next>
</proto-ui-brutalist-calendar-caption>
<proto-ui-brutalist-calendar-grid>
<proto-ui-brutalist-calendar-weekdays>
<!-- 7 Weekday slots with offset 0..6 -->
</proto-ui-brutalist-calendar-weekdays>
<!-- 6 Row slots (index 0..5), each with 7 Day slots (offset 0..41) -->
</proto-ui-brutalist-calendar-grid>
</proto-ui-brutalist-calendar-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#calendar-range'), {
mode: 'range',
defaultMonth: '2026-10',
defaultRange: { from: '2026-10-08', to: '2026-10-16' },
today: '2026-10-04',
});
</script>多选与范围约束
Section titled “多选与范围约束”结合 min、max、unavailable、minNights、maxNights 与 maxSelected 限制可选范围与数量。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<div class="flex flex-wrap items-start gap-8">
<proto-ui-brutalist-calendar-root id="calendar-range-constrained">
<!-- Range (1–14 nights) -->
</proto-ui-brutalist-calendar-root>
<proto-ui-brutalist-calendar-root id="calendar-multiple">
<!-- Multiple (max 4 dates) -->
</proto-ui-brutalist-calendar-root>
</div>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(
document.querySelector('#calendar-range-constrained'),
{
mode: 'range',
defaultMonth: '2026-10',
defaultRange: { from: '2026-10-10', to: '2026-10-14' },
min: '2026-10-01',
max: '2026-11-30',
unavailable: ['2026-10-18'],
minNights: 1,
maxNights: 14,
}
);
setElementProps(document.querySelector('#calendar-multiple'), {
mode: 'multiple',
defaultMonth: '2026-10',
defaultValues: ['2026-10-03', '2026-10-08', '2026-10-12'],
min: '2026-10-01',
max: '2026-11-30',
unavailable: ['2026-10-18'],
maxSelected: 4,
});
</script>配合受控 value / month、fixedWeeks 与同族 Button 快捷切换日期。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<div class="inline-flex flex-col items-center gap-3">
<proto-ui-brutalist-calendar-root id="calendar-presets">
<!-- Caption + 6-week fixed Grid -->
</proto-ui-brutalist-calendar-root>
<div class="flex max-w-[300px] flex-wrap gap-2">
<proto-ui-brutalist-button data-offset="0">
Today
</proto-ui-brutalist-button>
<proto-ui-brutalist-button data-offset="1">
Tomorrow
</proto-ui-brutalist-button>
<proto-ui-brutalist-button data-offset="3">
In 3 days
</proto-ui-brutalist-button>
<proto-ui-brutalist-button data-offset="7">
In a week
</proto-ui-brutalist-button>
<proto-ui-brutalist-button data-offset="14">
In 2 weeks
</proto-ui-brutalist-button>
</div>
</div>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#calendar-presets');
setElementProps(root, {
fixedWeeks: true,
value: '2026-10-12',
month: '2026-10',
today: '2026-10-10',
});
</script>已预订与不可用日期
Section titled “已预订与不可用日期”使用 unavailable 与 min / max 禁用不可预订日期区间。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<proto-ui-brutalist-calendar-root id="calendar-booked">
<!-- Caption + Grid -->
</proto-ui-brutalist-calendar-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#calendar-booked'), {
defaultMonth: '2026-10',
defaultValue: '2026-10-06',
today: '2026-10-06',
min: '2026-10-01',
max: '2026-10-31',
unavailable: [
'2026-10-12',
'2026-10-13',
'2026-10-14',
'2026-10-15',
'2026-10-16',
'2026-10-17',
'2026-10-18',
'2026-10-19',
'2026-10-20',
],
});
</script>从右到左(RTL)
Section titled “从右到左(RTL)”设置 direction="rtl"、locale="ar-SA" 与 weekStartsOn={6} 启用 RTL 布局与镜像键盘导航。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<proto-ui-brutalist-calendar-root id="calendar-rtl">
<!-- Caption + Grid -->
</proto-ui-brutalist-calendar-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#calendar-rtl'), {
defaultMonth: '2026-10',
defaultValue: '2026-10-12',
today: '2026-10-08',
locale: 'ar-SA',
direction: 'rtl',
weekStartsOn: 6,
a11yLabel: 'اختر تاريخاً',
});
</script>| 属性 | 类型 | 默认值 |
|---|---|---|
mode | 'single' 'multiple' 'range' | 'single' |
value | string | undefined |
defaultValue | string | '' |
values | readonly string[] | undefined |
defaultValues | readonly string[] | [] |
range | CalendarRange | undefined |
defaultRange | CalendarRange | {} |
minSelected | number | 0 |
maxSelected | number | undefined |
minNights | number | 0 |
maxNights | number | undefined |
month | string | undefined |
defaultMonth | string | undefined |
min | string | '' |
max | string | '' |
unavailable | readonly string[] | [] |
disabled | boolean | false |
readOnly | boolean | false |
weekStartsOn | number | 0 |
fixedWeeks | boolean | false |
a11yLabel | string | 'Calendar' |
today | string | '' |
locale | string | 'en-US' |
direction | 'ltr' 'rtl' | 'ltr' |
| 部件 / 属性 | 类型 | 默认值 |
|---|---|---|
Day.date | string | '' |
Day.offset | number | 0 |
Day.disabled | boolean | false |
Row.index | number | undefined |
Weekday.offset | number | 0 |
Caption.a11yLabel | string | 'Calendar navigation' |
Previous / Next.a11yLabel | string | 'Previous month' / 'Next month' |
Previous / Next.disabled | boolean | false |
事件、方法与暴露状态
Section titled “事件、方法与暴露状态”- 事件(Root):
onValueChange({ value })、onValuesChange({ values })、onRangeChange({ range })、onMonthChange({ month })。 - 方法(Root):
requestValue(date)、requestValues(dates)、requestRange(range)、requestMonth(month)、getValues()、getRange()。 - 暴露状态:Root 暴露
value、mode、selectedCount、rangeComplete、month、weekCount、disabled、direction;Day 暴露date、selected、rangeStart、rangeEnd、rangeMiddle、rangePending、today、outside、disabled、hidden。