Skip to content
portalbits
Home Docs GitHub(opens in a new tab)

Guides

Get startedFoundationsMotion

Components

All components

Buttons

ButtonIconButton

Inputs

InputSelectTextareaSlider

Selection

CheckboxToggleToggleGroupSwitchRadioGroup

Identity

AvatarBadge

Overlays

DialogPopoverTooltipDropdownMenuAlertDialog

Disclosure

TabsAccordion

Cards

AppCardArticleCardFeatureCard

Content

CarouselSectionHeaderEmptyStateAlertProgressSeparatorRowListRow

Chrome

PortalShellSidebarNavMobileNavTopBarAuthFrameColorSelectorFloatingNav

Slider

A number in a range, with a visible value and arrow-key steps.

Preview volume 40%
Variations

Source

<script lang="ts">
  import 'portal-bits/styles.css';
  import 'portal-bits/tokens.css';
  import type { Snippet } from 'svelte';

  let { children }: { children: Snippet } = $props();
</script>

{@render children()}
<script lang="ts">
  import SliderExample from './SliderExample.svelte';
</script>

<SliderExample step={1} disabled={false} />
<script lang="ts">
  import { Slider } from 'portal-bits';
  let { disabled = false, step = 1 }: { disabled?: boolean; step?: number } = $props();
  let volume = $state(40);
</script>

<div class="field">
  <Slider
    label="Preview volume"
    bind:value={volume}
    {step}
    {disabled}
    format={(value) => `${value}%`}
  />
</div>

<style>
  .field {
    width: 320px;
    max-width: 100%;
  }
</style>

API reference

These tables list the props and snippets that Slider declares. Attributes passed through to an element or primitive are listed under Forwarded attributes, not here.

Props

NameTypeDefaultRequiredBindingDescription
labelstringNoneYesOne-wayThe visible label. It names the thumb.
valuenumber0NoBindableThe current value.
minnumber0NoOne-wayThe lowest value.
maxnumber100NoOne-wayThe highest value.
stepnumber1NoOne-wayThe amount one arrow key press moves.
disabledbooleanfalseNoOne-wayStops pointer and keyboard changes.
namestringNoneNoOne-waySubmits the value with a form under this name.
format(value: number) => stringString(value)NoOne-wayFormats the visible value and `aria-valuetext`, such as `40%`.
classstring""NoOne-wayExtra classes, added after the component classes.

Forwarded attributes

None. Slider forwards no attributes.

The primitive underneath is a Bits UI peer dependency. Its own options are documented in the Bits UI Slider documentation. Only the props listed on this page are part of the Slider contract. No data attributes are documented as stable.

Limits

  • One thumb only. Ranges with two thumbs are not supported.
  • Horizontal only. The track, thumb, and halo are an adaptation; no slider was measured.
  • Only the props listed here reach Bits UI `Slider.Root`.

Related

  • Progress
  • Input
Previous Textarea Next Checkbox

On this page

  • Preview
  • Source
  • API reference
  • Props
  • Forwarded attributes
  • Limits