{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

SliderDefaults

public static class SliderDefaults


Object to hold defaults used by Slider

Summary

Public fields

static @NonNull SliderDefaults

Public methods

final void
@Composable
Thumb(
    @NonNull MutableInteractionSource interactionSource,
    @NonNull Modifier modifier,
    @NonNull SliderColors colors,
    boolean enabled,
    @NonNull DpSize thumbSize
)

The Default thumb for Slider and RangeSlider

final void
@Composable
Track(
    @NonNull RangeSliderState rangeSliderState,
    @NonNull Modifier modifier,
    @NonNull SliderColors colors,
    boolean enabled
)

The Default track for RangeSlider

final void
@Composable
Track(
    @NonNull SliderPositions sliderPositions,
    @NonNull Modifier modifier,
    @NonNull SliderColors colors,
    boolean enabled
)

This method is deprecated. Use version that supports slider state

final void
@Composable
@ExperimentalMaterial3Api
Track(
    @NonNull SliderState sliderState,
    @NonNull Modifier modifier,
    @NonNull SliderColors colors,
    boolean enabled
)

The Default track for Slider

final @NonNull SliderColors

Creates a SliderColors that represents the different colors used in parts of the Slider in different states.

final @NonNull SliderColors
@Composable
colors(
    @NonNull Color thumbColor,
    @NonNull Color activeTrackColor,
    @NonNull Color activeTickColor,
    @NonNull Color inactiveTrackColor,
    @NonNull Color inactiveTickColor,
    @NonNull Color disabledThumbColor,
    @NonNull Color disabledActiveTrackColor,
    @NonNull Color disabledActiveTickColor,
    @NonNull Color disabledInactiveTrackColor,
    @NonNull Color disabledInactiveTickColor
)

Creates a SliderColors that represents the different colors used in parts of the Slider in different states.

Public fields

INSTANCE

public static @NonNull SliderDefaults INSTANCE

Public methods

Thumb

@Composable
public final void Thumb(
    @NonNull MutableInteractionSource interactionSource,
    @NonNull Modifier modifier,
    @NonNull SliderColors colors,
    boolean enabled,
    @NonNull DpSize thumbSize
)

The Default thumb for Slider and RangeSlider

Parameters
@NonNull MutableInteractionSource interactionSource

the MutableInteractionSource representing the stream of Interactions for this thumb. You can create and pass in your own remembered instance to observe

@NonNull Modifier modifier

the Modifier to be applied to the thumb.

@NonNull SliderColors colors

SliderColors that will be used to resolve the colors used for this thumb in different states. See SliderDefaults.colors.

boolean enabled

controls the enabled state of this slider. When false, this component will not respond to user input, and it will appear visually disabled and disabled to accessibility services.

Track

@Composable
public final void Track(
    @NonNull RangeSliderState rangeSliderState,
    @NonNull Modifier modifier,
    @NonNull SliderColors colors,
    boolean enabled
)

The Default track for RangeSlider

Parameters
@NonNull RangeSliderState rangeSliderState

RangeSliderState which is used to obtain the current active track.

@NonNull Modifier modifier

the Modifier to be applied to the track.

@NonNull SliderColors colors

SliderColors that will be used to resolve the colors used for this track in different states. See SliderDefaults.colors.

boolean enabled

controls the enabled state of this slider. When false, this component will not respond to user input, and it will appear visually disabled and disabled to accessibility services.

Track

@Composable
public final void Track(
    @NonNull SliderPositions sliderPositions,
    @NonNull Modifier modifier,
    @NonNull SliderColors colors,
    boolean enabled
)

The Default track for Slider and RangeSlider

Parameters
@NonNull SliderPositions sliderPositions

SliderPositions which is used to obtain the current active track and the tick positions if the slider is discrete.

@NonNull Modifier modifier

the Modifier to be applied to the track.

@NonNull SliderColors colors

SliderColors that will be used to resolve the colors used for this track in different states. See SliderDefaults.colors.

boolean enabled

controls the enabled state of this slider. When false, this component will not respond to user input, and it will appear visually disabled and disabled to accessibility services.

Track

@Composable
@ExperimentalMaterial3Api
public final void Track(
    @NonNull SliderState sliderState,
    @NonNull Modifier modifier,
    @NonNull SliderColors colors,
    boolean enabled
)

The Default track for Slider

Parameters
@NonNull SliderState sliderState

SliderState which is used to obtain the current active track.

@NonNull Modifier modifier

the Modifier to be applied to the track.

@NonNull SliderColors colors

SliderColors that will be used to resolve the colors used for this track in different states. See SliderDefaults.colors.

boolean enabled

controls the enabled state of this slider. When false, this component will not respond to user input, and it will appear visually disabled and disabled to accessibility services.

colors

@Composable
public final @NonNull SliderColors colors()

Creates a SliderColors that represents the different colors used in parts of the Slider in different states.

colors

@Composable
public final @NonNull SliderColors colors(
    @NonNull Color thumbColor,
    @NonNull Color activeTrackColor,
    @NonNull Color activeTickColor,
    @NonNull Color inactiveTrackColor,
    @NonNull Color inactiveTickColor,
    @NonNull Color disabledThumbColor,
    @NonNull Color disabledActiveTrackColor,
    @NonNull Color disabledActiveTickColor,
    @NonNull Color disabledInactiveTrackColor,
    @NonNull Color disabledInactiveTickColor
)

Creates a SliderColors that represents the different colors used in parts of the Slider in different states.

For the name references below the words "active" and "inactive" are used. Active part of the slider is filled with progress, so if slider's progress is 30% out of 100%, left (or right in RTL) 30% of the track will be active, while the rest is inactive.

Parameters
@NonNull Color thumbColor

thumb color when enabled

@NonNull Color activeTrackColor

color of the track in the part that is "active", meaning that the thumb is ahead of it

@NonNull Color activeTickColor

colors to be used to draw tick marks on the active track, if steps is specified

@NonNull Color inactiveTrackColor

color of the track in the part that is "inactive", meaning that the thumb is before it

@NonNull Color inactiveTickColor

colors to be used to draw tick marks on the inactive track, if steps are specified on the Slider is specified

@NonNull Color disabledThumbColor

thumb colors when disabled

@NonNull Color disabledActiveTrackColor

color of the track in the "active" part when the Slider is disabled

@NonNull Color disabledActiveTickColor

colors to be used to draw tick marks on the active track when Slider is disabled and when steps are specified on it

@NonNull Color disabledInactiveTrackColor

color of the track in the "inactive" part when the Slider is disabled

@NonNull Color disabledInactiveTickColor

colors to be used to draw tick marks on the inactive part of the track when Slider is disabled and when steps are specified on it