Jetpack Compose

com.openbase:icons-compose is the native Android package. Every icon has cached ImageVector artwork, a themed OpenbaseIcon composable, and generated morph data for spring animations.

  • Import PascalCase icon extensions, such as OpenbaseIcons.Home, from com.openbase.icons.compose.icons.
  • Switch outline/filled weights and flat/raised/drawn appearances with Kotlin enums.
  • Morph any icon into any other with MorphIcon, including filled and drawn artwork.
  • Use Material 3's LocalContentColor, standard Compose modifiers, and accessible descriptions.

Installation

The package is available from a local checkout today. A remote Maven release has not been published. Build and publish it to your local Maven repository, then add it to your Android app.

Requirements: JDK 17, Android SDK platform and build tools 35, Node.js 18.18+ and pnpm. Set ANDROID_HOME or sdk.dir in the package's local.properties. The library supports Android API 21 and newer; its build pins Kotlin/Compose compiler 2.1.20 and supplies Gradle 8.14 through the wrapper.

git clone https://github.com/Try-Openbase/icons.git
cd useicons
pnpm install
pnpm run generate:compose
cd packages/icons-compose
sh ./gradlew publishReleasePublicationToMavenLocal
settings.gradle.kts (your app)
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        mavenLocal()
    }
}
app/build.gradle.kts
dependencies {
    implementation("com.openbase:icons-compose:0.1.0")
}
Note: Keep Compose and its compiler plugin enabled in your app. You can use your app's compatible Compose BOM. generate:compose needs no Flutter or Dart installation.

Basic usage

AppIcons.kt
import androidx.compose.foundation.layout.Row
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.openbase.icons.compose.IconAppearance
import com.openbase.icons.compose.IconWeight
import com.openbase.icons.compose.OpenbaseIcon
import com.openbase.icons.compose.OpenbaseIcons
import com.openbase.icons.compose.icons.Bell
import com.openbase.icons.compose.icons.Heart
import com.openbase.icons.compose.icons.Home

@Composable
fun AppIcons() {
    Row {
        OpenbaseIcon(icon = OpenbaseIcons.Home, contentDescription = "Home")
        OpenbaseIcon(icon = OpenbaseIcons.Bell, contentDescription = "Notifications", weight = IconWeight.Filled)
        OpenbaseIcon(
            icon = OpenbaseIcons.Heart,
            contentDescription = "Favorite",
            appearance = IconAppearance.Raised,
            tint = Color(0xFFE11D48),
            size = 32.dp,
        )
    }
}

Use a standard Material Icon

Inside a composable
// With the OpenbaseIcons and Home imports above:
androidx.compose.material3.Icon(
    imageVector = OpenbaseIcons.Home.imageVector(weight = IconWeight.Filled),
    contentDescription = "Home",
)

Props

Every icon uses the same OpenbaseIcon parameters. The icon itself is a OpenbaseIconData extension on OpenbaseIcons.

PropTypeDefaultDescription
iconOpenbaseIconDataRequiredThe icon to draw, e.g. OpenbaseIcons.Home
contentDescriptionString?RequiredAccessible description; explicitly pass null for decorative artwork
modifierModifierModifierCompose sizing, layout, and interaction modifiers
weightIconWeightIconWeight.OutlineOutline or Filled
appearanceIconAppearanceIconAppearance.FlatFlat, Raised, or Drawn
tintColorLocalContentColor.currentMaterial 3 content colour; Color.Unspecified uses the underlying black ink
sizeDp24.dpDefault square size in density-independent pixels

Icon weights

Every icon has outline and filled artwork. Import IconWeight from com.openbase.icons.compose; the enum members are PascalCase.

Outline

weight="outline"

Filled

weight="filled"

Inside a composable
OpenbaseIcon(icon = OpenbaseIcons.Home, contentDescription = "Home") // Outline by default
OpenbaseIcon(icon = OpenbaseIcons.Home, contentDescription = "Home", weight = IconWeight.Filled)

Appearances

  • Flat: the original artwork.
  • Raised: tonal radial shading clipped to the glyph, following tint.
  • Drawn: generated hand-drawn artwork, available in either weight.

Flat

appearance="flat"

Raised

appearance="raised"

Drawn

appearance="drawn"

