<!--
  GENERATED FILE - do not edit by hand.
  Source of truth: src/components/mds-calendar-cell/usage/ in the magma monorepo.
-->

# mds-calendar-cell - examples

> The API of this component: [`AGENTS.md`](AGENTS.md).

Correct and idiomatic ways to use the `<mds-calendar-cell>` component, ordered from most common to most specialized. The examples assume a working knowledge of the shared component rules in [`agents/conventions.md`](../../../../agents/conventions.md).

`<mds-calendar-cell>` is an internal subpart: its real parent [`<mds-calendar>`](../mds-calendar/AGENTS.md) renders one cell per day inside its own shadow DOM and has no default slot, so cells written as its children are never shown. Every pattern below shows the `<mds-calendar>` markup that puts the cells in each state.

#### Basic Cell Inside a Calendar

The typical form - let the parent render the cells and drive all their attributes (`date` in ISO `YYYY-MM-DD` format, `label`, `month`, `selection`, ...).

```html
<mds-calendar start-date="2024-06-01" end-date="2024-06-15"></mds-calendar>
```

#### Today Marker

The parent sets the `today` boolean attribute on the cell that matches the current date, which applies the accent-tinted styling that distinguishes today from other days. Set `hide-today` on the calendar to drop it.

```html
<mds-calendar></mds-calendar>
<mds-calendar hide-today></mds-calendar>
```

#### Selection Range - Start, Middle, and End Positions

The parent sets `selection` to express where a cell falls inside the active range. The `start` and `end` values are full dots, the same mark, with the band rounded around them; `middle` fills the span between them; `single` is a full dot with no band.

```html
<!-- 3 June: start, 4 June: middle, 5 June: end -->
<mds-calendar start-date="2024-06-03" end-date="2024-06-05"></mds-calendar>
```

#### Single-Day Selection

The parent uses `selection="single"` for the day of a single picker, for a range whose two ends are the same day, and for the start of a range still waiting for its end. The day is a full dot, with no band, as it reaches no other day.

```html
<mds-calendar single-picker start-date="2024-06-10"></mds-calendar>
```

#### Preview (Hover) Selection

While the user hovers toward the end of a range, the parent sets `preview` on the cells from the start to the hovered day: the band is paler, the hovered day is a ring, and the start keeps the full dot of a chosen day. A hovered day that a click would make the new start, one before the start, is a `single` `preview` alone: a ring with no band.

```html
<!-- range mode with a start and no end: hovering a later day previews the range -->
<mds-calendar start-date="2024-06-07"></mds-calendar>
```

#### Days from Adjacent Months

The parent renders the leading and trailing days that fill the grid but belong to the previous or next month with `month="other"`. Inside `<mds-calendar>` these cells are dimmed and visible; set `--mds-calendar-cell-other-month-visibility: hidden` on the calendar to hide them.

```html
<mds-calendar view-date="2024-06-01" style="--mds-calendar-cell-other-month-visibility: hidden;"></mds-calendar>
```

#### Disabled Day

The parent sets the `disabled` boolean attribute on days that cannot be selected - the dates outside its `min`/`max` range. A disabled cell removes pointer events and applies the disabled color automatically.

```html
<mds-calendar view-date="2024-06-01" min="2024-06-10"></mds-calendar>
```

#### Styling Customization

The cells live in the calendar's shadow DOM, so their public `--mds-calendar-cell-*` CSS custom properties reach them by inheritance: set them on the `<mds-calendar>` host (or on a parent selector), next to the public custom properties the calendar documents for them. The colors of the weekend, selected, preselected, disabled and adjacent-month days are not public: they follow the theme. Use the semantic color roles so dark mode, named themes and high contrast keep working.

```css
.booking-calendar mds-calendar {
  --mds-calendar-cell-other-month-visibility: hidden;
  --mds-calendar-cell-background: rgb(var(--magma-wash-soft));
  --mds-calendar-cell-color: rgb(var(--magma-text-muted));
}
```
