component
Calendar
A month to pick a date from: its name between two arrows, the days of the week, and six weeks of CalendarDays. The arrow keys move a day or a week.
Try it
Every variant
November 2026
Defaultimport { Calendar } from 'rost/components/calendar/Calendar'
<Calendar value={date} onValueChange={setDate} max={new Date()} />
// A range: the first press is the start, the second the end
<Calendar range={period} onRangeChange={setPeriod} /> src/components/calendar/Calendar.tsx
import { useEffect, useId, useRef, useState, type HTMLAttributes, type KeyboardEvent } from 'react'
import { CalendarDay, type CalendarDayStatus } from '../calendar-day/CalendarDay'
import { IconButton } from '../icon-button/IconButton'
import { Icon } from '../icon/Icon'
import './calendar.css'
/** A range of dates: `end` is null while only the first end is picked. */
export interface DateRange {
readonly start: Date
readonly end: Date | null
}
export interface CalendarProps extends Omit<HTMLAttributes<HTMLDivElement>, 'defaultValue'> {
/** The picked date. */
readonly value?: Date | null
readonly onValueChange?: (date: Date) => void
/** Picking a range instead of a date. With it, `value` is left out. */
readonly range?: DateRange | null
/** Called after each press while picking a range: first with only `start`, then with both ends. */
readonly onRangeChange?: (range: DateRange) => void
/** The month shown, any date in it. Leave it out and the Calendar keeps its own. */
readonly month?: Date
readonly onMonthChange?: (month: Date) => void
/** Today. The real today by default. */
readonly today?: Date
/** The first date that can be picked. */
readonly min?: Date
/** The last date that can be picked. */
readonly max?: Date
/** 0 for Sunday, 1 for Monday. */
readonly weekStartsOn?: number
readonly locale?: string
/** Put the focus on the picked day, or today, when it appears. For a Calendar in a Popover. */
readonly autoFocus?: boolean
}
const b = 'rost-calendar'
const day = (d: Date) => new Date(d.getFullYear(), d.getMonth(), d.getDate())
const addDays = (d: Date, n: number) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n)
const addMonths = (d: Date, n: number) => {
const last = new Date(d.getFullYear(), d.getMonth() + n + 1, 0).getDate()
return new Date(d.getFullYear(), d.getMonth() + n, Math.min(d.getDate(), last))
}
const same = (a?: Date | null, c?: Date | null) => !!a && !!c && a.getFullYear() === c.getFullYear() && a.getMonth() === c.getMonth() && a.getDate() === c.getDate()
const key = (d: Date) => `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`
/**
* A month to pick a date from. A `role="grid"` of CalendarDays with one in
* the tab order; the arrow keys move between them. Built from
* contracts/calendar.contract.yaml.
*/
export function Calendar({ value = null, onValueChange, range, onRangeChange, month, onMonthChange, today: todayProp, min, max, weekStartsOn = 1, locale = 'en', autoFocus = false, className, ...rest }: CalendarProps) {
const today = day(todayProp ?? new Date())
const ranged = range !== undefined || onRangeChange !== undefined
// In range mode the anchor for the month and the focus is the range's start.
if (ranged) value = range?.start ?? null
// While only one end is picked, the day under the pointer or the focus shows where the range would end.
const [over, setOver] = useState<Date | null>(null)
const [ownMonth, setOwnMonth] = useState(() => day(month ?? value ?? today))
const shown = month ?? ownMonth
const first = new Date(shown.getFullYear(), shown.getMonth(), 1)
const [focus, setFocus] = useState<Date>(() => (value && same(new Date(value.getFullYear(), value.getMonth(), 1), first) ? day(value) : same(new Date(today.getFullYear(), today.getMonth(), 1), first) ? today : first))
const moved = useRef(false)
const grid = useRef<HTMLDivElement>(null)
const titleId = useId()
const disabled = (d: Date) => (!!min && d < day(min)) || (!!max && d > day(max))
const go = (m: Date) => { const f = new Date(m.getFullYear(), m.getMonth(), 1); setOwnMonth(f); onMonthChange?.(f) }
// Keep the focused day inside the month on show.
const focusDay = focus.getMonth() === shown.getMonth() && focus.getFullYear() === shown.getFullYear()
? focus
: value && value.getMonth() === shown.getMonth() && value.getFullYear() === shown.getFullYear() ? day(value) : first
// Opened in a Popover: start on the picked day, or today, or the first.
useEffect(() => { if (autoFocus) grid.current?.querySelector<HTMLButtonElement>('[tabindex="0"]')?.focus() }, [])
useEffect(() => {
if (!moved.current) return
moved.current = false
grid.current?.querySelector<HTMLButtonElement>(`[data-date="${key(focusDay)}"]`)?.focus()
})
const lead = (first.getDay() - weekStartsOn + 7) % 7
const start = addDays(first, -lead)
const days = Array.from({ length: 42 }, (_, i) => addDays(start, i))
const weekdays = days.slice(0, 7)
const moveTo = (d: Date) => {
moved.current = true
setFocus(d)
if (d.getMonth() !== shown.getMonth() || d.getFullYear() !== shown.getFullYear()) go(d)
}
const pick = (d: Date) => {
if (disabled(d)) return
if (ranged) {
// A first press, or a press after a full range, starts again; the second press ends it,
// and the two are swapped if it's before the start.
if (!range || range.end) onRangeChange?.({ start: d, end: null })
else if (d < day(range.start)) onRangeChange?.({ start: d, end: day(range.start) })
else onRangeChange?.({ start: day(range.start), end: d })
setOver(null)
} else onValueChange?.(d)
moveTo(d)
}
// The two ends, in order, with a provisional end while one is picked.
const ends = (() => {
if (!ranged || !range) return null
const a = day(range.start)
const z = range.end ? day(range.end) : over
if (!z) return [a, a] as const
return a <= z ? [a, z] as const : [z, a] as const
})()
const inRange = (d: Date) => !!ends && d >= ends[0] && d <= ends[1]
const isEnd = (d: Date) => !!ends && (same(d, ends[0]) || same(d, ends[1]))
const onKey = (e: KeyboardEvent<HTMLDivElement>) => {
const pos = (focusDay.getDay() - weekStartsOn + 7) % 7
const to = {
ArrowRight: addDays(focusDay, 1), ArrowLeft: addDays(focusDay, -1), ArrowDown: addDays(focusDay, 7), ArrowUp: addDays(focusDay, -7),
Home: addDays(focusDay, -pos), End: addDays(focusDay, 6 - pos), PageUp: addMonths(focusDay, e.shiftKey ? -12 : -1), PageDown: addMonths(focusDay, e.shiftKey ? 12 : 1),
}[e.key]
if (to) { e.preventDefault(); moveTo(to) }
}
const status = (d: Date): CalendarDayStatus =>
disabled(d) ? 'disabled'
: ranged ? (isEnd(d) ? 'selected' : inRange(d) ? 'range' : d.getMonth() !== shown.getMonth() ? 'outside' : same(d, today) ? 'today' : 'default')
: same(d, value) ? 'selected' : d.getMonth() !== shown.getMonth() ? 'outside' : same(d, today) ? 'today' : 'default'
const picked = (d: Date) => (ranged ? inRange(d) && !!range : same(d, value))
const full = (d: Date) => d.toLocaleDateString(locale, { day: 'numeric', month: 'long', year: 'numeric' })
return (
<div className={[b, className].filter(Boolean).join(' ')} {...rest}>
<div className={`${b}__header`}>
<IconButton variant="tertiary" aria-label="Previous month" icon={<Icon name="chevron-left" size="small" />} onClick={() => go(addMonths(first, -1))} />
<h2 className={`${b}__title`} id={titleId} aria-live="polite">{first.toLocaleDateString(locale, { month: 'long', year: 'numeric' })}</h2>
<IconButton variant="tertiary" aria-label="Next month" icon={<Icon name="chevron-right" size="small" />} onClick={() => go(addMonths(first, 1))} />
</div>
<div ref={grid} className={`${b}__grid`} role="grid" aria-labelledby={titleId} aria-multiselectable={ranged || undefined} onKeyDown={onKey} onMouseLeave={() => setOver(null)}>
<div className={`${b}__row`} role="row">
{weekdays.map((d) => (
<span key={d.getDay()} className={`${b}__weekday`} role="columnheader" aria-label={d.toLocaleDateString(locale, { weekday: 'long' })}>
{d.toLocaleDateString(locale, { weekday: 'short' }).slice(0, 2)}
</span>
))}
</div>
{[0, 1, 2, 3, 4, 5].map((w) => (
<div key={w} className={`${b}__row`} role="row">
{days.slice(w * 7, w * 7 + 7).map((d) => {
const s = status(d)
return (
<span key={key(d)} className={`${b}__cell`} role="gridcell" aria-selected={picked(d)}>
<CalendarDay
status={s}
data-date={key(d)}
tabIndex={same(d, focusDay) ? 0 : -1}
aria-label={full(d)}
aria-current={same(d, today) ? 'date' : undefined}
onClick={() => pick(d)}
onMouseEnter={ranged && range && !range.end ? () => setOver(d) : undefined}
onFocus={ranged && range && !range.end ? () => setOver(d) : undefined}
>
{d.getDate()}
</CalendarDay>
</span>
)
})}
</div>
))}
</div>
</div>
)
}
The source for everything on this page: contracts/calendar.contract.yaml (opens in a new tab). The CSS, the docs and the checks in each app are built from it.
# yaml-language-server: $schema=../schema/component-contract.schema.json
schemaVersion: 2
id: calendar
name: Calendar
kind: component
status: review
summary: "A month to pick a date from: its name between two arrows, the days of the week, and six weeks of CalendarDays. The arrow keys move a day or a week."
category: inputs
related: [ calendar-day, input, popover ]
source:
tool: figma
fileKey: 1Zy0wiWKXQAvsfDBX3KR0d
nodeId: "750:34"
url: https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=750-34
extractedAt: "2026-11-17"
extractedBy: hand
frozenAt: "2026-11-17"
props:
value: { type: node, notes: "The picked date, a `Date`, or nothing." }
range: { type: node, notes: "For picking a range instead: `{ start, end }`, with `end` null while only one end is picked. Use it or `value`, not both." }
onRangeChange: { type: node, notes: "Called after each press while picking a range: first with only `start`, then with both ends, in order." }
month: { type: node, notes: "The month shown, a `Date` in it. Leave it out and the Calendar keeps its own, starting at `value` or today." }
today: { type: node, notes: "Today, a `Date`. The real today unless you set it." }
min: { type: node, notes: "The first date that can be picked." }
max: { type: node, notes: "The last date that can be picked." }
weekStartsOn: { type: number, default: 1, notes: "0 for Sunday, 1 for Monday." }
locale: { type: string, default: en, notes: "For the month's name, the days of the week and each day's spoken date." }
autoFocus: { type: boolean, default: false, notes: "Puts the focus on the picked day, or today, when it appears. For a Calendar in a Popover, like DateField's." }
elements:
root:
notes: "The header, then the grid, 8px apart. As wide as seven days."
styles:
display: { value: inline-flex, assert: false }
flex-direction: { value: column, assert: false }
gap: { token: spacing/gap/small, value: 8px }
header:
notes: "The month's name between two tertiary IconButtons: chevron-left and chevron-right."
styles:
display: { value: flex, assert: false }
align-items: { value: center }
justify-content: { value: space-between }
title:
notes: "The month and year, in paragraph type, medium weight, the main text colour. It names the grid."
styles:
margin: { token: spacing/gap/none, value: 0px }
font-family: { token: font-family/base, value: "'General Sans Variable'" }
font-weight: { token: typography/paragraph/font-weight/medium, value: "500" }
font-size: { token: typography/paragraph/font-size, value: 14px }
line-height: { token: typography/paragraph/line-height, value: 20px }
letter-spacing: { token: typography/paragraph/letter-spacing, value: 0px }
color: { token: calendar/title, value: "#ededed" }
grid:
notes: "`role=\"grid\"`: seven 40px columns. Its rows are `display: contents`, so the days line up in one grid."
styles:
display: { value: grid, assert: false }
grid-template-columns: { value: "repeat(7, var(--spacing-size-medium))", untokenised: "Composed from a token: seven columns, each a day wide." }
row:
notes: "A week, or the days of the week: `role=\"row\"`, laid out by the grid."
styles:
display: { value: contents, assert: false }
weekday:
notes: "A day of the week, two letters, in label type and the tertiary grey, centred, with 8px under."
styles:
padding-bottom: { token: spacing/gap/small, value: 8px }
text-align: { value: center, assert: false }
font-family: { token: font-family/base, value: "'General Sans Variable'" }
font-weight: { token: typography/label/font-weight/regular, value: "400" }
font-size: { token: typography/label/font-size, value: 12px }
line-height: { token: typography/label/line-height, value: 14px }
letter-spacing: { token: typography/label/letter-spacing, value: 0px }
color: { token: calendar/weekday, value: "#999999" }
cell:
notes: "`role=\"gridcell\"` around each CalendarDay, laid out by the grid."
styles:
display: { value: contents, assert: false }
guidance:
status: proposed
use:
- title: Picking a day
text: "An invoice's date, the day a payment came in. Put it in a **Popover** under a date field, or on the page when choosing the date is the task."
avoid:
- title: A date someone knows by heart
text: "A birthday or a year far away is quicker to type. That's an **Input**."
- title: A range
text: "From and to isn't done yet. Two Calendars, one for each end, for now."
behaviour: "It shows six weeks, always, so it doesn't change height between months. The arrows change the month. In the grid, the arrow keys move a day or a week, Home and End to the week's ends, Page Up and Page Down a month, and Enter or Space picks. Moving past the month's edge turns the page. It calls `onValueChange` with the picked date and `onMonthChange` when the month changes. With `range` it picks two ends instead: the first press is the start, the second the end (swapped if it's earlier), and a third starts again. While only the start is picked, the days up to the one under the pointer or the focus show as the range would be."
accessibility:
element: "A grid (`role=\"grid\"`) named by the month's title, with a header row of `columnheader`s whose names are the days in full. Only one day is in the tab order: the picked one, or today, or the first."
name: "The month and year. Each day's button says its whole date."
colour: "The title is 17:1 and the days of the week 7:1 on the dark page."
content: "Let the locale name the month and the days. Monday first unless the people using it count from Sunday."
Install
npx github:Runceanu/rost add calendar It lands in src/rost/calendar/, with what it needs and its contract. Install has the rest.
When to use
Picking a day
An invoice's date, the day a payment came in. Put it in a Popover under a date field, or on the page when choosing the date is the task.
When not to use
A date someone knows by heart
A birthday or a year far away is quicker to type. That's an Input.
A range
From and to isn't done yet. Two Calendars, one for each end, for now.
Behaviour
It shows six weeks, always, so it doesn't change height between months. The arrows change the month. In the grid, the arrow keys move a day or a week, Home and End to the week's ends, Page Up and Page Down a month, and Enter or Space picks. Moving past the month's edge turns the page. It calls onValueChange with the picked date and onMonthChange when the month changes. With range it picks two ends instead: the first press is the start, the second the end (swapped if it's earlier), and a third starts again. While only the start is picked, the days up to the one under the pointer or the focus show as the range would be.
Accessibility
- Element
A grid (
role="grid") named by the month's title, with a header row ofcolumnheaders whose names are the days in full. Only one day is in the tab order: the picked one, or today, or the first. - Name
The month and year. Each day's button says its whole date.
- Colour
The title is 17:1 and the days of the week 7:1 on the dark page.
Content
Let the locale name the month and the days. Monday first unless the people using it count from Sunday.
Props
| Prop | Type | Values | Default |
|---|---|---|---|
value | node | | |
range | node | | |
onRangeChange | node | | |
month | node | | |
today | node | | |
min | node | | |
max | node | | |
weekStartsOn | number | | 1 |
locale | string | | en |
autoFocus | boolean | | false |
Values
Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.
Never changes
root
-
gap8pxspacing/gap/small
displayinline-flex · flex-directioncolumn
header
displayflex · align-itemscenter · justify-contentspace-between
title
-
margin0pxspacing/gap/none -
font-family'General Sans Variable'font-family/base -
font-weight500typography/paragraph/font-weight/medium -
font-size14pxtypography/paragraph/font-size -
line-height20pxtypography/paragraph/line-height -
letter-spacing0pxtypography/paragraph/letter-spacing -
color#edededcalendar/title
grid
-
grid-template-columnsrepeat(7, var(--spacing-size-medium))on purpose: Composed from a token: seven columns, each a day wide.
displaygrid
row
displaycontents
weekday
-
padding-bottom8pxspacing/gap/small -
font-family'General Sans Variable'font-family/base -
font-weight400typography/label/font-weight/regular -
font-size12pxtypography/label/font-size -
line-height14pxtypography/label/line-height -
letter-spacing0pxtypography/label/letter-spacing -
color#999999calendar/weekday
text-aligncenter
cell
displaycontents
Part of Calendar
CalendarDay
One day in a Calendar: a 40px square with its number. Green when picked, green text for today, grey for the months either side, faint when it can't be picked.
Default · DefaultOutside · DefaultToday · DefaultSelected · DefaultDisabled · DefaultRange · DefaultHover, press or tab to one to see the other 5 states.
src/components/calendar-day/CalendarDay.tsx
import { forwardRef, type ButtonHTMLAttributes, type ReactNode } from 'react'
import './calendar-day.css'
export type CalendarDayStatus = 'default' | 'outside' | 'today' | 'selected' | 'disabled' | 'range'
export interface CalendarDayProps extends ButtonHTMLAttributes<HTMLButtonElement> {
readonly status?: CalendarDayStatus
/** The day's number. */
readonly children: ReactNode
}
const b = 'rost-calendar-day'
/** One day in a Calendar. Built from contracts/calendar-day.contract.yaml. */
export const CalendarDay = forwardRef<HTMLButtonElement, CalendarDayProps>(function CalendarDay({ status = 'default', children, className, ...rest }, ref) {
return (
<button ref={ref} type="button" className={[b, `${b}--status-${status}`, className].filter(Boolean).join(' ')} aria-disabled={status === 'disabled' || undefined} {...rest}>
{children}
</button>
)
})
The source for everything on this page: contracts/calendar-day.contract.yaml (opens in a new tab). The CSS, the docs and the checks in each app are built from it.
# yaml-language-server: $schema=../schema/component-contract.schema.json
schemaVersion: 2
id: calendar-day
name: CalendarDay
kind: component
status: review
partOf: calendar
summary: "One day in a Calendar: a 40px square with its number. Green when picked, green text for today, grey for the months either side, faint when it can't be picked."
category: inputs
related: [ calendar ]
source:
tool: figma
fileKey: 1Zy0wiWKXQAvsfDBX3KR0d
nodeId: "750:32"
url: https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=750-32
extractedAt: "2026-11-17"
extractedBy: hand
frozenAt: "2026-11-17"
props:
status:
type: enum
values: [ default, outside, today, selected, disabled, range ]
default: default
notes: "`outside` is a day from the month before or after, `disabled` one outside `min` and `max`, `range` one between the two ends of a range (the ends are `selected`). Calendar sets it."
children: { type: slot, required: true, notes: "The day's number." }
states: [ Default, Hover, Focus ]
elements:
root:
notes: "A `<button>`, 40px square with 8px corners, the number in the middle in paragraph type."
styles:
display: { value: inline-flex, assert: false }
align-items: { value: center }
justify-content: { value: center }
width: { token: spacing/size/medium, value: 40px }
height: { token: spacing/size/medium, value: 40px }
padding: { token: spacing/gap/none, value: 0px }
border: { value: none, assert: false }
border-radius: { token: spacing/radius/small, value: 8px }
background: { value: transparent, assert: false }
outline: { value: none, assert: false }
cursor: { value: pointer, assert: false }
font-family: { token: font-family/base, value: "'General Sans Variable'" }
font-weight: { token: typography/paragraph/font-weight/regular, value: "400" }
font-size: { token: typography/paragraph/font-size, value: 14px }
line-height: { token: typography/paragraph/line-height, value: 20px }
letter-spacing: { token: typography/paragraph/letter-spacing, value: 0px }
variants:
- when: { status: default, state: Default }
figmaNode: "750:14"
elements:
root:
color: { token: calendar-day/default/label, value: "#ededed" }
- when: { status: default, state: Hover }
figmaNode: "750:16"
elements:
root:
background: { token: calendar-day/hover/background, value: "#006f27" }
color: { token: calendar-day/hover/label, value: "#ededed" }
- when: { status: default, state: Focus }
figmaNode: "750:18"
elements:
root:
color: { token: calendar-day/default/label, value: "#ededed" }
outline: { value: "var(--spacing-outline-medium) solid var(--calendar-day-focus-ring)", untokenised: "Composed from tokens: a 2px ring in calendar-day/focus-ring." }
outline-offset: { value: "calc(-1 * var(--spacing-outline-medium))", untokenised: "Composed from a token: the ring sits inside the square." }
- when: { status: outside, state: Default }
figmaNode: "750:20"
elements:
root:
color: { token: calendar-day/outside/label, value: "#999999" }
- when: { status: outside, state: Hover }
figmaNode: "750:22"
elements:
root:
background: { token: calendar-day/hover/background, value: "#006f27" }
color: { token: calendar-day/hover/label, value: "#ededed" }
- when: { status: today, state: Default }
figmaNode: "750:24"
elements:
root:
font-weight: { token: typography/paragraph/font-weight/medium, value: "500" }
color: { token: calendar-day/today/label, value: "#00d669" }
- when: { status: today, state: Hover }
figmaNode: "750:26"
elements:
root:
font-weight: { token: typography/paragraph/font-weight/medium, value: "500" }
background: { token: calendar-day/hover/background, value: "#006f27" }
color: { token: calendar-day/hover/label, value: "#ededed" }
- when: { status: selected, state: Default }
figmaNode: "750:28"
elements:
root:
font-weight: { token: typography/paragraph/font-weight/medium, value: "500" }
background: { token: calendar-day/selected/background, value: "#00d669" }
color: { token: calendar-day/selected/label, value: "#060805" }
- when: { status: disabled, state: Default }
figmaNode: "750:30"
elements:
root:
color: { token: calendar-day/disabled/label, value: "#3a3a3a" }
cursor: { value: default, assert: false }
- when: { status: range, state: Default }
figmaNode: "782:54"
elements:
root:
background: { token: calendar-day/range/background, value: "#004c19" }
color: { token: calendar-day/range/label, value: "#ededed" }
- when: { status: range, state: Hover }
figmaNode: "782:56"
elements:
root:
background: { token: calendar-day/hover/background, value: "#006f27" }
color: { token: calendar-day/hover/label, value: "#ededed" }
- when: { status: range, state: Focus }
elements:
root:
background: { token: calendar-day/range/background, value: "#004c19" }
color: { token: calendar-day/range/label, value: "#ededed" }
outline: { value: "var(--spacing-outline-medium) solid var(--calendar-day-focus-ring)", untokenised: "Composed from tokens: a 2px ring in calendar-day/focus-ring." }
outline-offset: { value: "calc(-1 * var(--spacing-outline-medium))", untokenised: "Composed from a token: the ring sits inside the square." }
- when: { status: outside, state: Focus }
elements:
root:
color: { token: calendar-day/outside/label, value: "#999999" }
outline: { value: "var(--spacing-outline-medium) solid var(--calendar-day-focus-ring)", untokenised: "Composed from tokens: a 2px ring in calendar-day/focus-ring." }
outline-offset: { value: "calc(-1 * var(--spacing-outline-medium))", untokenised: "Composed from a token: the ring sits inside the square." }
- when: { status: today, state: Focus }
elements:
root:
font-weight: { token: typography/paragraph/font-weight/medium, value: "500" }
color: { token: calendar-day/today/label, value: "#00d669" }
outline: { value: "var(--spacing-outline-medium) solid var(--calendar-day-focus-ring)", untokenised: "Composed from tokens: a 2px ring in calendar-day/focus-ring." }
outline-offset: { value: "calc(-1 * var(--spacing-outline-medium))", untokenised: "Composed from a token: the ring sits inside the square." }
- when: { status: selected, state: Focus }
elements:
root:
font-weight: { token: typography/paragraph/font-weight/medium, value: "500" }
background: { token: calendar-day/selected/background, value: "#00d669" }
color: { token: calendar-day/selected/label, value: "#060805" }
outline: { value: "var(--spacing-outline-medium) solid var(--calendar-day-selected-focus-ring)", untokenised: "Composed from tokens: a 2px ring in calendar-day/selected/focus-ring, the picked day's own label colour, since the grey ring is 1.4:1 on the green." }
outline-offset: { value: "calc(-1 * var(--spacing-outline-large))", untokenised: "Composed from a token: on the green, the ring sits 2px further in, so the green shows round it." }
- when: { status: disabled, state: Focus }
elements:
root:
color: { token: calendar-day/disabled/label, value: "#3a3a3a" }
cursor: { value: default, assert: false }
outline: { value: "var(--spacing-outline-medium) solid var(--calendar-day-focus-ring)", untokenised: "Composed from tokens: a 2px ring in calendar-day/focus-ring." }
outline-offset: { value: "calc(-1 * var(--spacing-outline-medium))", untokenised: "Composed from a token: the ring sits inside the square." }
guidance:
status: proposed
use:
- title: Picked and today
text: "The picked day is filled green. Today is green text in medium weight, so it's found without being mistaken for the pick."
show: "status=today, state=Default"
- title: A range
text: "Both ends are filled green as a picked day is, and the days between them a dark green, so the stretch reads as one."
show: "status=range, state=Default"
avoid:
- title: On its own
text: "A CalendarDay only makes sense in a Calendar, which sets its status and moves the focus between days."
behaviour: "A day from either side of the month is grey and can still be picked; it moves the Calendar to that month. A disabled day can be reached with the keyboard, so the grid has no holes, but pressing it does nothing."
accessibility:
element: "`<button>` inside a `gridcell`. Its name is the whole date in the locale's words, like November 17, 2026. The picked one has `aria-selected`, today `aria-current=\"date\"`, a disabled one `aria-disabled`."
colour: "The numbers are 17:1, the grey ones 7:1 and today's green 10:1 on the dark page. Disabled days are faint on purpose, 1.8:1, and not counted."
Install
npx github:Runceanu/rost add calendar-day It lands in src/rost/calendar-day/, with what it needs and its contract. Install has the rest.
When to use
Picked and today
The picked day is filled green. Today is green text in medium weight, so it's found without being mistaken for the pick.
A range
Both ends are filled green as a picked day is, and the days between them a dark green, so the stretch reads as one.
When not to use
On its own
A CalendarDay only makes sense in a Calendar, which sets its status and moves the focus between days.
Behaviour
A day from either side of the month is grey and can still be picked; it moves the Calendar to that month. A disabled day can be reached with the keyboard, so the grid has no holes, but pressing it does nothing.
Accessibility
- Element
<button>inside agridcell. Its name is the whole date in the locale's words, like November 17, 2026. The picked one hasaria-selected, todayaria-current="date", a disabled onearia-disabled. - Colour
The numbers are 17:1, the grey ones 7:1 and today's green 10:1 on the dark page. Disabled days are faint on purpose, 1.8:1, and not counted.
Props
| Prop | Type | Values | Default |
|---|---|---|---|
status | enum | default · outside · today · selected · disabled · range | default |
children | slot | | |
States: Default, Hover, Focus.
Values
Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.
Never changes
root
-
width40pxspacing/size/medium -
height40pxspacing/size/medium -
padding0pxspacing/gap/none -
border-radius8pxspacing/radius/small -
font-family'General Sans Variable'font-family/base -
font-weight400typography/paragraph/font-weight/regular -
font-size14pxtypography/paragraph/font-size -
line-height20pxtypography/paragraph/line-height -
letter-spacing0pxtypography/paragraph/letter-spacing
displayinline-flex · align-itemscenter · justify-contentcenter · bordernone · backgroundtransparent · outlinenone · cursorpointer
Changes by variant
16 variants. Each table is what one thing changes with: a column per status, a row per property. Where every row starts with the same token path, it's written once, under the property.
Follows status
Focus
| Property | Default | Outside | Today | Selected | Disabled | Range |
|---|---|---|---|---|---|---|
root.outlinevar(--spacing-outline-medium) solid … | calendar-day-focus-ring | calendar-day-focus-ring | calendar-day-focus-ring | calendar-day-selected-focus-ring | calendar-day-focus-ring | calendar-day-focus-ring |
root.outline-offsetcalc(-1 * …) | spacing-outline-medium | spacing-outline-medium | spacing-outline-medium | spacing-outline-large | spacing-outline-medium | spacing-outline-medium |
Follows status and state
Default
| Property | Default | Hover | Focus |
|---|---|---|---|
root.background | · | calendar-day/hover/background #006f27 | · |
root.colorcalendar-day/… | default/label #ededed | hover/label #ededed | default/label #ededed |
Outside
| Property | Default | Hover | Focus |
|---|---|---|---|
root.background | · | calendar-day/hover/background #006f27 | · |
root.colorcalendar-day/… | outside/label #999999 | hover/label #ededed | outside/label #999999 |
Today
| Property | Default | Hover | Focus |
|---|---|---|---|
root.background | · | calendar-day/hover/background #006f27 | · |
root.colorcalendar-day/… | today/label #00d669 | hover/label #ededed | today/label #00d669 |
Selected
| Property | Default | Hover | Focus |
|---|---|---|---|
root.backgroundcalendar-day/selected/… | background #00d669 | · | background #00d669 |
root.colorcalendar-day/selected/… | label #060805 | · | label #060805 |
Disabled
| Property | Default | Hover | Focus |
|---|---|---|---|
root.colorcalendar-day/disabled/… | label #3a3a3a | · | label #3a3a3a |
Range
| Property | Default | Hover | Focus |
|---|---|---|---|
root.backgroundcalendar-day/… | range/background #004c19 | hover/background #006f27 | range/background #004c19 |
root.colorcalendar-day/… | range/label #ededed | hover/label #ededed | range/label #ededed |
Only in some variants
These don't change: they're just set in some variants and not others.
Disabled
-
root.cursordefaultFigma frame size
In 5 variants
-
root.font-weight500typography/paragraph/font-weight/medium