Live preview

Interactive example

Loading example…

Usage

Import the component and its manager, then make it your own.

ComponentSlider
Managercreate_slider_manager

svelte

<script>
  // Import the shared stylesheet once in your application's root layout.
  import "sveltekit-ui/style.css"
  import { Slider, create_slider_manager } from "sveltekit-ui"

  const manager = create_slider_manager({
    label: "Volume",
    name: "volume",
    val: 50,
    min: 0,
    max: 100,
    step: 5,
  })
</script>

<Slider {manager} />
<p>Volume: {manager.val}%</p>

API reference

Configure the manager, call its methods, and read its reactive state.

24 entries in configuration

PropertyTypeDefaultDescription
valnumber or number[] 0Current value(s). If an array is provided, multiple thumbs appear.
minnumber 0Minimum value range.
maxnumber 2Maximum value range.
stepnumber 0.01Value increment steps.
on_changefunction nullCalled with new value(s) when changed (pointer move or arrow key).
on_downfunction nullCalled with new value when pointer is pressed.
on_upfunction nullCalled with final value(s) when pointer is released.
labelstring or null nullLabel text displayed above the slider.
namestring sliderName attribute for potential form usage.
label_font_sizenumber 1.2Size in rem for label text.
is_requiredboolean falseWhether the field is required for form submission.
is_read_onlyboolean falseIf true, the slider can't be changed.
font_sizenumber 1Base text size for the slider thumb.
is_disabledboolean falseIf true, slider is disabled. If val is null and is_nullable is false, defaults to true.
is_nullableboolean falseIf true, a 'Set Null' / 'Select Value' button toggles val between null and min.
colorCSS color var(--primary-t)Color used for highlight track background and thumb details.
is_shortboolean falseIf true, uses a more compact thumb design.
is_show_textboolean trueIf false, hides numeric text on thumb.
mlnumber 0Margin-left in rem.
mrnumber 0Margin-right in rem.
mtnumber 0Margin-top in rem.
mbnumber 0Margin-bottom in rem.
highlight_range_start_percentnumber 0Optional highlight range start in percent (0-100).
highlight_range_end_percentnumber 0Optional highlight range end in percent (0-100).