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 ¶
const SliderNodeID = "Material3Slider"
Variables ¶
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
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 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 (c SliderColors) Layout(gtx layout.Context) layout.Dimensions
func (SliderColors) Thumb ¶
func (c SliderColors) Thumb(enabled bool) graphics.Color
ThumbColor returns the color of the thumb based on the enabled 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.