<!--
  GENERATED FILE - do not edit by hand.
  Source of truth: src/components/mds-input-date-range-preselection/ in the magma monorepo (usage/*.md and the
  component's JSDoc). Regenerated on every stencil build (scripts/component-docs.ts).
-->

# mds-input-date-range-preselection

> `@maggioli-design-system/magma` 2.15.0. Shadow DOM: style it only through the public CSS custom properties and the parts below.

The `<mds-input-date-range-preselection>` web component is a compound child of [`<mds-input-date-range>`](../mds-input-date-range/AGENTS.md). It renders a clickable shortcut button (a quick range like "Last 7 days" or "This month") that, when activated, fills the parent's date range with a predefined `start`/`end` pair instead of requiring the user to pick dates manually on the calendar.

#### Semantic Behavior

- **Compound child**: Placed as a direct child of `<mds-input-date-range>`, it assigns itself to the parent's `calendar-preselection` slot. A `slot` set by the author is kept, so it can also sit in the `preselection` slot of [`<mds-calendar>`](../mds-calendar/AGENTS.md): there it applies nothing itself, and its click reaches the page, which sets the range.
- **Click drives the parent**: On click it applies its `start`/`end` range to the parent, which populates and validates the range, syncs the form value, emits the parent's `mdsInputDateRangeValueChange` if the range changed, and closes the dropdown after the parent's `delay` (unless it is `0`).
- **Selection is parent-managed**: Choosing one preselection clears the active state on its siblings and marks the active one; the parent also re-marks a preselection as selected when the range changes to match its dates (including single-day matches where `end` is undefined); a range set at first load is not matched until it changes or the user leaves the component.

#### Properties & Visual Configurations

- **`start`** (required) and **`end`**: Define the ISO date range this shortcut applies. Provide both for a true range; omit `end` to express a single-day preselection.
- **`selected`**: Reflects whether this preselection is currently the active one. Treat it as read-only in normal use - the parent sets it; do not hand-toggle it to drive selection.

The default slot holds the human-readable label. Visual states (default, hover, selected) follow the theme: the component has no public CSS custom property and does not expose `variant`/`tone` props of its own.

## Read next

- [`examples.md`](examples.md) - correct usage, from the most common case
- [`mistakes.md`](mistakes.md) - the wrong forms, each with the right one
- [Storybook](https://magma-design-system.github.io/magma/storybook/?path=/docs/form-input-date-range-preselection--docs) - the live examples, in the published Storybook of `main`
- [`conventions.md`](../../../../agents/conventions.md), [`variants.md`](../../../../agents/variants.md), [`mistakes.md`](../../../../agents/mistakes.md) - the rules shared by every component

## Props

| Prop | Attribute | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `end` | `end` | `string \| undefined` | - | Sets the end date of the preselection |
| `selected` | `selected` | `boolean \| undefined` | - | Sets the preselection date range |
| `start` | `start` | `string` | - | **Required**. Sets the start date of the preselection |

## Slots

| Slot | Description |
| --- | --- |
| (default) | Add the `text string` of the preselection, as `Last 7 days`: it becomes the label of the button that applies the range. **Avoid** `HTML elements` or `components`, which end up inside an `mds-button`. |

## CSS custom properties

None is public: its 9 custom properties are internal and may change in any release. Style it with its props, its parts and the semantic roles.

## Dependencies

Uses: `mds-button`.