Inside a composable
OpenbaseIcon(icon = OpenbaseIcons.Heart, contentDescription = "Favorite")
OpenbaseIcon(icon = OpenbaseIcons.Heart, contentDescription = "Favorite", appearance = IconAppearance.Raised)
OpenbaseIcon(
    icon = OpenbaseIcons.Heart,
    contentDescription = "Favorite",
    weight = IconWeight.Filled,
    appearance = IconAppearance.Drawn,
)
Note: The previews use the web renderer. Android's raised treatment is tonal shading without the React/Flutter inner-edge effects, and is most visible at 32dp or larger. imageVector(appearance = IconAppearance.Raised) returns flat geometry; use OpenbaseIcon to paint the shading.

Morphing

MorphIcon animates filled regions with spring physics. Import it and OpenbaseMorphIcons from com.openbase.icons.compose.morph, then import individual morph extensions from com.openbase.icons.compose.morph.icons. Each icon provides Home, HomeFilled, HomeDrawn, and HomeFilledDrawn.

Outline

Heart ↔ Star

Filled, raised

raised

Plus ↔ X

rotation from geometry

Animate when the target changes

MenuIcon.kt
import androidx.compose.runtime.Composable
import com.openbase.icons.compose.morph.MorphIcon
import com.openbase.icons.compose.morph.MorphSpring
import com.openbase.icons.compose.morph.OpenbaseMorphIcons
import com.openbase.icons.compose.morph.icons.Plus
import com.openbase.icons.compose.morph.icons.X

@Composable
fun MenuIcon(open: Boolean) {
    MorphIcon(
        icon = if (open) OpenbaseMorphIcons.X else OpenbaseMorphIcons.Plus,
        contentDescription = if (open) "Close menu" else "Open menu",
        spring = MorphSpring.Snappy,
        raised = true,
    )
}

Control progress directly

Inside a composable, with the imports above
MorphIcon(
    from = OpenbaseMorphIcons.Plus,
    to = OpenbaseMorphIcons.X,
    progress = progress, // 0 = from, 1 = to; finite overshoot is supported
    contentDescription = "Toggle menu",
)

Imperative control

MorphControls.kt
import androidx.compose.foundation.layout.Row
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import com.openbase.icons.compose.morph.MorphIcon
import com.openbase.icons.compose.morph.OpenbaseMorphIcons
import com.openbase.icons.compose.morph.rememberMorphIconState
import com.openbase.icons.compose.morph.icons.Plus
import com.openbase.icons.compose.morph.icons.X
import kotlinx.coroutines.launch

@Composable
fun MorphControls() {
    val state = rememberMorphIconState(OpenbaseMorphIcons.Plus)
    val scope = rememberCoroutineScope()
    Row {
        IconButton(onClick = { scope.launch { state.morphTo(OpenbaseMorphIcons.X) } }) {
            MorphIcon(state = state, contentDescription = "Close menu")
        }
        TextButton(onClick = { scope.launch { state.snapTo(OpenbaseMorphIcons.Plus) } }) {
            Text("Reset")
        }
    }
}
PropTypeDefaultDescription
iconMorphRegionRequired in automatic modeChanging the target starts or interrupts a morph
from / to / progressMorphRegion / FloatControlled modeCaller-owned progress, including finite spring overshoot
stateMorphIconStateHoisted-state modeCreate with rememberMorphIconState(initialIcon); call suspend morphTo and snapTo in a UI coroutine scope
springMorphSpringMorphSpring.SnappyAlso Smooth, Bouncy, or custom positive stiffness/damping
reducedMotionMorphReducedMotionMorphReducedMotion.UserUser follows Android animator duration scale; Always jumps; Never permits animation at scale zero
raisedBooleanfalseShading follows the morphing geometry
tint / size / modifierColor / Dp / ModifierLocalContentColor.current / 24.dp / ModifierSame styling parameters as OpenbaseIcon
contentDescriptionString?RequiredAccessible description, or null for a decorative morph

The initial icon renders immediately. Interruptions continue from the current contours and retain spring velocity, capped at ±14 progress units/second. Hoisted state exposes observable progress, velocity, isRunning, isSettled, and target. Automatic animations stop when their composable leaves composition; hoisted animation jobs belong to the caller's coroutine scope.

