Skip to content
Ginga UI
Ginga UI
日本語

Getting started

  • Overview
  • Quick start
  • Theme generation
  • Custom rendering
  • All components

Forms

  • Button
  • Checkbox
  • Input
  • Radio
  • Questionnaire
  • SegmentedControl
  • Select
  • ComboBox
  • NumberField
  • SearchField
  • Slider
  • Switch
  • FormControl

Display

  • Accordion
  • Alert
  • AlertDialog
  • Badge
  • CodeBlock
  • Card
  • Dialog
  • Drawer
  • Image
  • List
  • Popover
  • Menu
  • Tooltip
  • Table
  • Tab
  • Toast
  • Trace

Typography

  • Heading
  • Paragraph

Navigation

  • Anchor

Layout

  • Box

Resources

  • Changelog
  • GitHub (opens in a new tab)

Logo: Twemoji (opens in a new tab) (CC-BY 4.0)

Slider

A slider for selecting a number within a range. Also supports range selection with start and end points.

View in Storybook (opens in a new tab)

Installation

import { Slider } from "@ginga-ui/core";

Basic usage

A simple slider example.

50
slider.tsx
import { Slider, SliderLabel, SliderOutput, SliderThumb, SliderTrack } from "@ginga-ui/core";

export function BasicExample() {
  return (
    <Slider defaultValue={50}>
      <SliderLabel>Volume</SliderLabel>
      <SliderOutput />
      <SliderTrack>
        <SliderThumb />
      </SliderTrack>
    </Slider>
  );
}

Custom range

A slider with custom minimum and maximum values.

0
slider.tsx
import { Slider, SliderLabel, SliderOutput, SliderThumb, SliderTrack } from "@ginga-ui/core";

export function CustomRangeExample() {
  return (
    <Slider defaultValue={0} minValue={-50} maxValue={50}>
      <SliderLabel>Balance</SliderLabel>
      <SliderOutput />
      <SliderTrack>
        <SliderThumb />
      </SliderTrack>
    </Slider>
  );
}

Range selection

Pass an array to defaultValue and place two SliderThumb elements to create a range slider with start and end points.

20–80
slider.tsx
import { Slider, SliderLabel, SliderOutput, SliderThumb, SliderTrack } from "@ginga-ui/core";

export function RangeExample() {
  return (
    <Slider defaultValue={[20, 80]}>
      <SliderLabel>Price range</SliderLabel>
      <SliderOutput />
      <SliderTrack>
        <SliderThumb index={0} />
        <SliderThumb index={1} />
      </SliderTrack>
    </Slider>
  );
}

With steps

A slider with a specified step.

50
slider.tsx
import { Slider, SliderLabel, SliderOutput, SliderThumb, SliderTrack } from "@ginga-ui/core";

export function WithStepsExample() {
  return (
    <Slider defaultValue={50} step={10}>
      <SliderLabel>Volume level (steps of 10)</SliderLabel>
      <SliderOutput />
      <SliderTrack>
        <SliderThumb />
      </SliderTrack>
    </Slider>
  );
}

Disabled

A disabled slider.

50
slider.tsx
import { Slider, SliderLabel, SliderOutput, SliderThumb, SliderTrack } from "@ginga-ui/core";

export function DisabledExample() {
  return (
    <Slider defaultValue={50} disabled>
      <SliderLabel>Disabled slider</SliderLabel>
      <SliderOutput />
      <SliderTrack>
        <SliderThumb />
      </SliderTrack>
    </Slider>
  );
}

Props

Slider

NameTypeDefaultDescription
disabledbooleanfalseDisables the slider.

Also accepts the props of React Aria's Slider (opens in a new tab).

SliderLabel

Accepts the props of React Aria's Label (opens in a new tab).

SliderOutput

Accepts the props of React Aria's SliderOutput (opens in a new tab).

SliderTrack

Accepts the props of React Aria's SliderTrack (opens in a new tab).

SliderThumb

Accepts the props of React Aria's SliderThumb (opens in a new tab).