Calendar
A month grid for picking a date or a range.
In Dense data
See it live
npm run storybookWhen to use it
In Dense data: Date ranges for reports.
- Use it when: Dates near today, ranges, or when the day of the week matters.
- Not when: A date people know by heart, such as a birth date: typed fields are faster.
Instead:
- Date picker: A calendar opened from a field, in a popover.
- Input: A known date typed in.
Words
- Lead with the object, then the state: "Alert 2041 contained."
- Use numbers, not words for numbers.
- One verb per button. No "please", no exclamation marks.
- Use: Investigate, Filter, Assign, Escalated, Resolved. Avoid: Oops, Awesome, Please, Simply.
The labels components use, from the voice tokens:
content.action.commit: Savecontent.action.cancel: Cancelcontent.action.destroy: Deletecontent.action.retry: Retrycontent.action.empty-action: Change filters
See Voice and tone for the whole voice.
Accessibility and keyboard
| Keyboard | What happens | Not |
|---|---|---|
| undefined | Arrow keys move between days; Page Up and Page Down change month. | undefined |
Test before you ship:
- It is a grid; the selected and today's dates are announced. undefined
Use it in code
npx open-ds add calendar
The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.
Tokens it reads
Calendar reads 31 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Calendar's tokens to change Calendar alone.
Dense data decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.
| Part | Its token and the semantic it aliases | Value |
|---|---|---|
| Calendar | ||
| Fill Changes with theme | component.calendar.backgroundcolor.surface.canvasvar(--calendar-background) | Lightslate.light.50:#F7F8FADarkslate.dark.0:#0D1117 |
| Padding | component.calendar.paddingcomponent-spacing-map.x3var(--calendar-padding) | space.12:0.75rem |
| Gap | component.calendar.gapspace.gap.groupvar(--calendar-gap) | space.16:1rem |
| Gap 2 | component.calendar.gap-2space.gap.tightvar(--calendar-gap-2) | space.4:0.25rem |
| Disabled opacity disabled when disabled | component.calendar.disabled-opacity-disabledopacity.disabledvar(--calendar-disabled-opacity-disabled) | opacity.40:0.4 |
| Gap 3 | component.calendar.gap-3component-spacing-map.x2var(--calendar-gap-3) | space.8:0.5rem |
| Text size | component.calendar.font-sizetype.body.font-sizevar(--calendar-font-size) | font.size.14:0.875rem |
| Weight | component.calendar.font-weighttype.label.font-weightvar(--calendar-font-weight) | font.weight.500:500 |
| Corner | component.calendar.radiusradius.controlvar(--calendar-radius) | radius.2:0.125rem |
| Border Changes with theme | component.calendar.bordercolor.border.strongvar(--calendar-border) | Lightslate.light.500:#6B7585Darkslate.dark.400:#969FAD |
| Shadow | component.calendar.shadowelevation.cardvar(--calendar-shadow) | shadow.none |
| Border 2 Changes with theme | component.calendar.border-2color.border.focusvar(--calendar-border-2) | Lightviolet.light.600:#4B3FD9Darkviolet.dark.600:#A9A3F6 |
| Focus | component.calendar.focusborder-width.focusvar(--calendar-focus) | border-width.2:2px |
| Focus ring Changes with theme | component.calendar.focus-ringcolor.border.focusvar(--calendar-focus-ring) | Lightviolet.light.600:#4B3FD9Darkviolet.dark.600:#A9A3F6 |
| Focus ring offset Changes with theme | component.calendar.focus-ring-offsetcolor.surface.canvasvar(--calendar-focus-ring-offset) | Lightslate.light.50:#F7F8FADarkslate.dark.0:#0D1117 |
| Background 2 Changes with theme | component.calendar.background-2color.surface.raisedvar(--calendar-background-2) | Lightslate.light.0:#FFFFFFDarkslate.dark.100:#262D38 |
| Height | component.calendar.heightsize.control.defaultvar(--calendar-height) | size.32:2rem |
| Padding right | component.calendar.padding-rightcomponent-spacing-map.x1var(--calendar-padding-right) | space.4:0.25rem |
| Padding left | component.calendar.padding-leftcomponent-spacing-map.x2var(--calendar-padding-left) | space.8:0.5rem |
| Text Changes with theme | component.calendar.labelcolor.text.mutedvar(--calendar-label) | Lightslate.light.600:#535D6DDarkslate.dark.400:#969FAD |
| Font weight 2 | component.calendar.font-weight-2type.body.font-weightvar(--calendar-font-weight-2) | font.weight.400:400 |
| Background 3 Changes with theme | component.calendar.background-3color.surface.sunkenvar(--calendar-background-3) | Lightslate.light.100:#EEF1F5Darkslate.dark.100:#262D38 |
| Label 2 Changes with theme | component.calendar.label-2color.text.primaryvar(--calendar-label-2) | Lightslate.light.900:#161B23Darkslate.dark.900:#F7F8FA |
| Label selected Changes with theme when selected | component.calendar.label-selectedcolor.text.mutedvar(--calendar-label-selected) | Lightslate.light.600:#535D6DDarkslate.dark.400:#969FAD |
| Disabled opacity | component.calendar.disabled-opacityopacity.disabledvar(--calendar-disabled-opacity) | opacity.40:0.4 |
| Icon size | component.calendar.icon-sizesize.iconvar(--calendar-icon-size) | size.16:1rem |
| Background 4 Changes with theme | component.calendar.background-4color.action.primaryvar(--calendar-background-4) | Lightviolet.light.600:#4B3FD9Darkviolet.dark.600:#A9A3F6 |
| Label 3 Changes with theme | component.calendar.label-3color.text.on-actionvar(--calendar-label-3) | Lightslate.light.0:#FFFFFFDarkslate.light.900:#161B23 |
| Background selected Changes with theme when selected | component.calendar.background-selectedcolor.action.primaryvar(--calendar-background-selected) | Lightviolet.light.600:#4B3FD9Darkviolet.dark.600:#A9A3F6 |
| Label selected 2 Changes with theme when selected | component.calendar.label-selected-2color.text.on-actionvar(--calendar-label-selected-2) | Lightslate.light.0:#FFFFFFDarkslate.light.900:#161B23 |
| Font size 2 | component.calendar.font-size-2type.caption.font-sizevar(--calendar-font-size-2) | font.size.12:0.75rem |
| From the system | ||
| Edge Changes with theme | color.border.default straight from the system, through --border | Lightslate.light.200 · #DDE2EADarkslate.dark.100 · #262D38 |
| Corner | radius.control straight from the system, through --radius-md | radius.2 · 0.125rem (2px) |