# Slider

Range slider built on a native input type range, with a primary fill, a round thumb, and the current value shown next to the label.

- Category: Form
- Status: stable
- Registry: https://markas.jenderalcorp.com/r/slider.json
- CLI: `npx markasui@latest add slider`

## When to use

Picking an approximate number in a known range where the exact value matters less than the position, such as volume, brightness, or a price limit.

- Use Input type number when users need to type an exact value
- Always give a label, or aria-label when the label is not visible
- Keep the step coarse enough to reach every value with the keyboard

## Code

### Blade

Save at `resources/views/components/markas/slider.blade.php`. Dependencies: alpinejs.

```blade
@props([
    'label' => null,
    'min' => 0,
    'max' => 100,
    'step' => 1,
    'value' => null,
    'showValue' => true,
])

@php
    // wire:model.live without its own timing gets the 150 ms debounce Livewire gives text inputs, so a burst of changes sends one request, not one per change.
    $liveModel = fn (string $key) => preg_match('/^wire:model(\.[\w-]+)*\.live(\.|$)/', $key) && ! preg_match('/\.(debounce|throttle|blur|change|lazy|enter)(\.|$)/', $key);
    $attributes = new \Illuminate\View\ComponentAttributeBag(collect($attributes->getAttributes())->mapWithKeys(fn ($bound, $key) => [$liveModel($key) ? $key.'.debounce.150ms' : $key => $bound])->all());

    $root = 'group grid gap-3 has-disabled:cursor-not-allowed';
    $header = 'flex items-center justify-between gap-4 text-sm';
    $labelClass = 'font-medium text-ink group-has-disabled:opacity-50';
    $valueClass = 'ml-auto text-muted tabular-nums group-has-disabled:text-faint';
    $range = 'h-4 w-full cursor-pointer appearance-none bg-transparent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary disabled:cursor-not-allowed disabled:opacity-50 [&::-moz-range-thumb]:size-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-2 [&::-moz-range-thumb]:border-primary [&::-moz-range-thumb]:bg-surface [&::-moz-range-track]:h-1.5 [&::-moz-range-track]:rounded-full [&::-moz-range-track]:bg-[linear-gradient(to_right,var(--color-primary)_var(--value),var(--color-line)_var(--value))] [&::-webkit-slider-runnable-track]:h-1.5 [&::-webkit-slider-runnable-track]:rounded-full [&::-webkit-slider-runnable-track]:bg-[linear-gradient(to_right,var(--color-primary)_var(--value),var(--color-line)_var(--value))] [&::-webkit-slider-thumb]:-mt-[5px] [&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-primary [&::-webkit-slider-thumb]:bg-surface';

    $current = $value ?? $min;
    $percent = $max > $min ? (($current - $min) / ($max - $min)) * 100 : 0;
    // Same id on every render, so Livewire's morph (which matches elements by id) keeps the element. Pass `id` to set it.
    $idKey = 'markas-slider|'.(isset($this) && $this instanceof \Livewire\Component ? $this->getId() : '').'|'.($attributes->get('wire:key') ?? $attributes->whereStartsWith('wire:model')->first() ?? $attributes->get('name')).'|';
    for ($idIndex = 0; $__env->hasRenderedOnce($idKey.$idIndex); $idIndex++);
    $__env->markAsRenderedOnce($idKey.$idIndex);
    $id = $attributes->get('id') ?? 'markas-slider-'.hash('xxh32', $idKey.$idIndex);
@endphp

{{-- wire:model and x-model bind to `value` on the root (x-modelable); other attributes land on the range input. --}}
<div
    x-data="{
        value: @js($current),
        min: @js($min),
        max: @js($max),
        get percent() {
            return this.max > this.min ? ((this.value - this.min) / (this.max - this.min)) * 100 : 0;
        },
    }"
    x-modelable="value"
    {{ $attributes->whereStartsWith(['wire:model', 'x-model']) }}
    class="{{ $root }}"
>
    @if ($label || $showValue)
        <div class="{{ $header }}">
            @if ($label)
                <label for="{{ $id }}" class="{{ $labelClass }}">{{ $label }}</label>
            @endif
            @if ($showValue)
                <span class="{{ $valueClass }}" aria-hidden="true" x-text="value">{{ $current }}</span>
            @endif
        </div>
    @endif
    <input
        type="range"
        min="{{ $min }}"
        max="{{ $max }}"
        step="{{ $step }}"
        value="{{ $current }}"
        style="--value: {{ $percent }}%"
        x-bind:value="value"
        x-bind:style="'--value: ' + percent + '%'"
        x-on:input="value = $event.target.valueAsNumber"
        {{ $attributes->whereDoesntStartWith(['wire:model', 'x-model'])->merge(['id' => $id])->class([$range]) }}
    />
</div>
```

