← Back to Portfolio
🎨

compose-dynamic-color-imagevector

Kotlin Android Jetpack Compose Material3

Build ImageVectors with dynamic colors that adapt to Material3 themes in Jetpack Compose.

View on GitHub ↗

Compose Dynamic Color ImageVector

Shows how to build programmatic ImageVectors in Jetpack Compose whose colors adapt to a Material3 dynamic color theme at runtime.

Demo

Instead of using static XML drawables, each path is constructed via ImageVector.Builder with explicit color parameters — making it trivial to swap colors from MaterialTheme.colorScheme or any runtime source.

Key pattern: a makeIcon() function accepts backgroundColor, primaryColor, and secondaryColor as arguments (defaulting to theme colors when used as a @Composable), then builds the vector on-the-fly using addPath + SolidColor.