Anyone know why Material3 has a hardcoded default ...
# compose
m
Anyone know why Material3 has a hardcoded default button shape? Rather than using one of the shapes from the theme like Material2 did?
Copy code
ShapeKeyTokens.CornerFull -> CircleShape
c
Because you define the shapes in the theme https://m3.material.io/styles/shape/overview
m
@Chrimaeon My point is that shapes are defined in the theme. However, for buttons, if you follow the code path, the default shape of Button ends up being a fixed value that's unnaffected by any theme settings.
Copy code
shape: Shape = ButtonDefaults.shape,
Copy code
val shape: Shape
    @Composable get() = FilledButtonTokens.ContainerShape.value
Copy code
val ContainerShape = ShapeKeyTokens.CornerFull
Copy code
ShapeKeyTokens.CornerFull -> CircleShape
Copy code
val CircleShape = RoundedCornerShape(50)
In material2, it comes from the theme:
Copy code
shape: Shape = MaterialTheme.shapes.small,
It's a big deal, since it can be overridden by a parameter, I'm just curious
c
CornerFull is a shape. its just one you cannot override. as defined in the guidelines a “full” corner is rounded by 50%.
m
hence, it's a "hardcoded" shape that doesn't come from the theme. That's my point
c
just pass a shape to the shape property:
Copy code
OutlinedButton(
        onClick = { },
        modifier = Modifier.padding(16.dp),
        shape = MaterialTheme.shapes.extraLarge
    ) { }
m
It's a departure from material 2 which is why i asked
c
whats the issue with that?
m
Curiosity mostly, but if you wanted to straight up use MaterialTheme, you can't affect the rounding on the buttons in one place. You'd have to override it at every location (which includes having a wrapper function that you're forced to call) rather than just using
Button
out of the box and letting the theme change the rounding
👍🏼 1
k
And in M2 you would override the small shape and it would affect all usages of that thing, not just for the buttons.