```blade
<x-markas.slider name="volume" label="Volume" :value="60" />
<x-markas.slider name="budget" label="Budget" :min="0" :max="500" :step="25" :value="250" />
```

Needs Alpine.js to update the fill and the value while dragging.

### Livewire

```blade
<x-markas.slider label="Volume" wire:model.live="volume" />
```

`wire:model` binds to the slider value through `x-modelable` on the wrapper, so the number label follows server changes too. Use `wire:model.live.debounce.300ms` to send fewer requests while dragging. Other attributes land on the range input.

### React

Save at `src/components/markas/Slider.tsx`. No extra dependencies.

```tsx
"use client";

import {
  useId,
  useState,
  type ChangeEvent,
  type ComponentProps,
  type CSSProperties,
  type ReactNode,
} from "react";

const root = "group grid gap-3 has-disabled:cursor-not-allowed";
const header = "flex items-center justify-between gap-4 text-sm";
const labelClass = "font-medium text-ink group-has-disabled:opacity-50";
const valueClass =
  "ml-auto text-muted tabular-nums group-has-disabled:text-faint";
const range =
  "h-4 w-full cursor-pointer appearance-none bg-transparent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary disabled:cursor-not-allowed disabled:opacity-50 [&::-moz-range-thumb]:size-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-2 [&::-moz-range-thumb]:border-primary [&::-moz-range-thumb]:bg-surface [&::-moz-range-track]:h-1.5 [&::-moz-range-track]:rounded-full [&::-moz-range-track]:bg-[linear-gradient(to_right,var(--color-primary)_var(--value),var(--color-line)_var(--value))] [&::-webkit-slider-runnable-track]:h-1.5 [&::-webkit-slider-runnable-track]:rounded-full [&::-webkit-slider-runnable-track]:bg-[linear-gradient(to_right,var(--color-primary)_var(--value),var(--color-line)_var(--value))] [&::-webkit-slider-thumb]:-mt-[5px] [&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-primary [&::-webkit-slider-thumb]:bg-surface";
const cx = (...c: (string | false | null | undefined)[]) =>
  c.filter(Boolean).join(" ");

const toPercent = (value: number, min: number, max: number) =>
  max > min ? ((value - min) / (max - min)) * 100 : 0;

export type SliderProps = Omit<
  ComponentProps<"input">,
  "type" | "value" | "defaultValue" | "min" | "max" | "step"
> & {
  label?: ReactNode;
  min?: number;
  max?: number;
  step?: number;
  value?: number;
  defaultValue?: number;
  showValue?: boolean;
  onValueChange?: (value: number) => void;
};

export function Slider({
  label,
  min = 0,
  max = 100,
  step = 1,
  value,
  defaultValue,
  showValue = true,
  onValueChange,
  onChange,
  id,
  className,
  style,
  ...props
}: SliderProps) {
  const generatedId = useId();
  const sliderId = id ?? generatedId;
  const [internal, setInternal] = useState(defaultValue ?? min);
  const current = value ?? internal;

  const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
    const next = event.currentTarget.valueAsNumber;
    setInternal(next);
    onChange?.(event);
    onValueChange?.(next);
  };

  return (
    <div className={root}>
      {(label || showValue) && (
        <div className={header}>
          {label && (
            <label htmlFor={sliderId} className={labelClass}>
              {label}
            </label>
          )}
          {showValue && (
            <span className={valueClass} aria-hidden="true">
              {current}
            </span>
          )}
        </div>
      )}
      <input
        id={sliderId}
        min={min}
        max={max}
        step={step}
        value={current}
        style={
          {
            ...style,
            "--value": `${toPercent(current, min, max)}%`,
          } as CSSProperties
        }
        onChange={handleChange}
        className={cx(range, className)}
        {...props}
        type="range"
      />
    </div>
  );
}
```

