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.
<div class="grid gap-6">
<x-markas.slider name="volume" label="Volume" :value="60" />
<x-markas.slider name="brightness" label="Brightness" :step="10" :value="30" />
</div><script lang="ts">
import Slider from "$lib/components/markas/Slider.svelte";
</script>
<div class="grid gap-6">
<Slider name="volume" label="Volume" value={60} />
<Slider name="brightness" label="Brightness" step={10} value={30} />
</div>---
import Slider from "@/components/markas/Slider.astro";
---
<div class="grid gap-6">
<Slider name="volume" label="Volume" value={60} />
<Slider name="brightness" label="Brightness" step={10} value={30} />
</div>Examples
Range labels
<div class="grid gap-2">
<x-markas.slider name="budget" label="Budget" :max="500" :step="25" :value="250" />
<div class="flex justify-between text-xs text-muted">
<span>0</span>
<span>500</span>
</div>
</div><script lang="ts">
import Slider from "$lib/components/markas/Slider.svelte";
</script>
<div class="grid gap-2">
<Slider name="budget" label="Budget" max={500} step={25} value={250} />
<div class="flex justify-between text-xs text-muted">
<span>0</span>
<span>500</span>
</div>
</div>---
import Slider from "@/components/markas/Slider.astro";
---
<div class="grid gap-2">
<Slider name="budget" label="Budget" max={500} step={25} value={250} />
<div class="flex justify-between text-xs text-muted">
<span>0</span>
<span>500</span>
</div>
</div>States
<div class="grid gap-6">
<x-markas.slider name="contrast" label="Contrast" :value="40" />
<x-markas.slider name="opacity" label="Opacity" :value="80" :show-value="false" />
<x-markas.slider name="quality" label="Export quality" :value="70" disabled />
</div><script lang="ts">
import Slider from "$lib/components/markas/Slider.svelte";
</script>
<div class="grid gap-6">
<Slider name="contrast" label="Contrast" value={40} />
<Slider name="opacity" label="Opacity" value={80} showValue={false} />
<Slider name="quality" label="Export quality" value={70} disabled />
</div>---
import Slider from "@/components/markas/Slider.astro";
---
<div class="grid gap-6">
<Slider name="contrast" label="Contrast" value={40} />
<Slider name="opacity" label="Opacity" value={80} showValue={false} />
<Slider name="quality" label="Export quality" value={70} disabled />
</div>With icons
<div class="flex items-center gap-3 text-muted">
<svg class="size-5 shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M11 5 6 9H3v6h3l5 4z" /></svg>
<div class="flex-1">
<x-markas.slider name="volume" aria-label="Volume" :value="45" :show-value="false" />
</div>
<svg class="size-5 shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M11 5 6 9H3v6h3l5 4zm4.5 3.5a5 5 0 0 1 0 7M19 5a10 10 0 0 1 0 14" /></svg>
</div>In a card
Sound
Changes apply to every device on this account.
Sound
Changes apply to every device on this account.
Sound
Changes apply to every device on this account.
Sound
Changes apply to every device on this account.
Sound
Changes apply to every device on this account.
<div class="grid gap-5 rounded-xl border border-line bg-surface p-5">
<div class="grid gap-1">
<h3 class="text-base font-medium text-ink">Sound</h3>
<p class="text-sm text-muted">Changes apply to every device on this account.</p>
</div>
<x-markas.slider name="master" label="Master volume" :value="75" />
<x-markas.slider name="music" label="Music" :value="50" />
<x-markas.slider name="effects" label="Effects" :value="20" />
</div>Installation
npx markasui@latest add sliderpnpm dlx markasui@latest add slideryarn dlx markasui@latest add sliderbunx --bun markasui@latest add slider- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Install the dependency:
npm install alpinejs - Copy the component source below to
resources/views/components/markas/slider.blade.php.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/Slider.tsx.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/Slider.vue.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/lib/components/markas/Slider.svelte.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/Slider.astro.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/app/markas/slider.component.ts.
Usage
<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
<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 to send fewer requests while dragging. Other attributes land on the range input.
import { Slider } from "@/components/markas/Slider";
<Slider
name="volume"
label="Volume"
defaultValue={60}
onValueChange={(value) => console.log(value)}
/>;<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><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} />---
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.
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);
}- 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-labeland setshowValueto false if the number is not needed. - The component has no built-in text. Translate
labeldirectly.
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.
Related components
More form components with the same classes in every framework.
- ButtonButton with primary, secondary, ghost, and danger variants.
- CheckboxNative checkbox with an optional label and description, custom styled without JavaScript.
- ComboboxText input with a filtered suggestion list in a popover, following the WAI-ARIA Combobox pattern with list autocomplete.
- InputText field with a label, hint, and error message wired up through ARIA.
- Input OTPOne-time code input split into single-digit boxes, with auto advance, paste support, and one hidden field for form submit.
- LabelForm label with consistent styling and optional required or optional markers that screen readers announce correctly.