# SSR, accessibility and performance

> How the calendar components server-render and hydrate (Next.js App Router, Vite SSR), what the server never computes, React Compiler rules, built-in icons, forced colors, axe and ARIA snapshot coverage, and the timing and bundle budgets.

Canonical: https://salmonui.dev/docs/calendars/platform

These guarantees hold for `Calendar`, `RangeCalendar`, `DateField`,
`TimeField`, `DatePicker`, `DateRangePicker` and `TimePicker`.

## Server rendering and hydration

The components render on the server in the Next.js App Router (16+) and in
Vite SSR and hydrate without warnings. A Server Component can render them
directly with plain values:

```tsx
// app/booking/page.tsx (a Server Component)
import { Calendar } from '@salmonui/calendars/calendar';
import { DatePicker } from '@salmonui/calendars/date-picker';

export default function Page() {
  return (
    <>
      <Calendar defaultValue="2026-11-23" />
      <DatePicker label="Arrival" defaultValue="2026-11-23" name="arrival" />
    </>
  );
}
```

Props that are functions (`isDateDisabled`, `renderDay`, preset functions)
need a Client Component, as for any React component.

- **No host locale or zone.** Render reads `locale` and `timeZone` from
  props only; the defaults are `'en-US'` and, on the server, no zone. The
  server HTML is the same in every host zone.
- **Zone-dependent text waits for the client.** An instant (a `Date`, an
  ISO string with an offset) without `timeZone` renders empty, sized
  segments (`data-salmon-deferred`) and fills in after hydration. Pass
  `timeZone` to render it on the server. Plain dates and times always
  render on the server.
- **Today is client-only.** `aria-current="date"` and the today mark are
  added after hydration. A `Calendar` with no `value`, `defaultValue`,
  `focusedValue` or `defaultFocusedValue` renders the heading and 42 empty
  cells with `aria-busy="true"` and shows today's month after hydration;
  pass `defaultFocusedValue` for a complete server render.
- **No popup and no preset on the server.** Popups mount on a user action
  (`defaultOpen` opens after hydration) and preset functions run when the
  popup opens.

## React Compiler

Renders are pure: no module-level render state, no browser globals and no
clock read during render (now and today are read in event handlers and
effects), and no `forwardRef`, `cloneElement` or `Children` traversal, so
the components are safe under the React Compiler and concurrent rendering.

## Icons

The trigger (calendar or clock) and the clear button carry built-in icons
drawn in each `styles.css` with `currentColor`, so they follow the theme
colors, the dark scheme and forced colors. There is no icon markup: the
buttons are labelled by `localeText` (`'Choose date'`, `'Choose date range'`, `'Choose time'`,
`'Clear'`), and `className` on the picker can restyle the
`.salmon-picker__trigger[data-icon]` and `.salmon-picker__clear` parts.

## Theme and sizing

- **One theme.** Salmon UI has one neutral theme driven by five
  color seeds (`primary`, `success`, `warning`, `danger`, `info`) and a
  `colorScheme`. Set the seeds to your brand colors on `ThemeProvider`, and
  use `className`, `style` and the `.salmon-*` parts for local
  adjustments.