```tsx
import { Slider } from "@/components/markas/Slider";

<Slider
  name="volume"
  label="Volume"
  defaultValue={60}
  onValueChange={(value) => console.log(value)}
/>;
```

### Vue

Save at `src/components/markas/Slider.vue`. No extra dependencies.

```vue
<script setup lang="ts">
import { computed, useId } from "vue";

defineOptions({ inheritAttrs: false });

const props = withDefaults(
  defineProps<{
    label?: string;
    min?: number;
    max?: number;
    step?: number;
    defaultValue?: number;
    showValue?: boolean;
    id?: string;
  }>(),
  {
    label: undefined,
    min: 0,
    max: 100,
    step: 1,
    defaultValue: undefined,
    showValue: true,
    id: undefined,
  },
);
const model = defineModel<number>();

const root = "group grid gap-3 has-disabled:cursor-not-allowed";
const header = "flex items-center justify-between gap-4 text-sm";
const labelClass = "font-medium text-ink group-has-disabled:opacity-50";
const valueClass =
  "ml-auto text-muted tabular-nums group-has-disabled:text-faint";
const range =
  "h-4 w-full cursor-pointer appearance-none bg-transparent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary disabled:cursor-not-allowed disabled:opacity-50 [&::-moz-range-thumb]:size-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-2 [&::-moz-range-thumb]:border-primary [&::-moz-range-thumb]:bg-surface [&::-moz-range-track]:h-1.5 [&::-moz-range-track]:rounded-full [&::-moz-range-track]:bg-[linear-gradient(to_right,var(--color-primary)_var(--value),var(--color-line)_var(--value))] [&::-webkit-slider-runnable-track]:h-1.5 [&::-webkit-slider-runnable-track]:rounded-full [&::-webkit-slider-runnable-track]:bg-[linear-gradient(to_right,var(--color-primary)_var(--value),var(--color-line)_var(--value))] [&::-webkit-slider-thumb]:-mt-[5px] [&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-primary [&::-webkit-slider-thumb]:bg-surface";

const generatedId = useId();
const sliderId = computed(() => props.id ?? generatedId);
const current = computed(() => model.value ?? props.defaultValue ?? props.min);
const percent = computed(() =>
  props.max > props.min
    ? ((current.value - props.min) / (props.max - props.min)) * 100
    : 0,
);

function onInput(event: Event) {
  model.value = (event.target as HTMLInputElement).valueAsNumber;
}
</script>

<template>
  <div :class="root">
    <div v-if="props.label || props.showValue" :class="header">
      <label v-if="props.label" :for="sliderId" :class="labelClass">{{
        props.label
      }}</label>
      <span v-if="props.showValue" :class="valueClass" aria-hidden="true">{{
        current
      }}</span>
    </div>
    <input
      :id="sliderId"
      :min="props.min"
      :max="props.max"
      :step="props.step"
      :value="current"
      :style="{ '--value': `${percent}%` }"
      :class="range"
      v-bind="$attrs"
      type="range"
      @input="onInput"
    />
  </div>
</template>
```

```vue
<script setup lang="ts">
import { ref } from "vue";
import Slider from "@/components/markas/Slider.vue";

const volume = ref(60);
</script>

<template>
  <Slider v-model="volume" name="volume" label="Volume" />
</template>
```

### Svelte

Save at `src/lib/components/markas/Slider.svelte`. No extra dependencies.

