Calendar
A Gregorian calendar supporting single, multiple, and range date selection in classic Duostrap framed panel, gradient button, and table styling.
Duostrap Calendar provides single (default), multiple, and range date selection. As Duostrap did not ship a native calendar, this family extension applies its classic 4px framed surfaces, raised button gradients, and condensed table typography.
Preview
Section titled “Preview”<proto-ui-duostrap-calendar-root id="calendar-caption-demo">
<proto-ui-duostrap-calendar-caption>
<proto-ui-duostrap-calendar-previous
aria-label="Previous month"
>
‹
</proto-ui-duostrap-calendar-previous>
<proto-ui-duostrap-select-root id="calendar-month">
<!-- Month Select -->
</proto-ui-duostrap-select-root>
<proto-ui-duostrap-select-root id="calendar-year">
<!-- Year Select -->
</proto-ui-duostrap-select-root>
<proto-ui-duostrap-calendar-next aria-label="Next month">
›
</proto-ui-duostrap-calendar-next>
</proto-ui-duostrap-calendar-caption>
<proto-ui-duostrap-calendar-heading
class="sr-only"
></proto-ui-duostrap-calendar-heading>
<proto-ui-duostrap-calendar-grid>
<proto-ui-duostrap-calendar-weekdays>
<!-- 7 Weekday slots with offset 0..6 -->
</proto-ui-duostrap-calendar-weekdays>
<!-- 6 Row slots (index 0..5), each with 7 Day slots (offset 0..41) -->
</proto-ui-duostrap-calendar-grid>
</proto-ui-duostrap-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>Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases (@proto.ui/prototypes-duostrap/calendar).
import { CalendarRoot, CalendarCaption, CalendarPrevious, CalendarHeading, CalendarNext, CalendarGrid, CalendarWeekdays, CalendarWeekday, CalendarRow, CalendarDay,} from '@proto.ui/prototypes-duostrap/calendar';
export function BootstrapCalendarExample() { 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> );}Anatomy, clock ownership, and caption pickers
Section titled “Anatomy, clock ownership, and caption pickers”- Compose
Calendarfrom ten parts:Root,Caption,Heading,Previous,Next,Grid,Weekdays,Weekday,Row, andDay. - Dates use
YYYY-MM-DDand visible months useYYYY-MM, controllable independently. The grid renders 4–6 complete weeks by default; passfixedWeeks={true}to reserve 6 rows. - Calendar never reads the system clock directly: pass a
YYYY-MM-DDtodaystring from your host to highlight today (aria-current="date"). direction="rtl"mirrors Left/Right arrow keys automatically. Connect familySelectcontrols usingbindCalendarCaption(source, { month, year })(and calldispose()on teardown).
Selection modes
Section titled “Selection modes”| Mode | Controlled / initial props | Change event |
|---|---|---|
single | value / defaultValue (YYYY-MM-DD) | onValueChange({ value }) |
multiple | values / defaultValues (readonly string[]) | onValuesChange({ values }) |
range | range / defaultRange ({ from?, to? }) | onRangeChange({ range }) |
Examples
Section titled “Examples”A classic framed single-date calendar with .btn-primary selected paint.
<proto-ui-duostrap-calendar-root id="calendar-basic">
<proto-ui-duostrap-calendar-caption>
<proto-ui-duostrap-calendar-previous
aria-label="Previous month"
>
‹
</proto-ui-duostrap-calendar-previous>
<proto-ui-duostrap-calendar-heading></proto-ui-duostrap-calendar-heading>
<proto-ui-duostrap-calendar-next aria-label="Next month">
›
</proto-ui-duostrap-calendar-next>
</proto-ui-duostrap-calendar-caption>
<proto-ui-duostrap-calendar-grid>
<proto-ui-duostrap-calendar-weekdays>
<!-- 7 Weekday slots with offset 0..6 -->
</proto-ui-duostrap-calendar-weekdays>
<!-- 6 Row slots (index 0..5), each with 7 Day slots (offset 0..41) -->
</proto-ui-duostrap-calendar-grid>
</proto-ui-duostrap-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>Set mode="range" for joined 4px endpoint corners and classic Bootstrap info-blue span highlighting.
<proto-ui-duostrap-calendar-root id="calendar-range">
<proto-ui-duostrap-calendar-caption>
<proto-ui-duostrap-calendar-previous
aria-label="Previous month"
>
‹
</proto-ui-duostrap-calendar-previous>
<proto-ui-duostrap-calendar-heading></proto-ui-duostrap-calendar-heading>
<proto-ui-duostrap-calendar-next aria-label="Next month">
›
</proto-ui-duostrap-calendar-next>
</proto-ui-duostrap-calendar-caption>
<proto-ui-duostrap-calendar-grid>
<proto-ui-duostrap-calendar-weekdays>
<!-- 7 Weekday slots with offset 0..6 -->
</proto-ui-duostrap-calendar-weekdays>
<!-- 6 Row slots (index 0..5), each with 7 Day slots (offset 0..41) -->
</proto-ui-duostrap-calendar-grid>
</proto-ui-duostrap-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>Multiple and range selection
Section titled “Multiple and range selection”Combine min, max, unavailable, minNights, maxNights, and maxSelected to constrain selections.
<div class="flex flex-wrap items-start gap-8">
<proto-ui-duostrap-calendar-root id="calendar-range-constrained">
<!-- Range (1–14 nights) -->
</proto-ui-duostrap-calendar-root>
<proto-ui-duostrap-calendar-root id="calendar-multiple">
<!-- Multiple (max 4 dates) -->
</proto-ui-duostrap-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>Presets
Section titled “Presets”Pair controlled value, month, and fixedWeeks with family Button actions.
<div class="inline-flex flex-col items-center gap-3">
<proto-ui-duostrap-calendar-root id="calendar-presets">
<!-- Caption + 6-week fixed Grid -->
</proto-ui-duostrap-calendar-root>
<div class="flex max-w-[300px] flex-wrap gap-2">
<proto-ui-duostrap-button data-offset="0">
Today
</proto-ui-duostrap-button>
<proto-ui-duostrap-button data-offset="1">
Tomorrow
</proto-ui-duostrap-button>
<proto-ui-duostrap-button data-offset="3">
In 3 days
</proto-ui-duostrap-button>
<proto-ui-duostrap-button data-offset="7">
In a week
</proto-ui-duostrap-button>
<proto-ui-duostrap-button data-offset="14">
In 2 weeks
</proto-ui-duostrap-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>Booked dates
Section titled “Booked dates”Use unavailable along with min and max to disable booked date ranges.
<proto-ui-duostrap-calendar-root id="calendar-booked">
<!-- Caption + Grid -->
</proto-ui-duostrap-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>Set direction="rtl", locale="ar-SA", and weekStartsOn={6} for RTL rendering and mirrored keyboard navigation.
<proto-ui-duostrap-calendar-root id="calendar-rtl">
<!-- Caption + Grid -->
</proto-ui-duostrap-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>| Prop | Type | Default |
|---|---|---|
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' |
Sub-part props
Section titled “Sub-part props”| Part / Prop | Type | Default |
|---|---|---|
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 |
Events, methods, and exposed states
Section titled “Events, methods, and exposed states”- Events (Root):
onValueChange({ value }),onValuesChange({ values }),onRangeChange({ range }),onMonthChange({ month }). - Methods (Root):
requestValue(date),requestValues(dates),requestRange(range),requestMonth(month),getValues(),getRange(). - Exposed states: Root exposes
value,mode,selectedCount,rangeComplete,month,weekCount,disabled,direction; Day exposesdate,selected,rangeStart,rangeEnd,rangeMiddle,rangePending,today,outside,disabled,hidden.