- **Control sizes.** `DatePicker` (and the date-time picker),
  `DateRangePicker`, `TimePicker`, `DateField` and `TimeField` take
  `size` (`'sm' | 'md' | 'lg'`, default `'md'`), the same prop as
  `Button`, `TextField` and the dropdowns: 24, 32 or 40 px tall, 8, 12 or
  16 px of inline padding and 14, 16 or 20 px icons. The pickers carry
  `data-size` on the root, DateField and TimeField on the field group.
  The popup and the calendar keep one size. `size` is a component prop;
  the theme's `density: 'compact'` makes each size 4 px shorter with 2 px
  less inline padding (see
  [Density](https://salmonui.dev/docs/data-grid/appearance#density)). Touch sizing still
  follows the input device: under `pointer: coarse`, the calendar day and
  navigation buttons grow to 44 px and date fields get a 44 px minimum
  height.

### Live demo: Control sizes

Live demo: https://salmonui.dev/demos/dropdowns/control-sizes

Select, Combobox, TreeSelect, DatePicker and TimePicker at the sm, md and lg sizes, 24, 32 and 40 pixels tall, next to a Button of the same size.

`Demo.tsx`:

```tsx
'use client';

import { Button } from '@salmonui/buttons/button';
import { Combobox } from '@salmonui/dropdowns/combobox';
import { DatePicker } from '@salmonui/calendars/date-picker';
import { Select } from '@salmonui/dropdowns/select';
import { TimePicker } from '@salmonui/calendars/time-picker';
import { TreeSelect } from '@salmonui/dropdowns/tree-select';

const FRUITS = [
  { value: 'apple', label: 'Apple' },
  { value: 'banana', label: 'Banana' },
  { value: 'kiwi', label: 'Kiwi' },
  { value: 'mango', label: 'Mango' },
];

interface Folder {
  id: string;
  label: string;
  children?: Folder[];
}

const FOLDERS: Folder[] = [{ id: 'docs', label: 'Documents', children: [{ id: 'cv', label: 'CV.pdf' }, { id: 'notes', label: 'Notes.txt' }] }];

const SIZES = [
  { size: 'sm', name: 'Small' },
  { size: 'md', name: 'Medium' },
  { size: 'lg', name: 'Large' },
] as const;

// One row per size: every control takes the same `size` as the Button.
export default function ControlSizesDemo() {
  return (
    <div style={{ display: 'grid', gap: 16 }}>
      {SIZES.map(({ size, name }) => (
        <div key={size} style={{ display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 8 }}>
          <Button size={size}>{name}</Button>
          <Select size={size} aria-label={`${name} select`} data={FRUITS} defaultValue="kiwi" />
          <Combobox size={size} aria-label={`${name} combobox`} multiple data={FRUITS} defaultValue={['apple']} />
          <TreeSelect<Folder> size={size} aria-label={`${name} tree select`} data={FOLDERS} getItemValue={(f) => f.id} getItemLabel={(f) => f.label} getChildren={(f) => f.children} defaultValue="cv" />
          <DatePicker size={size} aria-label={`${name} date`} defaultValue="2026-11-24" />
          <TimePicker size={size} aria-label={`${name} time`} defaultValue="09:30" />
        </div>
      ))}
    </div>
  );
}
```

## Forced colors

Under `forced-colors: active` (Windows High Contrast) selected days, range
ends and the selected time option use `Highlight` / `HighlightText`, days
between the range ends get a `Highlight` outline, today a dashed
`CanvasText` outline, disabled days `GrayText`, the focused day a 2 px
outline and the focused segment `Highlight`.

## Accessibility coverage

axe-core runs with no violations over every component and every popup
(DatePicker popover and modal sheet, the date-time popup, DateRangePicker
and TimePicker), and ARIA snapshots pin the accessibility tree a screen
reader receives for each of them. The scrolling time lists are tab stops
that answer the list keys.

### Live demo: Server rendering, color scheme and timing

Live demo: https://salmonui.dev/demos/calendars/calendar-pickers-platform

Pickers that server-render without the host locale or zone, a calendar that marks today after hydration, presets evaluated on open, a light and dark color scheme switch and input-to-paint timings for keys and popups.

`Demo.tsx`:

```tsx
'use client';

import { useRef, useState, type SyntheticEvent } from 'react';
import { Calendar } from '@salmonui/calendars/calendar';
import { DatePicker } from '@salmonui/calendars/date-picker';
import { DateRangePicker } from '@salmonui/calendars/date-range-picker';
import { TimePicker } from '@salmonui/calendars/time-picker';
import { ThemeProvider, type SalmonColorScheme } from '@salmonui/core/theme';
import { Select } from '@salmonui/dropdowns/select';

// The local calendar day (toISOString would give the UTC day).
const isoDay = (d: Date): string => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
// Runs when the popup opens, never on the server or during render.
const lastSevenDays = () => {
  const end = new Date();
  return { start: isoDay(new Date(end.getFullYear(), end.getMonth(), end.getDate() - 6)), end: isoDay(end) };
};

type Timing = { what: string; ms: number };

/** Server-rendered pickers without host locale or zone, today marked after hydration, a color scheme switch and input-to-paint timings. */
export default function CalendarPickersPlatformDemo() {
  const [scheme, setScheme] = useState<SalmonColorScheme>('auto');
  const [timings, setTimings] = useState<Timing[]>([]);
  const pending = useRef(false);
  // Input to the next painted frame: the measurement starts in the capture phase, before the component handles the event.
  const measure = (event: SyntheticEvent) => {
    if (pending.current) return;
    pending.current = true;
    const t0 = performance.now();
    const what = 'key' in event ? `${String((event as { key?: unknown }).key)} key` : 'pointer press';
    requestAnimationFrame(() =>
      setTimeout(() => {
        pending.current = false;
        setTimings((list) => [{ what, ms: performance.now() - t0 }, ...list].slice(0, 6));
      }, 0),
    );
  };
  return (
    <div style={{ display: 'grid', gap: 16 }}>
      <div className="demo-toolbar">
        <label>
          Color scheme
          <Select aria-label="Color scheme" data={[{ value: 'auto', label: 'auto (follow the system)' }, { value: 'light', label: 'light' }, { value: 'dark', label: 'dark' }]} value={scheme} onValueChange={(value) => value != null && setScheme(value as SalmonColorScheme)} />
        </label>
      </div>
      <ThemeProvider theme={{ colorScheme: scheme }}>
        <div onKeyDownCapture={measure} onPointerDownCapture={measure} style={{ display: 'flex', flexWrap: 'wrap', gap: 24, alignItems: 'flex-start', padding: 12, background: 'var(--salmon-surface-default)', color: 'var(--salmon-text-primary)', borderRadius: 'var(--salmon-radius-lg)' }}>
          <Calendar aria-label="This month (today after hydration)" />
          <div style={{ display: 'grid', gap: 16 }}>
            <DatePicker label="Ship date" defaultValue="2026-11-23" clearable />
            <DateRangePicker label="Report period" presets={[{ label: 'Last 7 days', value: lastSevenDays }]} defaultValue={{ start: '2026-11-02', end: '2026-11-08' }} />
            <TimePicker label="Any minute (1,440 options)" step={1} defaultValue="12:00" />
            <DatePicker label="Local time of an instant" granularity="minute" defaultValue="2026-11-23T14:00:00Z" description="No timeZone prop: the server renders an empty field, the browser fills in your zone." />
          </div>
        </div>
      </ThemeProvider>
      <div className="demo-log" aria-live="polite">
        <ol>{timings.length ? timings.map((t, i) => <li key={i}>{`${t.what}: ${t.ms.toFixed(1)} ms to the next frame`}</li>) : <li>Press keys or open a popup to time it</li>}</ol>
      </div>
    </div>
  );
}
```

## Performance budgets

Measured on the production build:

| Scenario | Budget |
| --- | --- |
| Arrow key in the calendar grid to focus painted | ≤ 8 ms |
| PageDown / Shift+PageDown (next month or year) to painted | ≤ 16 ms |
| Server render of one calendar month | ≤ 1 ms |

Bundle sizes are gzip budgets per subpath, gated by the build: the first
load of each picker holds the field and trigger, and the popup is a lazy
chunk preloaded when the browser is idle.

| Entry | First load | All chunks |
| --- | --- | --- |
| `@salmonui/calendars/calendar` | ≤ 8 KB | ≤ 8 KB |
| `@salmonui/calendars/date-picker` | ≤ 14 KB | ≤ 25 KB |
| `@salmonui/calendars/date-range-picker` | ≤ 17 KB | ≤ 23.5 KB |
| `@salmonui/calendars/time-picker` | ≤ 13 KB | ≤ 17.5 KB |
| All four together | | ≤ 33 KB |
| Each `styles.css` | ≤ 5 KB | |
