This browser is not supported. The glass needs a Chromium browser or Electron. Why

Slider

SwiftUI's Slider. Press the thumb and it lifts into a glass droplet; drag it, past the ends or off the track, and let go moving and it runs on. The track itself takes no touch.

import { Slider } from "@adamexu/glass";

Basic

onChange runs on every frame of a drag and of the run-on after it. onEditingChanged is SwiftUI's: true at the first change of a drag, false once the value has stopped.

value = 0.60
const [value, setValue] = useState(0.6);
const [editing, setEditing] = useState(false);

<Slider
  aria-label="Brightness"
  value={value}
  onChange={setValue}
  onEditingChanged={setEditing}
  minimumValueLabel={<SunDim size={22} className="glass-slider__icon" />}
  maximumValueLabel={<Sun size={22} className="glass-slider__icon" />}
/>

Ticks, steps and a neutral value

Ticks are marks the thumb snaps to. step rounds the value and puts a tick at every step, as on iOS. neutralValue is where the fill starts, so it can grow either way. thumbHidden draws the track alone.

rating = 3
const [rating, setRating] = useState(3);

<Slider aria-label="Size" defaultValue={0.5} ticks={[0, 0.25, 0.5, 0.75, 1]} tint="#ff5a1f" />
<Slider aria-label="Rating" in={[1, 5]} step={1} value={rating} onChange={setRating} />
<Slider aria-label="Balance" defaultValue={0.7} neutralValue={0.5} />
<Slider aria-label="Progress" defaultValue={0.6} thumbHidden />

Props

PropTypeDefaultDescription
valuenumber-SwiftUI value: controlled. Leave it out and the slider keeps its own.
defaultValuenumberthe middleThe initial value when uncontrolled.
onChange(value: number) => void-Every frame of a drag and of the run-on after it.
onEditingChanged(editing: boolean) => void-True at the first change of a drag (a press alone reports nothing), false when the value has stopped.
in[number, number][0, 1]SwiftUI in: the range.
stepnumber-SwiftUI step: rounds the value, with a tick at every step.
ticksnumber[]-SwiftUI ticks: marks at these values, which the thumb snaps to.
neutralValuenumber-SwiftUI neutralValue: the fill runs from here to the thumb.
enabledBounds[number, number]-SwiftUI enabledBounds. Only the upper bound stops a drag, as on iOS 27.2.
minimumValueLabelReactNode-Drawn before the track.
maximumValueLabelReactNode-Drawn after the track.
labelstring-SwiftUI label: only spoken, the accessible name when there is no aria-label.
currentValueLabelstring-Spoken as the value's text (aria-valuetext).
tintstring-SwiftUI .tint(_:): the fill colour.
thumbHiddenbooleanfalseSwiftUI .sliderThumbVisibility(.hidden).
disabledbooleanfalseSwiftUI .disabled(_:).
animatedbooleanfalsewithAnimation: a new value from outside springs there instead of jumping.
idiom"phone" | "pad" | "duo""phone"The device whose feel to match. The look is the same; on iPad a drag holds a moment longer.
id, aria-labelstring-Go on the role="slider" element.
className, stylestring, CSSProperties-On the outer box.

Behaviour

The slider is a role="slider" element: the arrow keys step it (by step, or a hundredth of the range), Page Up and Page Down move a tenth, Home and End jump to the ends. It is drawn for Chromium, where the lifted thumb refracts the track and whatever is behind it.

SwiftUI

SwiftUI@adamexu/glass
Slider(value:in:step:)<Slider value onChange in step>
Slider(...) minimumValueLabel: maximumValueLabel:<Slider minimumValueLabel maximumValueLabel>
Slider(..., onEditingChanged:)onEditingChanged
Slider(..., neutralValue:)neutralValue
Slider(...) ticks:ticks
.sliderThumbVisibility(.hidden)thumbHidden
.tint(.orange)tint="orange"