Slider
A slider component with buffer support. Perfect for media players to show loading progress.
Loading...
<script lang="ts">
import { Slider } from "$lib/components/ui/audio/elements/slider/index.js";
let value = $state([25]);
</script>
<div class="w-full max-w-sm">
<Slider
{value}
onValueChange={(v) => (value = v)}
max={100}
step={1}
bufferValue={55}
/>
</div> Installation
Install bits-ui :
Copy and paste the following code into your project.
Usage
<script lang="ts">
import { Slider } from "$lib/components/ui/audio/elements/slider/index.js";
</script> <Slider value={[33]} max={100} step={1} /> Buffer Indicator
This slider extends the shadcn-svelte slider component (which uses bits-ui) to add support for a bufferValue prop, which displays a buffer indicator behind the current value. This is particularly useful for media players to show loading progress:
<script lang="ts">
import { Slider } from "$lib/components/ui/audio/elements/slider/index.js";
</script>
<Slider
bufferValue={75}
class="w-[60%]"
value={[25]}
max={100}
step={1}
/> API Reference
Slider
This component extends the bits-ui Slider component and inherits its props. Additionally, it supports:
For all other props, see the Bits UI Slider API Reference.
Notes
Important Information:
- Custom Component: This component is based on the default shadcn-svelte registry
Slidercomponent but extends it with audio-specific features. All standard slider functionality is preserved, with the addition of thebufferValueprop for buffer indicators.- Buffer Indicator: The buffer indicator displays a semi-transparent overlay behind the current value. This is particularly useful for media players to show loading progress or buffered content.
- Usage in Audio Player: This slider is used by the
AudioPlayerSeekBarcomponent to display playback progress and buffer status.