Is there a way to have a Material Button with a gr...
# compose
c
Is there a way to have a Material Button with a gradient? I found this sample which works until I try to apply a CircleShape to it so that it becomes a "pill" shaped button. https://stackoverflow.com/questions/65542068/jetpack-compose-button-with-gradient-background Is there no way to define a single color as a gradient?
c
AFAIK the material spec does not mention gradients for buttons so Compose material library Buttons don't support it. However the JetSnack sample has an example of implementing a custom Button with gradients
1
c
Yeah trying to use modifiers to add the gradient won't work well due to the layering within the Button implementation in how it's using Surface and passing color parameters down through the tree. It would be easier ATM to just reimplement Button which is essentially what Jetsnack does - that is, it sets the inner Surface color to unspecified, and instead uses a gradient background color modifier.
And yes, Material spec doesn't have gradient buttons, even in Material3, so there hasn't been a request yet to make Material Button flexible for gradients. But it doesn't hurt to file a request. 🙂
c
Will file! Thanks for the link to jetsnack. that sounds like exactly what I need!
👍 1