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, fromcom.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 publishReleasePublicationToMavenLocaldependencyResolutionManagement {
repositories {
google()
mavenCentral()
mavenLocal()
}
}dependencies {
implementation("com.openbase:icons-compose:0.1.0")
}generate:compose needs no Flutter or Dart installation.Basic usage
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
// 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.
| Prop | Type | Default | Description |
|---|---|---|---|
| icon | OpenbaseIconData | Required | The icon to draw, e.g. OpenbaseIcons.Home |
| contentDescription | String? | Required | Accessible description; explicitly pass null for decorative artwork |
| modifier | Modifier | Modifier | Compose sizing, layout, and interaction modifiers |
| weight | IconWeight | IconWeight.Outline | Outline or Filled |
| appearance | IconAppearance | IconAppearance.Flat | Flat, Raised, or Drawn |
| tint | Color | LocalContentColor.current | Material 3 content colour; Color.Unspecified uses the underlying black ink |
| size | Dp | 24.dp | Default 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"
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"
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,
)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
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
MorphIcon(
from = OpenbaseMorphIcons.Plus,
to = OpenbaseMorphIcons.X,
progress = progress, // 0 = from, 1 = to; finite overshoot is supported
contentDescription = "Toggle menu",
)Imperative control
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")
}
}
}| Prop | Type | Default | Description |
|---|---|---|---|
| icon | MorphRegion | Required in automatic mode | Changing the target starts or interrupts a morph |
| from / to / progress | MorphRegion / Float | Controlled mode | Caller-owned progress, including finite spring overshoot |
| state | MorphIconState | Hoisted-state mode | Create with rememberMorphIconState(initialIcon); call suspend morphTo and snapTo in a UI coroutine scope |
| spring | MorphSpring | MorphSpring.Snappy | Also Smooth, Bouncy, or custom positive stiffness/damping |
| reducedMotion | MorphReducedMotion | MorphReducedMotion.User | User follows Android animator duration scale; Always jumps; Never permits animation at scale zero |
| raised | Boolean | false | Shading follows the morphing geometry |
| tint / size / modifier | Color / Dp / Modifier | LocalContentColor.current / 24.dp / Modifier | Same styling parameters as OpenbaseIcon |
| contentDescription | String? | Required | Accessible 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.
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.
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.
// 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.byNameretains 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.
# 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:composepnpm 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 includemavenLocal()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 usecom.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_HOMEor the package'slocal.propertiesSDK path. - Raised looks flat. Use
OpenbaseIconinstead of a bareImageVector, and check the shading at 32dp or larger. For morphs, setraised = true. - A morph jumps immediately.
MorphReducedMotion.Userfollows Android's animator duration scale. With animations disabled, jumping to the target is expected. - New drawn artwork is missing. Run
generate:drawnbeforegenerate:compose, or rungenerate:all.