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

# mds-horizontal-scroll

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

The `<mds-horizontal-scroll>` web component is a horizontally scrolling container of the Magma Design System. It wraps any slotted content in a snap-scrolling viewport and overlays optional navigation controls, replacing the manual overflow/scroll-snap CSS plumbing you would otherwise write around a `<div>`.

#### Semantic Behavior

- **Slotted children drive scrolling**: The default slot's children are the scrollable items.
- **Navigation buttons**: When `controls` resolves to a viewport other than `'none'`, two arrow buttons are rendered, icon-only and named in the page language (the `lang` of `<html>`) ("Scroll back", "Scroll forward"); each advances the scroll position to the next/previous item not fully in the viewport. Browsers without the `scrollend` event get no arrows: the component clears `controls` there.
- **Auto-disabled arrows**: The back arrow hides/disables when the first item is fully visible and the forward arrow when the last item is.
- **Position indicator**: With `navigation="position"` a proportional dot is rendered; its width reflects the visible/total ratio and it translates along its track as the container scrolls.
- **No focus or form semantics**: This is a presentational scroll container - it is not form-associated, exposes no implicit ARIA role, and emits no custom events.

#### Properties & Visual Configurations

- **`controls`** selects the smallest viewport breakpoint at which the arrow navigation appears (default `'desktop'`); pick a wider tier like `'large'` or `'wide'` to show arrows only on big screens, or `'none'` to suppress them entirely. The chosen value is the threshold, not a single device.
- **`navigation`** chooses the scroll-progress affordance: `'position'` renders the translating dot indicator, `'scrollbar'` defers to the styled native browser scrollbar, and `'none'` shows neither.
- **`snap`** sets the scroll-snap alignment of each item against the viewport - `'start'` (default) aligns items to the leading edge, `'center'` keeps them centred, `'end'` to the trailing edge, and `'none'` disables snapping for free scrolling.

This component does not use the shared `variant` / `tone` ladders defined in [`agents/variants.md`](../../../../agents/variants.md); its public CSS custom properties set the layout (the width of the items area and the margin of the controls) and its colours follow the theme (see [`AGENTS.md`](AGENTS.md)).

## 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/layout-horizontal-scroll--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 |
| --- | --- | --- | --- | --- |
| `controls` | `controls` | `"all" \| "desktop" \| "large" \| "none" \| "tablet" \| "tv" \| "wide" \| "xlarge" \| undefined` | `'desktop'` | Specifies the viewport which will display navigation controls |
| `navigation` | `navigation` | `"none" \| "position" \| "scrollbar" \| undefined` | `'position'` | Specifies the box’s snap position as an alignment of its snap area |
| `snap` | `snap` | `"center" \| "end" \| "none" \| "start" \| undefined` | `'start'` | Specifies the box’s snap position as an alignment of its snap area |

## Slots

| Slot | Description |
| --- | --- |
| (default) | Add `text string`, `HTML elements` or `components` to this slot. |

## Parts

| Part | Description |
| --- | --- |
| `content` | The track that scrolls, with the default slot inside |

## CSS custom properties

| Property | Description |
| --- | --- |
| `--mds-horizontal-scroll-controls-margin` | Sets how far the back and forward controls sit outside the area of the slotted elements, 48px by default; `0px` keeps them on its edges |
| `--mds-horizontal-scroll-max-width` | Sets the max-width of the slotted elements container, to keep layout limited as the rest of the sections |

Only these are public. Its other 9 are internal: they may change in any release, do not set them.

## Dependencies

Uses: `mds-button`.
