slider

package
v0.1.43 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package slider contains Material 3 Slider components.

Reference: [Sliders](https://m3.material.io/components/sliders/overview) Specs: [Sliders Specs](https://m3.material.io/components/sliders/specs)

Index

Constants

View Source
const SliderNodeID = "Material3Slider"

Variables

View Source
var (
	TrackHeight     = gioUnit.Dp(4)
	ThumbSize       = gioUnit.Dp(20)
	ActiveThumbSize = gioUnit.Dp(28) // M3 State Layer/Enlarged handle
	TickSize        = gioUnit.Dp(2)
	ThumbTrackGap   = gioUnit.Dp(6) // Approximate
)

Dimensions constants @TODO this should be compose.ui.unit

View Source
var SliderDefaults = sliderDefaults{}

SliderDefaults holds default values for the Slider component.

Functions

This section is empty.

Types

type Composable

type Composable = api.Composable

func Slider

func Slider(value float32, onValueChange func(float32), options ...SliderOption) Composable

Slider is a Material 3 slider component.

value is the current value of the slider. onValueChange is called when the value changes. options provides optional configuration.

type Composer

type Composer = api.Composer

type SliderColors

type SliderColors struct {
	ThumbColor            graphics.Color
	ActiveTrackColor      graphics.Color
	ActiveTickColor       graphics.Color
	InactiveTrackColor    graphics.Color
	InactiveTickColor     graphics.Color
	DisabledThumbColor    graphics.Color
	DisabledActiveTrack   graphics.Color
	DisabledActiveTick    graphics.Color
	DisabledInactiveTrack graphics.Color
	DisabledInactiveTick  graphics.Color
}

SliderColors represents the colors used by a Slider in different states.

func (SliderColors) Layout

func (SliderColors) Thumb

func (c SliderColors) Thumb(enabled bool) graphics.Color

ThumbColor returns the color of the thumb based on the enabled state.

func (SliderColors) Tick

func (c SliderColors) Tick(enabled, active bool) graphics.Color

TickColor returns the color of the ticks based on the enabled and active state.

func (SliderColors) Track

func (c SliderColors) Track(enabled, active bool) graphics.Color

TrackColor returns the color of the track based on the enabled and active state.

type SliderOption

type SliderOption func(*SliderOptions)

SliderOption defines the functional option pattern for Slider.

func WithColors

func WithColors(colors SliderColors) SliderOption

WithColors sets the colors for the slider.

func WithEnabled

func WithEnabled(enabled bool) SliderOption

WithEnabled sets whether the slider is enabled.

func WithModifier

func WithModifier(m ui.Modifier) SliderOption

WithModifier applies a modifier to the slider.

func WithOnValueChangeFinished

func WithOnValueChangeFinished(callback func()) SliderOption

WithOnValueChangeFinished sets the callback for when dragging finishes.

func WithSteps

func WithSteps(steps int) SliderOption

WithSteps sets the number of discrete steps.

func WithValueRange

func WithValueRange(min, max float32) SliderOption

WithValueRange sets the range of valid values.

type SliderOptions

type SliderOptions struct {
	Modifier              ui.Modifier
	Enabled               bool
	ValueRange            struct{ Min, Max float32 }
	Steps                 int
	OnValueChangeFinished func()
	Colors                SliderColors
}

SliderOptions holds all optional parameters for the Slider.

func DefaultSliderOptions

func DefaultSliderOptions() SliderOptions

DefaultSliderOptions returns the default options.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL