# `<ixfx-labelled-slider-input>`

A composite slider input that pairs an editable label (`ixfx-editable-number`) with a slider (`ixfx-slider-input`). The two controls are always in sync — dragging the slider updates the number, and editing the number moves the slider.

## Basic usage

```html
<ixfx-labelled-slider-input label="Volume" value="0.5" min="0" max="1" step="0.01">
</ixfx-labelled-slider-input>
```

## Layout

Layout is driven by a container query on the component's own height.

| Height          | Layout                          |
|-----------------|---------------------------------|
| >= 80px (default) | **Vertical** — label above slider |
| < 80px          | **Horizontal** — label beside slider |

The component defaults to `height: 100px`, so unconstrained usage shows the vertical layout. Constrain the height in your CSS to switch to horizontal.

### Force a layout with `--flow`

Override the container query entirely:

```html
<ixfx-labelled-slider-input style="--flow: row" ...>   <!-- always horizontal -->
<ixfx-labelled-slider-input style="--flow: column" ...> <!-- always vertical   -->
```

### Control label width (horizontal layout)

```html
<ixfx-labelled-slider-input style="--label-width: 8em" ...>
```

## Mini mode

When the component is very small the label is hidden and only the slider is shown.

Mini mode activates when **both** of the following are true:
- `width < mini-width-threshold` (default 120px)
- `height < mini-height-threshold` (default 40px)

Override with a CSS variable:

```html
<ixfx-labelled-slider-input style="--mini: 1" ...> <!-- always mini  -->
<ixfx-labelled-slider-input style="--mini: 0" ...> <!-- never mini   -->
```

## Formatter

Apply a function to format the displayed value. Set it as a JS property — it cannot be set as an HTML attribute.

```js
const el = document.querySelector('ixfx-labelled-slider-input');
el.formatter = (v) => `${Math.round(Number(v))}%`;
```

The formatter receives the raw string value and returns the string to display in the editable-number label. Note the inner slider has no tooltip — the label already shows the value, so a tooltip would be redundant.

## Properties / attributes

| Attribute              | Type                                          | Default      | Description                                         |
|------------------------|-----------------------------------------------|--------------|-----------------------------------------------------|
| `label`                | `string`                                      | `""`         | Label text shown in the editable-number             |
| `value`                | `number`                                      | `0`          | Current value                                       |
| `min`                  | `number`                                      | `0`          | Minimum value                                       |
| `max`                  | `number`                                      | `1`          | Maximum value                                       |
| `step`                 | `number`                                      | `0.01`       | Step increment                                      |
| `stops`                | `number`                                      | —            | Quantise to N discrete positions                    |
| `drag-sensitivity`     | `number`                                      | `1`          | Steps per pixel when dragging the number label      |
| `precision`            | `number`                                      | `0`          | Decimal places shown                                |
| `orientation`          | `"horizontal" \| "vertical"`                  | `"horizontal"` | Slider track orientation                          |
| `single-style`         | `"range" \| "bipolar" \| "unipolar"`          | `"range"`    | How the value bar is drawn                          |
| `marker-style`         | `"needle" \| "dot" \| "triangle" \| "none"`   | `"needle"`   | Marker shape                                        |
| `disabled`             | `boolean`                                     | `false`      | Disables all interaction                            |
| `swipeable`            | `boolean`                                     | `false`      | Swipe-to-draw gesture (step-sequencer layouts)      |
| `switch-height`        | `number`                                      | `80`         | Height (px) at which layout switches vertical↔horizontal |
| `mini-width-threshold` | `number`                                      | `120`        | Width (px) below which mini mode can activate       |
| `mini-height-threshold`| `number`                                      | `40`         | Height (px) below which mini mode can activate      |
| `display-text-logic`   | `"hidden" \| "show" \| "override" \| "transient"` | `"transient"` | Controls when label text vs value is shown    |
| `formatter`            | `(value: string) => string`                   | —            | JS property only — formats value for display |
| `lighttouch`           | `boolean`                                     | `false`      | Wheel adjusts the value on hover without focus      |

### `display-text-logic` values

| Value       | Behaviour                                              |
|-------------|--------------------------------------------------------|
| `transient` | Shows the label when idle, value on hover/interaction  |
| `show`      | Always shows the value                                 |
| `hidden`    | Always shows the label text, never the value           |
| `override`  | Label text replaces value at all times                 |

## Events

| Event    | Detail                    | Description                                              |
|----------|---------------------------|----------------------------------------------------------|
| `change` | `{ value: string }`       | Fired when the value is committed (slider release or number edit) |
| `input`  | `{ value: number }`       | Fired on every slider move                               |

Both events bubble and are composed (cross shadow boundary).

## CSS variables

### Layout

| Variable                 | Default      | Description                                               |
|--------------------------|--------------|-----------------------------------------------------------|
| `--height`               | `100px`      | Component height. Set to `100%` to fill a constrained parent |
| `--width`                | `auto`       | Component width                                           |
| `--min-height`           | `20px`       | Minimum height                                            |
| `--min-width`            | `50px`       | Minimum width                                             |
| `--flow`                 | *(container query)* | `row` or `column` — overrides the automatic layout |
| `--label-width`          | `5ch`        | Width of the editable-number in horizontal layout         |
| `--mini`                 | *(auto)*     | `1` to force mini mode, `0` to disable it                 |

### Label (passed to `ixfx-editable-number`)

| Variable              | Default                    | Description              |
|-----------------------|----------------------------|--------------------------|
| `--label-font-size`   | `var(--text-m)`            | Font size                |
| `--label-font-family` | `var(--font-family)`       | Font family              |
| `--label-color`       | `var(--surface-text)`      | Text colour              |
| `--label-muted-color` | `var(--surface-muted-text)`| Muted text colour        |
| `--label-padding`     | `var(--space-xs) var(--space-s)` | Padding             |
| `--label-radius`      | `var(--radius-s)`          | Border radius            |
| `--label-align`       | `center`                   | Text alignment           |

### Slider (passed to `ixfx-slider-input`)

| Variable                          | Default                  | Description                              |
|-----------------------------------|--------------------------|------------------------------------------|
| `--lane-track-color`              | `var(--surface-4)`       | Colour of the background track lane      |
| `--lane-value-color`              | `var(--accent)`          | Colour of the value lane                 |
| `--lane-color`                    | `var(--accent)`          | Fallback colour for custom lanes         |
| `--lane-dasharray`                | `none`                   | Dash pattern for lanes                   |
| `--marker-color`                  | `var(--accent)`          | Marker colour                            |
| `--marker-thickness`              | `0.15`                   | Marker thickness (fraction of cross axis)|
| `--marker-length`                 | `0.8`                    | Needle length (fraction of cross axis)   |
| `--marker-offset`                 | `0`                      | Perpendicular offset from centreline     |
| `--track-color`                   | `var(--surface-4)`       | Track stroke colour                      |
| `--track-width`                   | `2`                      | Track stroke width (SVG units)           |

See `ixfx-slider-input` for the full list of lane, marker, and midpoint variables.

## Examples

### Horizontal layout with percentage formatter

```html
<ixfx-labelled-slider-input
  id="my-slider"
  label="Mix"
  value="0.75"
  style="height: 50px"
></ixfx-labelled-slider-input>

<script type="module">
  document.querySelector('#my-slider').formatter = (v) =>
    `${Math.round(Number(v) * 100)}%`;
</script>
```

### Custom slider colours

```html
<ixfx-labelled-slider-input
  label="Intensity"
  value="0.7"
  style="
    --lane-value-color: hsl(280, 80%, 60%);
    --lane-track-color: hsl(280, 30%, 30%);
    --marker-color: hsl(280, 100%, 70%);
  "
></ixfx-labelled-slider-input>
```

### Force mini mode

```html
<ixfx-labelled-slider-input label="Vol" value="0.5" style="--mini: 1">
</ixfx-labelled-slider-input>
```

### Listen for changes

```js
const el = document.querySelector('ixfx-labelled-slider-input');

// Committed value (slider release or number edit)
el.addEventListener('change', (e) => console.log(e.detail.value));

// Every slider move
el.addEventListener('input', (e) => console.log(e.detail.value));
```
