SliderDefaults


Object to hold defaults used by Slider

Summary

Public functions

Unit
@Composable
Thumb(
    interactionSource: MutableInteractionSource,
    modifier: Modifier,
    colors: SliderColors,
    enabled: Boolean,
    thumbSize: DpSize
)

The Default thumb for Slider and RangeSlider

Cmn
Unit
@Composable
Track(
    sliderPositions: SliderPositions,
    modifier: Modifier,
    colors: SliderColors,
    enabled: Boolean
)

This function is deprecated. Use version that supports slider state

Cmn
Unit
@Composable
Track(
    rangeSliderState: RangeSliderState,
    modifier: Modifier,
    enabled: Boolean,
    colors: SliderColors,
    drawStopIndicator: (DrawScope.(Offset) -> Unit)?,
    drawTick: DrawScope.(Offset, Color) -> Unit,
    thumbTrackGapSize: Dp,
    trackInsideCornerSize: Dp
)

The Default track for RangeSlider

Cmn
Unit
@ExperimentalMaterial3Api
@Composable
Track(
    sliderState: SliderState,
    modifier: Modifier,
    enabled: Boolean,
    colors: SliderColors,
    drawStopIndicator: (DrawScope.(Offset) -> Unit)?,
    drawTick: DrawScope.(Offset, Color) -> Unit,
    thumbTrackGapSize: Dp,
    trackInsideCornerSize: Dp
)

The Default track for Slider

Cmn
SliderColors

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

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

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

Cmn

Public properties

Dp

The default size for the ticks if steps are greater than 0.

Cmn
Dp

The default size for the stop indicator at the end of the track.

Cmn

Public functions

Thumb

@Composable
fun Thumb(
    interactionSource: MutableInteractionSource,
    modifier: Modifier = Modifier,
    colors: SliderColors = colors(),
    enabled: Boolean = true,
    thumbSize: DpSize = ThumbSize
): Unit

The Default thumb for Slider and RangeSlider

Parameters
interactionSource: MutableInteractionSource

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

modifier: Modifier = Modifier

the Modifier to be applied to the thumb.

colors: SliderColors = colors()

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

enabled: Boolean = true

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.

thumbSize: DpSize = ThumbSize

the size of the thumb.

Track

@Composable
fun Track(
    sliderPositions: SliderPositions,
    modifier: Modifier = Modifier,
    colors: SliderColors = colors(),
    enabled: Boolean = true
): Unit

The Default track for Slider and RangeSlider

Parameters
sliderPositions: SliderPositions

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

modifier: Modifier = Modifier

the Modifier to be applied to the track.

colors: SliderColors = colors()

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

enabled: Boolean = true

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
fun Track(
    rangeSliderState: RangeSliderState,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    colors: SliderColors = colors(),
    drawStopIndicator: (DrawScope.(Offset) -> Unit)? = { drawStopIndicator( drawScope = this, offset = it, color = colors.trackColor(enabled, active = true), size = TrackStopIndicatorSize ) },
    drawTick: DrawScope.(Offset, Color) -> Unit = { offset, color -> drawStopIndicator(drawScope = this, offset = offset, color = color, size = TickSize) },
    thumbTrackGapSize: Dp = ThumbTrackGapSize,
    trackInsideCornerSize: Dp = TrackInsideCornerSize
): Unit

The Default track for RangeSlider

Parameters
rangeSliderState: RangeSliderState

RangeSliderState which is used to obtain the current active track.

modifier: Modifier = Modifier

the Modifier to be applied to the track.

enabled: Boolean = true

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: SliderColors = colors()

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

drawStopIndicator: (DrawScope.(Offset) -> Unit)? = { drawStopIndicator( drawScope = this, offset = it, color = colors.trackColor(enabled, active = true), size = TrackStopIndicatorSize ) }

lambda that will be called to draw the stop indicator at the start/end of the track.

drawTick: DrawScope.(Offset, Color) -> Unit = { offset, color -> drawStopIndicator(drawScope = this, offset = offset, color = color, size = TickSize) }

lambda that will be called to draw the ticks if steps are greater than 0.

thumbTrackGapSize: Dp = ThumbTrackGapSize

size of the gap between the thumbs and the track.

trackInsideCornerSize: Dp = TrackInsideCornerSize

size of the corners towards the thumbs when a gap is set.

Track

@ExperimentalMaterial3Api
@Composable
fun Track(
    sliderState: SliderState,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    colors: SliderColors = colors(),
    drawStopIndicator: (DrawScope.(Offset) -> Unit)? = { drawStopIndicator( drawScope = this, offset = it, color = colors.trackColor(enabled, active = true), size = TrackStopIndicatorSize ) },
    drawTick: DrawScope.(Offset, Color) -> Unit = { offset, color -> drawStopIndicator(drawScope = this, offset = offset, color = color, size = TickSize) },
    thumbTrackGapSize: Dp = ThumbTrackGapSize,
    trackInsideCornerSize: Dp = TrackInsideCornerSize
): Unit

The Default track for Slider

Parameters
sliderState: SliderState

SliderState which is used to obtain the current active track.

modifier: Modifier = Modifier

the Modifier to be applied to the track.

enabled: Boolean = true

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: SliderColors = colors()

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

drawStopIndicator: (DrawScope.(Offset) -> Unit)? = { drawStopIndicator( drawScope = this, offset = it, color = colors.trackColor(enabled, active = true), size = TrackStopIndicatorSize ) }

lambda that will be called to draw the stop indicator at the end of the track.

drawTick: DrawScope.(Offset, Color) -> Unit = { offset, color -> drawStopIndicator(drawScope = this, offset = offset, color = color, size = TickSize) }

lambda that will be called to draw the ticks if steps are greater than 0.

thumbTrackGapSize: Dp = ThumbTrackGapSize

size of the gap between the thumb and the track.

trackInsideCornerSize: Dp = TrackInsideCornerSize

size of the corners towards the thumb when a gap is set.

colors

@Composable
fun colors(): SliderColors

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

colors

@Composable
fun colors(
    thumbColor: Color = Color.Unspecified,
    activeTrackColor: Color = Color.Unspecified,
    activeTickColor: Color = Color.Unspecified,
    inactiveTrackColor: Color = Color.Unspecified,
    inactiveTickColor: Color = Color.Unspecified,
    disabledThumbColor: Color = Color.Unspecified,
    disabledActiveTrackColor: Color = Color.Unspecified,
    disabledActiveTickColor: Color = Color.Unspecified,
    disabledInactiveTrackColor: Color = Color.Unspecified,
    disabledInactiveTickColor: Color = Color.Unspecified
): SliderColors

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
thumbColor: Color = Color.Unspecified

thumb color when enabled

activeTrackColor: Color = Color.Unspecified

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

activeTickColor: Color = Color.Unspecified

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

inactiveTrackColor: Color = Color.Unspecified

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

inactiveTickColor: Color = Color.Unspecified

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

disabledThumbColor: Color = Color.Unspecified

thumb colors when disabled

disabledActiveTrackColor: Color = Color.Unspecified

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

disabledActiveTickColor: Color = Color.Unspecified

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

disabledInactiveTrackColor: Color = Color.Unspecified

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

disabledInactiveTickColor: Color = Color.Unspecified

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

Public properties

TickSize

val TickSizeDp

The default size for the ticks if steps are greater than 0.

TrackStopIndicatorSize

val TrackStopIndicatorSizeDp

The default size for the stop indicator at the end of the track.