Demo
Calendar with week numbers and today button
Documented in Calendar.
Calendar with week numbers and today button
An inline Calendar with single selection, ISO week-number row headers, the today button and the view and focused-date callbacks.
| Wk | Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|---|
| 45 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 46 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 47 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 48 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 49 | 29 | 30 | |||||
| 50 |
Selected: 2026-11-23 (default) · view month · focused 2026-11-23
Demo.tsx
'use client';
import { useState } from 'react';
import { Calendar, type CalendarView, type PlainDate } from '@salmonui/calendars/calendar';
/** Single selection with week numbers, the today button and controlled view and focus events. */
export default function CalendarBasicDemo() {
const [value, setValue] = useState<PlainDate | null>(null);
const [view, setView] = useState<CalendarView>('month');
const [focused, setFocused] = useState('2026-11-23');
return (
<div className="demo-stack">
<Calendar
aria-label="Delivery date"
locale="en-US"
defaultValue="2026-11-23"
defaultFocusedValue="2026-11-23"
showWeekNumbers
showTodayButton
onValueChange={(next, details) => setValue(next ?? null) /* details.iso is the ISO form value */}
onViewChange={setView}
onFocusedValueChange={(date) => setFocused(String(date))}
/>
<p className="demo-status" aria-live="polite">
Selected: <code>{value ? String(value) : '2026-11-23 (default)'}</code> · view <code>{view}</code> · focused <code>{focused}</code>
</p>
</div>
);
}
Click the month heading to move up to the year and decade views; arrow keys, Home / End, PageUp / PageDown and Ctrl+Up / Ctrl+Down work in every view. Today is highlighted only after hydration, so the server markup never depends on the server's clock.