Skip to main content

Calendar

A month grid for picking a date or a range.

In Accessible first

See it live​

Start Storybook to see it live: npm run storybook

When 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: Continue
  • content.action.cancel: Go back
  • content.action.destroy: Delete
  • content.action.retry: Try again
  • content.action.empty-action: Start a new application

See Voice and tone for the whole voice.

Accessibility and keyboard​

KeyboardWhat happensNot
undefinedArrow 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.

Changes with theme

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.

PartIts token and the semantic it aliasesValue
Calendar
Fill
Changes with theme
component.calendar.backgroundcolor.surface.canvasvar(--calendar-background)Lightgray.light.50:#F7F7F7Darkgray.dark.0:#0A0A0A
Paddingcomponent.calendar.paddingcomponent-spacing-map.x3var(--calendar-padding)space.20:1.25rem
Gapcomponent.calendar.gapspace.gap.groupvar(--calendar-gap)space.32:2rem
Gap 2component.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 3component.calendar.gap-3component-spacing-map.x2var(--calendar-gap-3)space.8:0.5rem
Text sizecomponent.calendar.font-sizetype.body.font-sizevar(--calendar-font-size)font.size.19:1.1875rem
Weightcomponent.calendar.font-weighttype.label.font-weightvar(--calendar-font-weight)font.weight.700:700
Cornercomponent.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
Shadowcomponent.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
Focuscomponent.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
Heightcomponent.calendar.heightsize.control.defaultvar(--calendar-height)size.52:3.25rem
Padding rightcomponent.calendar.padding-rightcomponent-spacing-map.x1var(--calendar-padding-right)space.4:0.25rem
Padding leftcomponent.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 2component.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 opacitycomponent.calendar.disabled-opacityopacity.disabledvar(--calendar-disabled-opacity)opacity.50:0.5
Icon sizecomponent.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 2component.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
Cornerradius.control
straight from the system, through --radius-md
radius.6 · 0.375rem (6px)