Calendar
支持单选、多选与日期范围的 Liquid Glass 公历选择器,提供同心圆角层次、减透明回退与可组合标题栏。
Liquid Glass Calendar 是支持 single(默认)、multiple 与 range 三种选择模式的公历组件。容器采用同心圆角、内描边高光与半透明层次(在降低透明度或高对比模式下自动回退为不透明表面),且不叠加嵌套玻璃材质,可安全嵌入 Date Picker 浮层中使用。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<proto-ui-liquid-glass-calendar-root id="calendar-caption-demo">
<proto-ui-liquid-glass-calendar-caption>
<proto-ui-liquid-glass-calendar-previous
aria-label="Previous month"
>
‹
</proto-ui-liquid-glass-calendar-previous>
<proto-ui-liquid-glass-select-root id="calendar-month">
<!-- Month Select -->
</proto-ui-liquid-glass-select-root>
<proto-ui-liquid-glass-select-root id="calendar-year">
<!-- Year Select -->
</proto-ui-liquid-glass-select-root>
<proto-ui-liquid-glass-calendar-next aria-label="Next month">
›
</proto-ui-liquid-glass-calendar-next>
</proto-ui-liquid-glass-calendar-caption>
<proto-ui-liquid-glass-calendar-heading
class="sr-only"
></proto-ui-liquid-glass-calendar-heading>
<proto-ui-liquid-glass-calendar-grid>
<proto-ui-liquid-glass-calendar-weekdays>
<!-- 7 Weekday slots with offset 0..6 -->
</proto-ui-liquid-glass-calendar-weekdays>
<!-- 6 Row slots (index 0..5), each with 7 Day slots (offset 0..41) -->
</proto-ui-liquid-glass-calendar-grid>
</proto-ui-liquid-glass-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-liquid-glass/calendar 引入。
import { CalendarRoot, CalendarCaption, CalendarPrevious, CalendarHeading, CalendarNext, CalendarGrid, CalendarWeekdays, CalendarWeekday, CalendarRow, CalendarDay,} from '@proto.ui/prototypes-liquid-glass/calendar';
export function LiquidGlassCalendarExample() { 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。 - 为避免玻璃叠玻璃(glass-on-glass),Calendar 本身作为内容层不注册额外的光学材质槽位;外层若由
Date Picker浮层承载,则由浮层独占单一 Liquid Glass 材质。 - 组件不主动读取系统时钟:请通过
today传入YYYY-MM-DD字符串标记今天(自动映射aria-current="date")。 direction="rtl"自动镜像左右方向键;可通过bindCalendarCaption(source, { month, year })将同族Select与 Calendar 的公开month/disabled及requestMonth联动(卸载时调用dispose())。
| 模式 | 受控 / 初始值属性 | 变更事件 |
|---|---|---|
single | value / defaultValue(YYYY-MM-DD) | onValueChange({ value }) |
multiple | values / defaultValues(readonly string[]) | onValuesChange({ values }) |
range | range / defaultRange({ from?, to? }) | onRangeChange({ range }) |
采用同心 rounded-2xl / rounded-xl 层次与清晰悬停/按压反馈的单日日历。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<proto-ui-liquid-glass-calendar-root id="calendar-basic">
<proto-ui-liquid-glass-calendar-caption>
<proto-ui-liquid-glass-calendar-previous
aria-label="Previous month"
>
‹
</proto-ui-liquid-glass-calendar-previous>
<proto-ui-liquid-glass-calendar-heading></proto-ui-liquid-glass-calendar-heading>
<proto-ui-liquid-glass-calendar-next aria-label="Next month">
›
</proto-ui-liquid-glass-calendar-next>
</proto-ui-liquid-glass-calendar-caption>
<proto-ui-liquid-glass-calendar-grid>
<proto-ui-liquid-glass-calendar-weekdays>
<!-- 7 Weekday slots with offset 0..6 -->
</proto-ui-liquid-glass-calendar-weekdays>
<!-- 6 Row slots (index 0..5), each with 7 Day slots (offset 0..41) -->
</proto-ui-liquid-glass-calendar-grid>
</proto-ui-liquid-glass-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-liquid-glass-calendar-root id="calendar-range">
<proto-ui-liquid-glass-calendar-caption>
<proto-ui-liquid-glass-calendar-previous
aria-label="Previous month"
>
‹
</proto-ui-liquid-glass-calendar-previous>
<proto-ui-liquid-glass-calendar-heading></proto-ui-liquid-glass-calendar-heading>
<proto-ui-liquid-glass-calendar-next aria-label="Next month">
›
</proto-ui-liquid-glass-calendar-next>
</proto-ui-liquid-glass-calendar-caption>
<proto-ui-liquid-glass-calendar-grid>
<proto-ui-liquid-glass-calendar-weekdays>
<!-- 7 Weekday slots with offset 0..6 -->
</proto-ui-liquid-glass-calendar-weekdays>
<!-- 6 Row slots (index 0..5), each with 7 Day slots (offset 0..41) -->
</proto-ui-liquid-glass-calendar-grid>
</proto-ui-liquid-glass-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-liquid-glass-calendar-root
id="calendar-range-constrained"
>
<!-- Range (1–14 nights) -->
</proto-ui-liquid-glass-calendar-root>
<proto-ui-liquid-glass-calendar-root id="calendar-multiple">
<!-- Multiple (max 4 dates) -->
</proto-ui-liquid-glass-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 与同族 Liquid Glass Button 快捷选择日期。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<div class="inline-flex flex-col items-center gap-3">
<proto-ui-liquid-glass-calendar-root id="calendar-presets">
<!-- Caption + 6-week fixed Grid -->
</proto-ui-liquid-glass-calendar-root>
<div class="flex max-w-[300px] flex-wrap gap-2">
<proto-ui-liquid-glass-button data-offset="0">
Today
</proto-ui-liquid-glass-button>
<proto-ui-liquid-glass-button data-offset="1">
Tomorrow
</proto-ui-liquid-glass-button>
<proto-ui-liquid-glass-button data-offset="3">
In 3 days
</proto-ui-liquid-glass-button>
<proto-ui-liquid-glass-button data-offset="7">
In a week
</proto-ui-liquid-glass-button>
<proto-ui-liquid-glass-button data-offset="14">
In 2 weeks
</proto-ui-liquid-glass-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-liquid-glass-calendar-root id="calendar-booked">
<!-- Caption + Grid -->
</proto-ui-liquid-glass-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-liquid-glass-calendar-root id="calendar-rtl">
<!-- Caption + Grid -->
</proto-ui-liquid-glass-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。