Custom springs use MorphSpring(stiffness = 420.0, damping = 30.0), with finite positive coefficients up to 1,000,000. Controlled progress is owned by the caller, including reduced-motion behaviour. Android morph inputs are the generated MorphRegion values; raw SVG strings are not a runtime input.

Tip: For dynamic lookup, import com.openbase.icons.compose.morph.icons.byName, then use OpenbaseMorphIcons.byName["arrow-left"]!!.filled. This retains the full morph catalog; individual imports let R8 remove unused data.

Styling & colour

OpenbaseIcon and MorphIcon default to Material 3's LocalContentColor.current. Pass tint for one icon or provide a content colour to a group. Import OpenbaseIcons, OpenbaseIcon, and your icon extensions as shown above.

Inside a composable
androidx.compose.runtime.CompositionLocalProvider(
    androidx.compose.material3.LocalContentColor provides androidx.compose.ui.graphics.Color(0xFF7C3AED),
) {
    OpenbaseIcon(icon = OpenbaseIcons.Home, contentDescription = "Home")
}

OpenbaseIcon(
    icon = OpenbaseIcons.Heart,
    contentDescription = "Favorite",
    tint = androidx.compose.ui.graphics.Color(0xFFE11D48),
    size = 32.dp,
)

Use modifier for normal Compose layout and interaction. Wrap actionable icons in an IconButton for an appropriate touch target. Color.Unspecified renders the underlying black artwork. Raised shading follows the selected tint.

Accessibility

Always supply contentDescription: a meaningful label for an icon carrying information, or null when nearby text already explains it. TalkBack can announce labelled icons and morphs.

Inside a composable
// Decorative artwork beside a text label
OpenbaseIcon(icon = OpenbaseIcons.Home, contentDescription = null)

// A morph with a meaningful label and system reduced motion
MorphIcon(
    icon = OpenbaseMorphIcons.X,
    contentDescription = "Close menu",
    reducedMotion = com.openbase.icons.compose.morph.MorphReducedMotion.User,
)

Automatic and imperative morphs default to MorphReducedMotion.User, honouring Android's animator duration scale and jumping when animations are disabled. When driving progress yourself, honour the user's motion preference in the code supplying that progress.

Performance

  • Native vectors are built and cached independently on first use; there is no runtime SVG/XML loader.
  • Import individual icon and morph extensions so R8 can remove unused artwork in release builds. Importing OpenbaseMorphIcons.byName retains the entire morph catalog.
  • Morph regions are normalized and sampled at build time. Automatic and imperative plans are built off the UI thread and held in a bounded cache.
  • Drawing reuses point buffers and a native Compose path. Raised shading adds an offscreen layer, so consider how many icons animate at once.

Adding icons

Add matching outline and filled SVGs under data/icons. Generate the drawn appearance, then regenerate the Compose vectors, morph regions, and reference fixtures. Commit source SVGs and generated Kotlin together.

In the repository root
# Canonical artwork
# data/icons/outline/rocket.svg
# data/icons/filled/rocket.svg
pnpm run generate:drawn
pnpm run generate:compose
pnpm run test:compose-generator
pnpm run build:compose

pnpm run generate:all also includes Compose. build:compose builds the release AAR, runs catalog and JavaScript/Kotlin morph parity tests, and runs Android lint. A stem such as arrow-up-right becomes OpenbaseIcons.ArrowUpRight and OpenbaseMorphIcons.ArrowUpRight. The adding-icons guide covers drawing rules.

Troubleshooting

  • The dependency cannot be resolved. Publish the package with publishReleasePublicationToMavenLocal, and include mavenLocal() in the app's dependency repositories. A remote Maven release is not available yet.
  • An icon name is unresolved. Import its extension, such as com.openbase.icons.compose.icons.Home; morph variants use com.openbase.icons.compose.morph.icons.HomeFilled. Names and enum members are PascalCase.
  • Gradle cannot find Java or the SDK. Use JDK 17 and install SDK platform/build tools 35. Set ANDROID_HOME or the package's local.properties SDK path.
  • Raised looks flat. Use OpenbaseIcon instead of a bare ImageVector, and check the shading at 32dp or larger. For morphs, set raised = true.
  • A morph jumps immediately. MorphReducedMotion.User follows Android's animator duration scale. With animations disabled, jumping to the target is expected.
  • New drawn artwork is missing. Run generate:drawn before generate:compose, or run generate:all.
NextSVG & JSX