I have a composable that's like material 3 TextBut...
# compose
z
I have a composable that's like material 3 TextButton but smaller. The issue im having is when I use it with a DropdownMenu is it's getting positioned far off from the button. Code in 🧵
This is the MiniTextButton composable
Copy code
val 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
Copy code
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 usage
m
Is it possible you are hit by this? LocalMinimumInteractiveComponentSize
z
I tried providing Dp.Unspecified but no change