zt
07/26/2024, 8:40 PMzt
07/26/2024, 8:43 PMval MiniTextButtonContentPadding: PaddingValues
get() = PaddingValues(
horizontal = 8.dp,
vertical = 4.dp
)
@Composable
fun MiniTextButton(
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
shape: Shape = ButtonDefaults.textShape,
colors: ButtonColors = ButtonDefaults.textButtonColors(),
elevation: ButtonElevation? = null,
border: BorderStroke? = null,
contentPadding: PaddingValues = MiniTextButtonContentPadding,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
content: @Composable RowScope.() -> Unit
) {
CompositionLocalProvider(
LocalMinimumInteractiveComponentSize provides Dp.Unspecified,
LocalTextStyle provides MaterialTheme.typography.labelMedium
) {
Button(
onClick = onClick,
modifier = modifier.heightIn(28.dp),
enabled = enabled,
shape = shape,
colors = colors,
elevation = elevation,
border = border,
contentPadding = contentPadding,
interactionSource = interactionSource,
content = content
)
}
}
And I'm using it like
Box(
modifier = Modifier.wrapContentSize(Alignment.TopStart)
) {
var showDropdown by rememberSaveable { mutableStateOf(false) }
MiniTextButton(
onClick = { showDropdown = true },
content = label
)
DropdownMenu(
expanded = showDropdown,
onDismissRequest = { showDropdown = false },
content = content
)
}
I've tried adjusting the heightIn modifier but it doesn't change anything except the button itself
If I put a TextButton then the dropdown menu is in the correct place, but that's too big for my usageMichael Paus
07/27/2024, 7:23 AMzt
07/27/2024, 3:59 PM