layoutdisabledimport { useState } from "react"
import { YearView } from "@/components/ui/year-view"
export function Deploys({ counts }: { counts: Record<string, number> }) {
const [day, setDay] = useState<Date | null>(null)
return (
<YearView
aria-label="Deploys"
counts={counts}
formatCount={(n) => `${n.toLocaleString("en-US")} ${n === 1 ? "deploy" : "deploys"}`}
value={day}
onValueChange={setDay}
/>
)
}Usage
import { useState } from "react"
import { YearView } from "@/components/ui/year-view"
export function Deploys({ counts }: { counts: Record<string, number> }) {
const [day, setDay] = useState<Date | null>(null)
return <YearView aria-label="Deploys" counts={counts} value={day} onValueChange={setDay} />
}Examples
import { useState } from 'react';
import { YearView } from '@/components/ui/year-view';
export function Example({ counts }: { counts: Record<string, number> }) {
const [day, setDay] = useState<Date | null>(null);
return (
<YearView
aria-label="Deploys"
counts={counts}
value={day}
onValueChange={setDay}
formatCount={(n) => `${n.toLocaleString("en-US")} ${n === 1 ? "deploy" : "deploys"}`}
/>
);
}import { YearView } from '@/components/ui/year-view';
export function Example({ counts }: { counts: Record<string, number> }) {
return (
<YearView
aria-label="Deploys"
layout="months"
counts={counts}
formatCount={(n) => `${n.toLocaleString("en-US")} ${n === 1 ? "deploy" : "deploys"}`}
/>
);
}Notes
Server rendering
Pass today when the page renders on a server, so the server and the browser agree on which day it is.
Color
The shades mix --success into --muted. Set --year-view-color on the view, or any parent, to shade with another color.
Weeks and months
The weeks layout fits a year across a desktop and scrolls to the latest week. On a phone the months layout stacks months latest first, so days are big enough to tap.
API
YYYY-MM-DD.details.cancel() refuses the change.start to end takes. Defaults to the 53 weeks up to end's week.auto switches at 768px. Months scroll inside a box --year-view-height tall, 22rem by default.max, days after it are outlined and can't be picked.YYYY-MM-DD.Agent
Inside an AgentProvider, it appears in agent.snapshot() as date.
Reads
labelThe aria-label, "Activity" by default.
valueThe picked day as YYYY-MM-DD, or absent.
Actions
setValue("2026-11-11")Picks a day.
clear()Clears the pick. Refused when required is set.
An agent's change runs through onValueChange like anyone's. isAgentChange(details) is true for it; details.cancel() refuses it. A day before the view starts, or after max or end, is refused with the reason.
await agent.act({
steps: [{ ref: "Deploys", action: "setValue", args: ["2026-11-11"] }],
})Accessibility
- Each day is a toggle button named with its date and count, such as Wednesday 11 November 2026: 8 events.
- Days before
start, or aftermaxorend, have aria-disabled. Only one day is in the tab order. - Shade is never the only signal: every count is in the day's name and in the readout. Only the top shade reaches 3:1 against the page, so don't rely on the lighter ones to carry meaning.
- The readout is a live region.
Keyboard
requiredrequired