Prerequisites and compatibility
- Wear OS Compose Material3 version: If an internal tool is available to establish the latest stable version
{VERSION} of androidx.wear.compose:compose-material3, use that tool.
- Strict compliance: If a version is listed as stable, you MUST use it, unless overridden by the user. Do not downgrade based on initial "Unresolved reference" errors in the editor or outdated web search results.
- Kotlin version: For Wear Compose Material3, use Kotlin 2.0.0 or
higher.
- Compose compiler:
- If Kotlin version is 2.0.0+ , the project must use the
org.jetbrains.kotlin.plugin.compose Gradle plugin.
- If Kotlin version is < 2.0.0 , the project must use
kotlinCompilerExtensionVersion in composeOptions, matching the Compose to Kotlin Compatibility Map.
- Min SDK: Ensure
minSdk is at least 25 (Wear OS 2.0).
- Sample extraction mandate: Wear Compose libraries ship with an additional JAR file which contains individual samples for each and every component. You MUST NOT propose code changes until the samples in Capability 2 are extracted to the local cache. Library source files are incomplete and NOT a substitute for these samples; bypassing extraction is an environment setup failure.
Gotchas
- Mandatory sync and validation: After updating versions in
libs.versions.toml or build.gradle.kts, you must perform a Gradle sync before refactoring any code. This ensures the environment has resolved the libraries correctly.
- Prohibition of guessing (error protocol): If you encounter an 'Unresolved Reference' or API mismatch after a successful sync, do not attempt to 'fix' it by downgrading the library version.
Capabilities and tools
Capability 1: Migration
Use this guidance when migrating from an older version of Wear OS Compose or
Horologist.
- Unless otherwise indicated by the developer, use the latest stable version of Wear Compose Material3 from
{VERSION}.
- Read the migration guide.
- Use the official component mappings from the migration guide.
- Before refactoring any component (for example,
Chip -> Button), check the parameter names, slot types, and "Expressive" design tokens.
- Do not use the Horologist Composables, Compose Layout, or Compose Material libraries.
- Always check against the component guidance in Capability 3.
- Expect screenshot tests to fail when a migration has been performed: Even when migrating to very similar components, expected defaults for padding and positioning will have changed. Do not seek to artificially match the pre-migration screenshot, but give preference to the Material3 defaults.
Capability 2: Component samples
Wear Compose includes individual component samples for each and every component,
within the <artifact>-<version>-samples-sources.jar file. Gradle automatically
downloads these JAR files along with the main library JAR when using any of
compose-material3, compose-foundation or compose-navigation3.
Use the canonical component samples whenever adding or adjusting a Wear Compose
Material3 component.
STRICT COMPLIANCE: Extraction is NOT optional. You are FORBIDDEN from
implementing any code until samples are extracted and read. Bypassing this step
with alternative search tools or by assuming library documentation is sufficient
is a protocol breach. You MUST verify the local cache by reading a sample file
before proceeding.
Step 1: Prepare
- Check the
build.gradle.kts or libs.versions.toml to ensure the Wear Compose version matches {VERSION}.
- Ensure that the necessary dependencies are downloaded by doing a Gradle sync.
Step 2: Check the local cache
- Define the cache directory path:
/tmp/wear-compose-samples/{VERSION}/. Do NOT choose your own different location.
- Check if this directory exists and contains subdirectories with
.kt files.
- IF YES (cache hit): Proceed to Step 4.
- IF NO (cache miss): Proceed to Step 3.
Step 3: Network-based sample retrieval
Google Maven publishes a -samples-sources.jar alongside every library release.
Download and extract it directly without needing a local Gradle sync or cache
lookup.
Determine the {VERSION} of androidx.wear.compose:compose-material3 from build.gradle.kts or libs.versions.toml.
Define {ARTIFACT} as the items in the list ["material3", "foundation"]. Also include navigation3 if androidx.wear.compose.navigation3 is used.
For each {ARTIFACT}, run the following commands to download and extract
the samples:
# Download the samples-sources JAR
curl -sSL "https://dl.google.com/dl/android/maven2/androidx/wear/compose/compose-{ARTIFACT}/{VERSION}/compose-{ARTIFACT}-{VERSION}-samples-sources.jar" -o {ARTIFACT}-{VERSION}-samples.jar
# Extract and flatten into the cache directory
unzip -q -o {ARTIFACT}-{VERSION}-samples.jar -d /tmp/wear-compose-samples/{VERSION}/{ARTIFACT}/
# Clean up
rm {ARTIFACT}-{VERSION}-samples.jar
If this works, proceed directly to step 4.
Step 4: Read samples and implement
- Read the relevant
.kt sample files.
- Use these official, version-matched samples as the source of truth for:
- Required parameters and slot names.
- Default styling and typography tokens.
- Interactive behaviors (for example:
onClick, onLongClick).
- Component nesting (for example:
AppScaffold -> ScreenScaffold).
Capability 3: Component guidance
Mandatory: Use this capability as a checklist against any component use. It
provides more holistic guidance on how to use each component in practice, beyond
the component syntax.
AppScaffold and ScreenScaffold
- [ ] Use
AppScaffold as the outer container, with ScreenScaffold children.
- [ ] Use only ONE
AppScaffold and any number of ScreenScaffold.
ScalingLazyColumn - Use TransformingLazyColumn instead.
TransformingLazyColumn - You will need the following imports:
import androidx.wear.compose.foundation.lazy.TransformingLazyColumn
import androidx.wear.compose.foundation.lazy.TransformingLazyColumnDefaults
import androidx.wear.compose.foundation.lazy.rememberTransformingLazyColumnState
// ...
import androidx.wear.compose.material3.lazy.rememberTransformationSpec
import androidx.wear.compose.material3.lazy.transformedHeight
Canonical example:
val columnState = rememberTransformingLazyColumnState()
val transformationSpec = rememberTransformationSpec()
ScreenScaffold(
scrollState = columnState
) { contentPadding ->
TransformingLazyColumn(
state = columnState,
contentPadding = contentPadding
) {
item {
ListHeader(
modifier = Modifier
.fillMaxWidth()
.transformedHeight(this, transformationSpec)
.minimumVerticalContentPadding(ListHeaderDefaults.minimumTopListContentPadding),
transformation = SurfaceTransformation(transformationSpec)
) {
Text(text = "Header")
}
}
// ... other items
item {
Button(
modifier = Modifier
.fillMaxWidth()
.transformedHeight(this, transformationSpec)
.minimumVerticalContentPadding(ButtonDefaults.minimumVerticalListContentPadding),
transformation = SurfaceTransformation(transformationSpec),
/* ... */ },
icon = {
Icon(
imageVector = Icons.Default.Build,
contentDescription = "build",
)
},
) {
Text(
text = "Build",
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
}
}
}
- [ ] Use
TransformingLazyColumn instead of ScalingLazyColumn.
- [ ] You must pass the
contentPadding parameter from ScreenScaffold to the TransformingLazyColumn.
- [ ] Use the
minimumVerticalContentPadding modifier to achieve required padding top and bottom.
- This expects a value from defaults, such as
ButtonDefaults, CardDefaults, `ListHeaderDefaults.
- Note: This is a scoped modifier available within
TransformingLazyColumnItemScope.
- [ ] Ensure the list morphs and scales.
- [ ] Use
transformedHeight modifier.
- [ ] Use
transform = SurfaceTransform(...).
- [ ] If configuring a list for snapping, use
flingBehavior and rotaryScrollableBehavior together:
val columnState = rememberTransformingLazyColumnState()
ScreenScaffold(scrollState = columnState) { contentPadding ->
TransformingLazyColumn(
state = columnState,
flingBehavior = TransformingLazyColumnDefaults.snapFlingBehavior(columnState),
rotaryScrollableBehavior = RotaryScrollableDefaults.snapBehavior(columnState)
) {
// ...
// ...
}
}
ScreenScaffold
- [ ] Guard the
scrollIndicator with !LocalScrollCaptureInProgress.current.
EdgeButton
- [ ] Do NOT use as the final item within a
TransformingLazyColumn. Instead, use the slot in ScreenScaffold.
- [ ] When used in a
TransformingLazyColumn, add the required overscroll behavior:
val columnState = rememberTransformingLazyColumnState()
ScreenScaffold(
scrollState = columnState,
edgeButton = {
EdgeButton(
/* TODO */ },
modifier = Modifier.scrollable(
columnState,
orientation = Orientation.Vertical,
reverseDirection = true,
// Apply overscroll to the EdgeButton for proper scrolling behavior.
overscrollEffect = rememberOverscrollEffect(),
)
) {
Text("More")
}
}
) { contentPadding ->
TransformingLazyColumn(
contentPadding = contentPadding,
state = columnState,
) {
// ...
// ...
}
}
Column
- [ ] USE as a direct child of
ScreenScaffold if the screen is will never scroll, even with the largest system font.
- [ ] Use
TransformingLazyColumn instead for all other cases.
Styles
- [ ] Do NOT hard-code text sizes, use
typography from MaterialTheme.
- [ ] Do NOT hard-code colors, use
colorScheme from MaterialTheme.
Use component defaults:
- [ ] Components such as
Button have a corresponding ButtonDefaults object.
- Check for and use the
*Defaults object for any component when working with padding and styling values, in preference to hard-coded values.
Use Wear specific previews:
- [ ]
WearPreviewDevices
- [ ]
WearPreviewFontScales
Ambient mode
- [ ] Use
LocalAmbientModeManager instead of AmbientLifecycleObserver.
Navigation
- [ ] When adding navigation fresh, use Navigation3.
- [ ] For Navigation3 in Wear OS, use
SwipeDismissableSceneStrategy() from the Wear Compose compose-navigation3 library.
1---2name: wear-compose-m33description: Create, update, or migrate Wear OS projects using Compose Material3, Foundation, and Navigation3 libraries with official component samples and migration guidance.4license: Complete terms in LICENSE.txt5---67## Prerequisites and compatibility891. **Wear OS Compose Material3 version:** If an internal tool is available to establish the **latest stable version** `{VERSION}` of `androidx.wear.compose:compose-material3`, use that tool.10 - Otherwise, fetch the [official Maven metadata XML](https://dl.google.com/dl/android/maven2/androidx/wear/compose/compose-material3/maven-metadata.xml) to identify `{VERSION}` (highest number, ignoring `-alpha`, `-beta`, or `-rc`).112. **Strict compliance:** If a version is listed as stable, you MUST use it, unless overridden by the user. Do not downgrade based on initial "Unresolved reference" errors in the editor or outdated web search results.123. **Kotlin version:** For Wear Compose Material3, use Kotlin **2.0.0 or13 higher**.144. **Compose compiler:**15 - If Kotlin version is **2.0.0+** , the project must use the `org.jetbrains.kotlin.plugin.compose` Gradle plugin.16 - If Kotlin version is **\< 2.0.0** , the project must use `kotlinCompilerExtensionVersion` in `composeOptions`, matching the [Compose to Kotlin Compatibility Map](https://developer.android.com/jetpack/androidx/releases/compose-kotlin).175. **Min SDK:** Ensure `minSdk` is at least **25** (Wear OS 2.0).186. **Sample extraction mandate**: Wear Compose libraries ship with an additional JAR file which contains individual samples for each and every component. You MUST NOT propose code changes until the samples in Capability 2 are extracted to the local cache. Library source files are incomplete and NOT a substitute for these samples; bypassing extraction is an environment setup failure.1920## Gotchas21221. **Mandatory sync and validation:** After updating versions in `libs.versions.toml` or `build.gradle.kts`, you **must** perform a Gradle sync before refactoring any code. This ensures the environment has resolved the libraries correctly.232. **Prohibition of guessing (error protocol):** If you encounter an 'Unresolved Reference' or API mismatch after a successful sync, do not attempt to 'fix' it by downgrading the library version.2425## Capabilities and tools2627### Capability 1: Migration2829Use this guidance when migrating from an older version of Wear OS Compose or30Horologist.31321. Unless otherwise indicated by the developer, use the latest stable version of Wear Compose Material3 from `{VERSION}`.332. Read the [migration guide](references/android/training/wearables/compose/migrate-to-material3.md).343. Use the official component mappings from the migration guide.354. Before refactoring any component (for example, `Chip` -\> `Button`), check the parameter names, slot types, and "Expressive" design tokens.365. Do not use the Horologist Composables, Compose Layout, or Compose Material libraries.376. **Always** check against the component guidance in Capability 3.387. Expect screenshot tests to fail when a migration has been performed: Even when migrating to very similar components, expected defaults for padding and positioning will have changed. Do not seek to artificially match the pre-migration screenshot, but give preference to the Material3 defaults.3940### Capability 2: Component samples4142Wear Compose includes individual component samples for each and every component,43within the `<artifact>-<version>-samples-sources.jar` file. Gradle automatically44downloads these JAR files along with the main library JAR when using any of45`compose-material3`, `compose-foundation` or `compose-navigation3`.4647Use the canonical component samples whenever adding or adjusting a Wear Compose48Material3 component.4950STRICT COMPLIANCE: Extraction is NOT optional. You are FORBIDDEN from51implementing any code until samples are extracted and read. Bypassing this step52with alternative search tools or by assuming library documentation is sufficient53is a protocol breach. You MUST verify the local cache by reading a sample file54before proceeding.5556#### Step 1: Prepare57581. Check the `build.gradle.kts` or `libs.versions.toml` to ensure the Wear Compose version matches `{VERSION}`.592. Ensure that the necessary dependencies are downloaded by doing a Gradle sync.6061#### Step 2: Check the local cache62631. Define the cache directory path: `/tmp/wear-compose-samples/{VERSION}/`. Do NOT choose your own different location.642. Check if this directory exists and contains subdirectories with `.kt` files.65 - **IF YES (cache hit):** Proceed to **Step 4**.66 - **IF NO (cache miss):** Proceed to **Step 3**.6768#### Step 3: Network-based sample retrieval6970Google Maven publishes a `-samples-sources.jar` alongside every library release.71Download and extract it directly without needing a local Gradle sync or cache72lookup.73741. Determine the `{VERSION}` of `androidx.wear.compose:compose-material3` from `build.gradle.kts` or `libs.versions.toml`.752. Define `{ARTIFACT}` as the items in the list `["material3", "foundation"]`. Also include `navigation3` if `androidx.wear.compose.navigation3` is used.763. For each `{ARTIFACT}`, run the following commands to download and extract77 the samples:7879 # Download the samples-sources JAR80 curl -sSL "https://dl.google.com/dl/android/maven2/androidx/wear/compose/compose-{ARTIFACT}/{VERSION}/compose-{ARTIFACT}-{VERSION}-samples-sources.jar" -o {ARTIFACT}-{VERSION}-samples.jar8182 # Extract and flatten into the cache directory83 unzip -q -o {ARTIFACT}-{VERSION}-samples.jar -d /tmp/wear-compose-samples/{VERSION}/{ARTIFACT}/8485 # Clean up86 rm {ARTIFACT}-{VERSION}-samples.jar87884. If this works, proceed directly to step 4.8990#### Step 4: Read samples and implement91921. Read the relevant `.kt` sample files.932. Use these official, version-matched samples as the source of truth for:94 - Required parameters and slot names.95 - Default styling and typography tokens.96 - Interactive behaviors (for example: `onClick`, `onLongClick`).97 - Component nesting (for example: `AppScaffold` -\> `ScreenScaffold`).9899### Capability 3: Component guidance100101**Mandatory**: Use this capability as a checklist against any component use. It102provides more holistic guidance on how to use each component in practice, beyond103the component syntax.1041051. `AppScaffold` and `ScreenScaffold`106 - \[ \] Use `AppScaffold` as the outer container, with `ScreenScaffold` children.107 - \[ \] Use only **ONE** `AppScaffold` and any number of `ScreenScaffold`.1082. `ScalingLazyColumn` - Use `TransformingLazyColumn` instead.1093. `TransformingLazyColumn` - You will need the following imports:110111112 ```kotlin113 import androidx.wear.compose.foundation.lazy.TransformingLazyColumn114 import androidx.wear.compose.foundation.lazy.TransformingLazyColumnDefaults115 import androidx.wear.compose.foundation.lazy.rememberTransformingLazyColumnState116 // ...117 import androidx.wear.compose.material3.lazy.rememberTransformationSpec118 import androidx.wear.compose.material3.lazy.transformedHeight119 ```120121 <br />122123 **Canonical example**:124125126 ```kotlin127 val columnState = rememberTransformingLazyColumnState()128 val transformationSpec = rememberTransformationSpec()129 ScreenScaffold(130 scrollState = columnState131 ) { contentPadding ->132 TransformingLazyColumn(133 state = columnState,134 contentPadding = contentPadding135 ) {136 item {137 ListHeader(138 modifier = Modifier139 .fillMaxWidth()140 .transformedHeight(this, transformationSpec)141 .minimumVerticalContentPadding(ListHeaderDefaults.minimumTopListContentPadding),142 transformation = SurfaceTransformation(transformationSpec)143 ) {144 Text(text = "Header")145 }146 }147 // ... other items148 item {149 Button(150 modifier = Modifier151 .fillMaxWidth()152 .transformedHeight(this, transformationSpec)153 .minimumVerticalContentPadding(ButtonDefaults.minimumVerticalListContentPadding),154 transformation = SurfaceTransformation(transformationSpec),155 onClick = { /* ... */ },156 icon = {157 Icon(158 imageVector = Icons.Default.Build,159 contentDescription = "build",160 )161 },162 ) {163 Text(164 text = "Build",165 maxLines = 1,166 overflow = TextOverflow.Ellipsis,167 )168 }169 }170 }171 }172 ```173174 <br />175176 - \[ \] Use `TransformingLazyColumn` instead of `ScalingLazyColumn`.177 - \[ \] You must pass the `contentPadding` parameter from `ScreenScaffold` to the `TransformingLazyColumn`.178 - \[ \] Use the `minimumVerticalContentPadding` modifier to achieve required padding top and bottom.179 - This expects a value from defaults, such as `ButtonDefaults`, `CardDefaults`, \`ListHeaderDefaults.180 - Note: This is a scoped modifier available within `TransformingLazyColumnItemScope`.181 - \[ \] Ensure the list morphs and scales.182 - \[ \] Use `transformedHeight` modifier.183 - \[ \] Use `transform = SurfaceTransform(...)`.184 - \[ \] If configuring a list for snapping, use `flingBehavior` and `rotaryScrollableBehavior` **together**:185186187 ```kotlin188 val columnState = rememberTransformingLazyColumnState()189 ScreenScaffold(scrollState = columnState) { contentPadding ->190 TransformingLazyColumn(191 state = columnState,192 flingBehavior = TransformingLazyColumnDefaults.snapFlingBehavior(columnState),193 rotaryScrollableBehavior = RotaryScrollableDefaults.snapBehavior(columnState)194 ) {195 // ...196 // ...197 }198 }199 ```200201 <br />2022034. `ScreenScaffold`204205 - \[ \] Guard the `scrollIndicator` with `!LocalScrollCaptureInProgress.current`.2065. `EdgeButton`207208 - \[ \] Do **NOT** use as the final item within a `TransformingLazyColumn`. Instead, use the slot in `ScreenScaffold`.209 - \[ \] When used in a `TransformingLazyColumn`, add the required overscroll behavior:210211212 ```kotlin213 val columnState = rememberTransformingLazyColumnState()214 ScreenScaffold(215 scrollState = columnState,216 edgeButton = {217 EdgeButton(218 onClick = { /* TODO */ },219 modifier = Modifier.scrollable(220 columnState,221 orientation = Orientation.Vertical,222 reverseDirection = true,223 // Apply overscroll to the EdgeButton for proper scrolling behavior.224 overscrollEffect = rememberOverscrollEffect(),225 )226 ) {227 Text("More")228 }229 }230 ) { contentPadding ->231 TransformingLazyColumn(232 contentPadding = contentPadding,233 state = columnState,234 ) {235 // ...236 // ...237 }238 }239 ```240241 <br />2422436. `Column`244245 - \[ \] USE as a direct child of `ScreenScaffold` *if* the screen is will **never** scroll, even with the largest system font.246 - \[ \] Use `TransformingLazyColumn` instead for all other cases.2477. Styles248249 - \[ \] Do **NOT** hard-code text sizes, use `typography` from `MaterialTheme`.250 - \[ \] Do **NOT** hard-code colors, use `colorScheme` from `MaterialTheme`.2518. Use component defaults:252253 - \[ \] Components such as `Button` have a corresponding `ButtonDefaults` object.254 - Check for and use the `*Defaults` object for any component when working with padding and styling values, in preference to hard-coded values.2559. Use Wear specific previews:256257 - \[ \] `WearPreviewDevices`258 - \[ \] `WearPreviewFontScales`25910. Ambient mode260261 - \[ \] Use `LocalAmbientModeManager` instead of `AmbientLifecycleObserver`.26211. Navigation263264 - \[ \] When adding navigation fresh, use Navigation3.265 - \[ \] For Navigation3 in Wear OS, use `SwipeDismissableSceneStrategy()` from the Wear Compose `compose-navigation3` library.