Why does Jetpack Compose provide separate button types like OutlinedButton and TextButton, instead of passing the button style as a parameter to a single Button type?
I understand that this will help us in better code organization and maintainability, and also make it easier to understand the purpose of the components from the name directly, rather than a generic name with a bunch of parameters!
This question isn't just about buttons, but this design decision of why Jetpack Compose offers multiple composable functions for different visual styles, rather than providing a single base composable function that can be customized with style parameters.
Because in the end, if we see the code of these components, you will see it is calling the base components with just different parameters:
@Composable
fun OutlinedButton(
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
shape: Shape = ButtonDefaults.outlinedShape,
colors: ButtonColors = ButtonDefaults.outlinedButtonColors(),
elevation: ButtonElevation? = null,
border: BorderStroke? = ButtonDefaults.outlinedButtonBorder,
contentPadding: PaddingValues = ButtonDefaults.ContentPadding,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
content: @Composable RowScope.() -> Unit
) =
Button(
onClick = onClick,
modifier = modifier,
enabled = enabled,
shape = shape,
colors = colors,
elevation = elevation,
border = border,
contentPadding = contentPadding,
interactionSource = interactionSource,
content = content
)
Material design components exist not only for Compose, but for Views, Web, Flutter, and as a design principle.
Because of that they are not just styles but Components with each own guidelines, rationale and purposes to create a design style with both M2 and M3.



https://m3.material.io/components/all-buttons
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With