```svelte
<script lang="ts">
  import type { HTMLInputAttributes } from "svelte/elements";

  const root = "group grid gap-3 has-disabled:cursor-not-allowed";
  const header = "flex items-center justify-between gap-4 text-sm";
  const labelClass = "font-medium text-ink group-has-disabled:opacity-50";
  const valueClass =
    "ml-auto text-muted tabular-nums group-has-disabled:text-faint";
  const range =
    "h-4 w-full cursor-pointer appearance-none bg-transparent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary disabled:cursor-not-allowed disabled:opacity-50 [&::-moz-range-thumb]:size-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-2 [&::-moz-range-thumb]:border-primary [&::-moz-range-thumb]:bg-surface [&::-moz-range-track]:h-1.5 [&::-moz-range-track]:rounded-full [&::-moz-range-track]:bg-[linear-gradient(to_right,var(--color-primary)_var(--value),var(--color-line)_var(--value))] [&::-webkit-slider-runnable-track]:h-1.5 [&::-webkit-slider-runnable-track]:rounded-full [&::-webkit-slider-runnable-track]:bg-[linear-gradient(to_right,var(--color-primary)_var(--value),var(--color-line)_var(--value))] [&::-webkit-slider-thumb]:-mt-[5px] [&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-primary [&::-webkit-slider-thumb]:bg-surface";

  const toPercent = (value: number, min: number, max: number) =>
    max > min ? ((value - min) / (max - min)) * 100 : 0;

  type Props = Omit<
    HTMLInputAttributes,
    "type" | "value" | "min" | "max" | "step"
  > & {
    label?: string;
    min?: number;
    max?: number;
    step?: number;
    /** Current value, bindable with bind:value. */
    value?: number;
    showValue?: boolean;
  };

  let {
    label,
    min = 0,
    max = 100,
    step = 1,
    value = $bindable(),
    showValue = true,
    id,
    class: className,
    oninput,
    ...rest
  }: Props = $props();

  const generatedId = $props.id();
  const sliderId = $derived(id ?? generatedId);
  const current = $derived(value ?? min);

  function handleInput(
    event: Event & { currentTarget: EventTarget & HTMLInputElement },
  ) {
    value = event.currentTarget.valueAsNumber;
    oninput?.(event);
  }
</script>

<div class={root}>
  {#if label || showValue}
    <div class={header}>
      {#if label}
        <label for={sliderId} class={labelClass}>{label}</label>
      {/if}
      {#if showValue}
        <span class={valueClass} aria-hidden="true">{current}</span>
      {/if}
    </div>
  {/if}
  <input
    id={sliderId}
    {min}
    {max}
    {step}
    value={current}
    style:--value={`${toPercent(current, min, max)}%`}
    oninput={handleInput}
    class={[range, className]}
    {...rest}
    type="range"
  />
</div>
```

```svelte
<script lang="ts">
  import Slider from "$lib/components/markas/Slider.svelte";

  let volume = $state(60);
</script>

<Slider bind:value={volume} name="volume" label="Volume" />
<Slider name="budget" label="Budget" max={500} step={25} value={250} />
```

### Astro

Save at `src/components/markas/Slider.astro`. No extra dependencies.

