Menus
Menus

Cascading submenu

A menu item that opens a nested submenu from a trailing chevron.

Rename
Share to
Messages
Mail
Copy link

Installation

caveui components are copy-paste Jetpack Compose built entirely on Material 3 — there's no caveui dependency to add. Make sure Material 3 is on your classpath (it ships with the Compose BOM), then copy the Usage snippet below into your project.

kotlin
// build.gradle.kts (module)
dependencies {
    implementation(platform("androidx.compose:compose-bom:2025.06.00"))
    implementation("androidx.compose.material3:material3")
}

Usage

kotlin
@Composable
fun ShareSubmenu() {
    var open by remember { mutableStateOf(false) }
    var sub by remember { mutableStateOf(false) }
    Box {
        TextButton(onClick = { open = true }) { Text("Actions") }
        DropdownMenu(expanded = open, onDismissRequest = { open = false }) {
            DropdownMenuItem(text = { Text("Rename") }, onClick = {})
            DropdownMenuItem(
                text = { Text("Share to") },
                trailingIcon = { Icon(Icons.Filled.ChevronRight, null) },
                onClick = { sub = true },
            )
        }
        DropdownMenu(expanded = sub, onDismissRequest = { sub = false },
            offset = DpOffset(160.dp, 0.dp)) {
            listOf("Messages", "Mail", "Copy link").forEach {
                DropdownMenuItem(text = { Text(it) }, onClick = { sub = false; open = false })
            }
        }
    }
}