Calendar
A month grid for picking a date or a range.
In Accessible first
See it live
npm run storybookWhen to use it
In Accessible first: Dates near today, such as a health appointment. Not a date people know by heart, like a birth date.
- 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
- Use common words. Explain any term you must use.
- One idea per sentence. Put the action first.
- Never blame the person.
- Use: Continue, Change, Start, You. Avoid: Invalid, Utilise, Submit, Error code.
The labels components use, from the voice tokens:
content.action.commit: Continuecontent.action.cancel: Go backcontent.action.destroy: Deletecontent.action.retry: Try againcontent.action.empty-action: Start a new application
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.
Accessible first 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) | Lightgray.light.50:#F7F7F7Darkgray.dark.0:#0A0A0A |
| Padding | component.calendar.paddingcomponent-spacing-map.x3var(--calendar-padding) | space.20:1.25rem |
| Gap | component.calendar.gapspace.gap.groupvar(--calendar-gap) | space.32:2rem |
| Gap 2 | component.calendar.gap-2space.gap.tightvar(--calendar-gap-2) | space.12:0.75rem |
| Disabled opacity disabled when disabled | component.calendar.disabled-opacity-disabledopacity.disabledvar(--calendar-disabled-opacity-disabled) | opacity.50:0.5 |
| 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.19:1.1875rem |
| Weight | component.calendar.font-weighttype.label.font-weightvar(--calendar-font-weight) | font.weight.700:700 |
| Corner | component.calendar.radiusradius.controlvar(--calendar-radius) | radius.6:0.375rem |
| Border Changes with theme | component.calendar.bordercolor.border.strongvar(--calendar-border) | Lightgray.light.500:#595959Darkgray.dark.500:#949494 |
| Shadow | component.calendar.shadowelevation.cardvar(--calendar-shadow) | shadow.none |
| Border 2 Changes with theme | component.calendar.border-2color.border.focusvar(--calendar-border-2) | Lightblue.light.600:#0B4FC0Darkblue.dark.600:#8AB4F8 |
| Focus | component.calendar.focusborder-width.focusvar(--calendar-focus) | border-width.3:3px |
| Focus ring Changes with theme | component.calendar.focus-ringcolor.border.focusvar(--calendar-focus-ring) | Lightblue.light.600:#0B4FC0Darkblue.dark.600:#8AB4F8 |
| Focus ring offset Changes with theme | component.calendar.focus-ring-offsetcolor.surface.canvasvar(--calendar-focus-ring-offset) | Lightgray.light.50:#F7F7F7Darkgray.dark.0:#0A0A0A |
| Background 2 Changes with theme | component.calendar.background-2color.surface.raisedvar(--calendar-background-2) | Lightgray.light.0:#FFFFFFDarkgray.dark.100:#222222 |
| Height | component.calendar.heightsize.control.defaultvar(--calendar-height) | size.52:3.25rem |
| 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) | Lightgray.light.500:#595959Darkgray.dark.500:#949494 |
| 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) | Lightgray.light.100:#EDEDEDDarkgray.dark.100:#222222 |
| Label 2 Changes with theme | component.calendar.label-2color.text.primaryvar(--calendar-label-2) | Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7 |
| Label selected Changes with theme when selected | component.calendar.label-selectedcolor.text.mutedvar(--calendar-label-selected) | Lightgray.light.500:#595959Darkgray.dark.500:#949494 |
| Disabled opacity | component.calendar.disabled-opacityopacity.disabledvar(--calendar-disabled-opacity) | opacity.50:0.5 |
| Icon size | component.calendar.icon-sizesize.iconvar(--calendar-icon-size) | size.20:1.25rem |
| Background 4 Changes with theme | component.calendar.background-4color.action.primaryvar(--calendar-background-4) | Lightblue.light.600:#0B4FC0Darkblue.dark.600:#8AB4F8 |
| Label 3 Changes with theme | component.calendar.label-3color.text.on-actionvar(--calendar-label-3) | Lightgray.light.0:#FFFFFFDarkgray.light.900:#141414 |
| Background selected Changes with theme when selected | component.calendar.background-selectedcolor.action.primaryvar(--calendar-background-selected) | Lightblue.light.600:#0B4FC0Darkblue.dark.600:#8AB4F8 |
| Label selected 2 Changes with theme when selected | component.calendar.label-selected-2color.text.on-actionvar(--calendar-label-selected-2) | Lightgray.light.0:#FFFFFFDarkgray.light.900:#141414 |
| Font size 2 | component.calendar.font-size-2type.caption.font-sizevar(--calendar-font-size-2) | font.size.16:1rem |
| From the system | ||
| Edge Changes with theme | color.border.default straight from the system, through --border | Lightgray.light.200 · #D6D6D6Darkgray.dark.100 · #222222 |
| Corner | radius.control straight from the system, through --radius-md | radius.6 · 0.375rem (6px) |