```astro
---
import type { HTMLAttributes } from "astro/types";

const root = "group grid gap-3 has-disabled:cursor-not-allowed";
const header = "flex items-center justify-between gap-4 text-sm";
const labelClass = "font-medium text-ink group-has-disabled:opacity-50";
const valueClass =
  "ml-auto text-muted tabular-nums group-has-disabled:text-faint";
const range =
  "h-4 w-full cursor-pointer appearance-none bg-transparent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary disabled:cursor-not-allowed disabled:opacity-50 [&::-moz-range-thumb]:size-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-2 [&::-moz-range-thumb]:border-primary [&::-moz-range-thumb]:bg-surface [&::-moz-range-track]:h-1.5 [&::-moz-range-track]:rounded-full [&::-moz-range-track]:bg-[linear-gradient(to_right,var(--color-primary)_var(--value),var(--color-line)_var(--value))] [&::-webkit-slider-runnable-track]:h-1.5 [&::-webkit-slider-runnable-track]:rounded-full [&::-webkit-slider-runnable-track]:bg-[linear-gradient(to_right,var(--color-primary)_var(--value),var(--color-line)_var(--value))] [&::-webkit-slider-thumb]:-mt-[5px] [&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-primary [&::-webkit-slider-thumb]:bg-surface";

const toPercent = (value: number, min: number, max: number) =>
  max > min ? ((value - min) / (max - min)) * 100 : 0;

type Props = Omit<
  HTMLAttributes<"input">,
  "type" | "value" | "min" | "max" | "step"
> & {
  label?: string;
  min?: number;
  max?: number;
  step?: number;
  value?: number;
  showValue?: boolean;
};

const {
  label,
  min = 0,
  max = 100,
  step = 1,
  value,
  showValue = true,
  id,
  class: className,
  ...rest
} = Astro.props;
const sliderId = id ?? `markas-slider-${crypto.randomUUID().slice(0, 8)}`;
const current = value ?? min;
---

<div class={root} data-markas-slider>
  {
    (label || showValue) && (
      <div class={header}>
        {label && (
          <label for={sliderId} class={labelClass}>
            {label}
          </label>
        )}
        {showValue && (
          <span class={valueClass} aria-hidden="true" data-markas-slider-value>
            {current}
          </span>
        )}
      </div>
    )
  }
  <input
    id={sliderId}
    min={min}
    max={max}
    step={step}
    value={current}
    style={`--value: ${toPercent(current, min, max)}%`}
    class:list={[range, className]}
    {...rest}
    type="range"
  />
</div>

<script>
  // One listener per page serves every slider: it updates the track fill and the number.
  document.addEventListener("input", (event) => {
    const input = event.target;
    if (!(input instanceof HTMLInputElement) || input.type !== "range") return;
    const root = input.parentElement;
    if (!root?.hasAttribute("data-markas-slider")) return;
    const min = Number(input.min);
    const max = Number(input.max);
    const value = input.valueAsNumber;
    const percent = max > min ? ((value - min) / (max - min)) * 100 : 0;
    input.style.setProperty("--value", `${percent}%`);
    const output = root.querySelector("[data-markas-slider-value]");
    if (output) output.textContent = String(value);
  });
</script>
```

```astro
---
import Slider from "@/components/markas/Slider.astro";
---

<Slider name="volume" label="Volume" value={60} />
```

A small page script updates the fill and the value while dragging.

### Angular

Save at `src/app/markas/slider.component.ts`. No extra dependencies.

