Calendar
A month grid for picking a date or a range.
Left out of Content first Readers need sections, navigation and little else. Actions are rare: subscribe, share, save. Picking dates is not one of them. Use instead: Input
See it live
npm run storybookWhen to use it
- 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
- Write to one person: "you", not "users".
- Short sentences with room to breathe.
- Explain why before asking for anything.
- Use: Read, Save for later, You, Next issue. Avoid: Click here, Submit, Users, Content.
The labels components use, from the voice tokens:
content.action.commit: Savecontent.action.cancel: Not nowcontent.action.destroy: Removecontent.action.retry: Try againcontent.action.empty-action: Browse guides
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.
Content 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) | Lightstone.light.50:#FFFDF8Darkstone.dark.0:#14110D |
| 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.8:0.5rem |
| 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.18:1.125rem |
| Weight | component.calendar.font-weighttype.label.font-weightvar(--calendar-font-weight) | font.weight.600:600 |
| Corner | component.calendar.radiusradius.controlvar(--calendar-radius) | radius.8:0.5rem |
| Border Changes with theme | component.calendar.bordercolor.border.strongvar(--calendar-border) | Lightstone.light.500:#7A7062Darkstone.dark.400:#A39A8B |
| Shadow | component.calendar.shadowelevation.cardvar(--calendar-shadow) | shadow.none |
| Border 2 Changes with theme | component.calendar.border-2color.border.focusvar(--calendar-border-2) | Lightnavy.light.600:#1E3A5FDarknavy.dark.600:#8FA6C4 |
| 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) | Lightnavy.light.600:#1E3A5FDarknavy.dark.600:#8FA6C4 |
| Focus ring offset Changes with theme | component.calendar.focus-ring-offsetcolor.surface.canvasvar(--calendar-focus-ring-offset) | Lightstone.light.50:#FFFDF8Darkstone.dark.0:#14110D |
| Background 2 Changes with theme | component.calendar.background-2color.surface.raisedvar(--calendar-background-2) | Lightstone.light.0:#FFFFFFDarkstone.dark.100:#2E2A24 |
| Height | component.calendar.heightsize.control.defaultvar(--calendar-height) | size.48:3rem |
| 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) | Lightstone.light.600:#61594DDarkstone.dark.400:#A39A8B |
| 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) | Lightstone.light.100:#F6F2EADarkstone.dark.100:#2E2A24 |
| Label 2 Changes with theme | component.calendar.label-2color.text.primaryvar(--calendar-label-2) | Lightstone.light.900:#1F1B16Darkstone.dark.900:#FFFDF8 |
| Label selected Changes with theme when selected | component.calendar.label-selectedcolor.text.mutedvar(--calendar-label-selected) | Lightstone.light.600:#61594DDarkstone.dark.400:#A39A8B |
| 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) | Lightnavy.light.600:#1E3A5FDarknavy.dark.600:#8FA6C4 |
| Label 3 Changes with theme | component.calendar.label-3color.text.on-actionvar(--calendar-label-3) | Lightstone.light.0:#FFFFFFDarkstone.light.900:#1F1B16 |
| Background selected Changes with theme when selected | component.calendar.background-selectedcolor.action.primaryvar(--calendar-background-selected) | Lightnavy.light.600:#1E3A5FDarknavy.dark.600:#8FA6C4 |
| Label selected 2 Changes with theme when selected | component.calendar.label-selected-2color.text.on-actionvar(--calendar-label-selected-2) | Lightstone.light.0:#FFFFFFDarkstone.light.900:#1F1B16 |
| Font size 2 | component.calendar.font-size-2type.caption.font-sizevar(--calendar-font-size-2) | font.size.14:0.875rem |
| From the system | ||
| Edge Changes with theme | color.border.default straight from the system, through --border | Lightstone.light.200 · #E4DDD0Darkstone.dark.100 · #2E2A24 |
| Corner | radius.control straight from the system, through --radius-md | radius.8 · 0.5rem (8px) |