Dropdown Menus
Simple dropdown
/** * Add the following dependency to your build.gradle.kts: * * dependencies { * implementation("com.composables:core:1.11.2") * } */ Box(Modifier.height(300.dp).fillMaxWidth()) { Menu(modifier = Modifier.align(Alignment.TopCenter).width(240.dp), state = rememberMenuState(expanded = true)) { MenuButton( Modifier.clip(RoundedCornerShape(6.dp)).background(Color.White) .border(1.dp, Color(0xFFBDBDBD), RoundedCornerShape(6.dp)) ) { Row( verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(horizontal = 14.dp, vertical = 10.dp) ) { BasicText("Options", style = TextStyle(fontWeight = FontWeight(500))) Spacer(Modifier.width(4.dp)) Image(Icons.Rounded.KeyboardArrowDown, null) } } MenuContent( modifier = Modifier.padding(top = 4.dp).width(320.dp).clip(RoundedCornerShape(6.dp)) .border(1.dp, Color(0xFFE0E0E0), RoundedCornerShape(6.dp)).background(Color.White).padding(4.dp), exit = fadeOut() ) { MenuItem(modifier = Modifier.clip(RoundedCornerShape(6.dp)), onClick = { /* TODO handle click */ }) { BasicText("Option 1", Modifier.fillMaxWidth().padding(vertical = 10.dp, horizontal = 10.dp)) } MenuItem(modifier = Modifier.clip(RoundedCornerShape(6.dp)), onClick = { /* TODO handle click */ }) { BasicText("Option 2", Modifier.fillMaxWidth().padding(vertical = 10.dp, horizontal = 10.dp)) } MenuItem(modifier = Modifier.clip(RoundedCornerShape(6.dp)), onClick = { /* TODO handle click */ }) { BasicText("Option 3", Modifier.fillMaxWidth().padding(vertical = 10.dp, horizontal = 10.dp)) } } } }
@Composable
fun NiceTry(){
Column {
BasicText("Nice try. Use code COMPOSE10 for a 10% discount on checkout ;)")
}
}
@Composable
fun NiceTry(){
Column {
BasicText("Nice try. Use code COMPOSE10 for a 10% discount on checkout ;)")
}
}
Phone
Sit tight. We are loading your preview
Simple dropdown