```ts
import {
  booleanAttribute,
  ChangeDetectionStrategy,
  Component,
  computed,
  input,
  linkedSignal,
  numberAttribute,
  output,
} from "@angular/core";

const root = "group grid gap-3 has-disabled:cursor-not-allowed";
const header = "flex items-center justify-between gap-4 text-sm";
const labelClass = "font-medium text-ink group-has-disabled:opacity-50";
const valueClass =
  "ml-auto text-muted tabular-nums group-has-disabled:text-faint";
const range =
  "h-4 w-full cursor-pointer appearance-none bg-transparent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary disabled:cursor-not-allowed disabled:opacity-50 [&::-moz-range-thumb]:size-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-2 [&::-moz-range-thumb]:border-primary [&::-moz-range-thumb]:bg-surface [&::-moz-range-track]:h-1.5 [&::-moz-range-track]:rounded-full [&::-moz-range-track]:bg-[linear-gradient(to_right,var(--color-primary)_var(--value),var(--color-line)_var(--value))] [&::-webkit-slider-runnable-track]:h-1.5 [&::-webkit-slider-runnable-track]:rounded-full [&::-webkit-slider-runnable-track]:bg-[linear-gradient(to_right,var(--color-primary)_var(--value),var(--color-line)_var(--value))] [&::-webkit-slider-thumb]:-mt-[5px] [&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-primary [&::-webkit-slider-thumb]:bg-surface";

const toPercent = (value: number, min: number, max: number) =>
  max > min ? ((value - min) / (max - min)) * 100 : 0;
const optionalNumber = (value: unknown) =>
  value === undefined || value === null || value === ""
    ? undefined
    : numberAttribute(value);

let nextId = 0;

/**
 * Host stays out of layout (display: contents). id, name, aria-label, and class move to the
 * input, so the host attributes are cleared.
 */
@Component({
  selector: "markas-slider",
  changeDetection: ChangeDetectionStrategy.OnPush,
  host: {
    class: "contents",
    "[attr.id]": "null",
    "[attr.name]": "null",
    "[attr.label]": "null",
    "[attr.aria-label]": "null",
  },
  template: `
    <div [class]="root">
      @if (label() || showValue()) {
        <div [class]="header">
          @if (label()) {
            <label [for]="sliderId()" [class]="labelClass">{{ label() }}</label>
          }
          @if (showValue()) {
            <span [class]="valueClass" aria-hidden="true">{{ current() }}</span>
          }
        </div>
      }
      <input
        #field
        type="range"
        [id]="sliderId()"
        [min]="min()"
        [max]="max()"
        [step]="step()"
        [value]="current()"
        [disabled]="disabled()"
        [attr.name]="name() ?? null"
        [attr.aria-label]="ariaLabel() ?? null"
        [style.--value]="percent()"
        [class]="rangeClass()"
        (input)="update(field.valueAsNumber)"
      />
    </div>
  `,
})
export class Slider {
  readonly label = input<string>();
  readonly min = input(0, { transform: numberAttribute });
  readonly max = input(100, { transform: numberAttribute });
  readonly step = input(1, { transform: numberAttribute });
  readonly value = input<number | undefined, unknown>(undefined, {
    transform: optionalNumber,
  });
  readonly showValue = input(true, { transform: booleanAttribute });
  readonly disabled = input(false, { transform: booleanAttribute });
  readonly id = input<string>();
  readonly name = input<string>();
  readonly ariaLabel = input<string | undefined>(undefined, {
    alias: "aria-label",
  });
  readonly userClass = input("", { alias: "class" });
  /** Emits the new number; together with `value` this enables `[(value)]`. */
  readonly valueChange = output<number>();

  protected readonly root = root;
  protected readonly header = header;
  protected readonly labelClass = labelClass;
  protected readonly valueClass = valueClass;
  private readonly generatedId = `markas-slider-${nextId++}`;
  protected readonly sliderId = computed(() => this.id() ?? this.generatedId);
  protected readonly current = linkedSignal(() => this.value() ?? this.min());
  protected readonly percent = computed(
    () => `${toPercent(this.current(), this.min(), this.max())}%`,
  );
  protected readonly rangeClass = computed(() =>
    [range, this.userClass()].filter(Boolean).join(" "),
  );

  protected update(value: number) {
    this.current.set(value);
    this.valueChange.emit(value);
  }
}
```

```ts
import { Component, signal } from "@angular/core";
import { Slider } from "./markas/slider.component";

@Component({
  selector: "app-sound",
  imports: [Slider],
  template: `
    <markas-slider [(value)]="volume" name="volume" label="Volume" />
    <markas-slider
      name="budget"
      label="Budget"
      max="500"
      step="25"
      value="250"
    />
  `,
})
export class Sound {
  readonly volume = signal(60);
}
```

## Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `label` | `string` | - | Label text above the slider, linked through for/id. Without it, pass aria-label. |
| `min` | `number` | 0 | Lowest value. |
| `max` | `number` | 100 | Highest value. |
| `step` | `number` | 1 | Increment used by dragging and the arrow keys. |
| `value / defaultValue / v-model / bind:value` | `number` | min | Current value. Blade and Astro use value, React value or defaultValue, Vue v-model or defaultValue, Svelte bind:value, Angular value or [(value)]. |
| `onValueChange` | `(value: number) => void` | - | React only. Called with the new number on every input. |
| `valueChange` | `output<number>` | - | Angular only. Emits the new number on every input. |
| `showValue` | `boolean` | true | Shows the current value on the right of the label with tabular numbers. |
| `disabled` | `boolean` | false | Disables the slider and dims the label. |
| `id` | `string` | auto | Input id. Generated when empty. |

## Accessibility

- A native input type range, so screen readers announce the role slider and the current value.
- Arrow keys, Page Up, Page Down, Home, and End change the value natively.
- The visible value is aria-hidden because the slider already announces it.

## Notes

- Slider is an `<input type="range">`, so its value is submitted with the form and the keyboard works natively.
- The fill comes from the CSS variable `--value` (a percentage) that the component updates on every input.
- Without a visible label, pass `aria-label` and set `showValue` to false if the number is not needed.
- The component has no built-in text. Translate `label` directly.
