ToolkitIcon

sealed interface ToolkitIcon(source)

One icon slot of a toolkit component, such as a navigation item or a button.

Five sources are accepted:

  • Vector, a Compose ImageVector like Icons.Rounded.Share.

  • Resource, a static drawable or vector XML resource, drawn through a painter.

  • Bitmap, a runtime Compose ImageBitmap, with authored colors preserved by default.

  • AnimatedVector, an Animated Vector Drawable that plays when the component is clicked.

  • Lottie, bundled Lottie JSON that plays once per interaction.

Both animated sources accept Animated.loop to keep playing instead of only on interaction; it is off by default, orthogonal to their replay mode, and Animated.loopTrigger decides whether the loop starts on its own or on the first interaction.

Components that own a selected state take two of these, one per state, and both slots accept any of the five sources. See :library:core:designsystem README.md for the accepted combinations and the behavior of each one.

Inheritors

Types

Link copied to clipboard
sealed interface Animated : ToolkitIcon

Playback options shared by bundled animation sources; these are presentation values.

Link copied to clipboard
data class AnimatedVector(@DrawableRes val resId: Int, val atEnd: Boolean = false, val replayMode: ToolkitIconReplayMode = ToolkitIconReplayMode.Restart, val loop: Boolean = false, val loopTrigger: ToolkitIconLoopTrigger = ToolkitIconLoopTrigger.Immediately) : ToolkitIcon.Animated

Icon backed by an Animated Vector Drawable.

Link copied to clipboard
data class Bitmap(val imageBitmap: ImageBitmap, val tintable: Boolean = false) : ToolkitIcon

Icon backed by a runtime Compose ImageBitmap. Nothing about it animates.

Link copied to clipboard
object Companion
Link copied to clipboard
data class Lottie(@RawRes val resId: Int, val atEnd: Boolean = false, val replayMode: ToolkitIconReplayMode = ToolkitIconReplayMode.Restart, val tintable: Boolean = false, val loop: Boolean = false, val loopTrigger: ToolkitIconLoopTrigger = ToolkitIconLoopTrigger.Immediately) : ToolkitIcon.Animated

Bundled Lottie JSON in res/raw. Plays once per interaction unless loop is set, in which case loopTrigger decides whether the loop starts on its own or on the first interaction. Artwork retains its authored colors; the renderer's tint applies only when tintable is true. Prefer small vector-only compositions for navigation and button icons.

Link copied to clipboard
data class Resource(@DrawableRes val resId: Int) : ToolkitIcon

Icon backed by a static drawable or vector XML resource. Nothing about it animates.

Link copied to clipboard
data class Vector(val imageVector: ImageVector) : ToolkitIcon

Icon backed by a Compose ImageVector, for example a Material icon.