SegmentedControlScope

DSL scope for declaring segments inside a SegmentedControl content block.

Each function adds one segment in declaration order. The return type SegmentedButtonItem is a marker; callers discard it. All variants animate label weight and colour between the selected and unselected states; icons additionally animate between com.adevinta.spark.tokens.SparkColors.support (unselected) and com.adevinta.spark.tokens.SparkColors.supportVariant (selected).

Enabled state and indicator shape are inherited from the enclosing SegmentedControl and cannot be overridden per segment.

Functions

Link copied to clipboard
abstract fun custom(selected: Boolean, onClick: () -> Unit, modifier: Modifier = Modifier, rippleColor: Color = SparkTheme.colors.outlineHigh, content: @Composable () -> Unit): SegmentedButtonItem

Segment with fully custom content. Use this when no other scope variant fits — for example, when segment appearance must vary with the selected value (e.g. a colour-coded energy-rating scale).

Link copied to clipboard
abstract fun icon(icon: SparkIcon, contentDescription: String, selected: Boolean, onClick: () -> Unit, modifier: Modifier = Modifier): SegmentedButtonItem

Segment showing a single medium-sized SparkIcon.

Link copied to clipboard
abstract fun iconText(icon: SparkIcon, text: String, selected: Boolean, onClick: () -> Unit, modifier: Modifier = Modifier): SegmentedButtonItem

Segment showing a medium-sized SparkIcon above a single line of text.

Link copied to clipboard
abstract fun number(number: Int, selected: Boolean, onClick: () -> Unit, modifier: Modifier = Modifier): SegmentedButtonItem

Segment showing an integer label. Equivalent to singleLine with number converted to a string. Useful for compact numeric scales (e.g. ratings 1–5).

Link copied to clipboard
abstract fun singleLine(text: String, selected: Boolean, onClick: () -> Unit, modifier: Modifier = Modifier): SegmentedButtonItem

Segment showing a single line of text, truncated with ellipsis when the segment is too narrow.

Link copied to clipboard
abstract fun twoLine(title: String, subtitle: String, selected: Boolean, onClick: () -> Unit, modifier: Modifier = Modifier): SegmentedButtonItem

Segment showing a bold primary line and a smaller caption below it. Both lines are single-line, truncated with ellipsis.