is there any way to align the contents of a button...
# compose-desktop
l
is there any way to align the contents of a button to the side?
o
What do you mean exactly? AFAIR button content is called on a RowScope, so any alignment for rows should work. If not, you can put a box or column inside and do whatever you wish
l
So I'm trying to make a few buttons that will use the full width of a column, but the text inside of it it's always centered, tried using alignments or padding and nothing worked
Copy code
@Composable
fun MenuButton(text: String, goTo: () -> Unit) {
    TextButton(
        onClick = { goTo },
        shape = RectangleShape,
        modifier = Modifier
            .fillMaxWidth()
    ){
        Text(text = text,
            textAlign = TextAlign.Left,
            color = Color.Black)
    }
}
Since the button will repeat itself a bunch of times I made into a Composable element
c
@Luukas if I'm understanding correctly, you want to remove the padding from a Button in the material package. All material buttons conform to material spec and try their best to prevent you mis-using them. I would just use a base button. It doesn't have any padding.
l
Like... a Button() ? @Colton Idle I'm sorry I'm new to kotlin and jetpack ;-;
c
TextButton is imported from material package no? There should be some other base button to use. Not sure haven't used it.
l
I mean, there is button, which is also part of the material package, but sadly I cannot even change the background color on that one
I got to change the background color, but now it has a shadow...
c
Is BaseButton a thing?
"I got to change the background color, but now it has a shadow..." Yeah. You're using a material button. Look for a button not in that package
❤️ 1
c
You could also just recreate the button with primitive Composables, e.g. Row + Modifier.clickable, to your exact visual liking.
❤️ 1
As mentioned the Button component in Compose is meant to a Material style button out of the box. Though most Buttons in most design systems center align the text. So if you want to create an element that is clickable and has a ripple, and is stylistically different from the out-of-the-box Button, it would be best to create it with Row/Column + clickable modifier.
Example
l
Ooooh that makes so much sense, ty! ❤️
c
@Chris Sinco [G] is there no such thing as BaseButton? I could have sworn I was listening to some podcast with (@Clara Bayarri?) and she was saying that all of the Base components are there to build upon the second you don't want/need material.
o
There is no
BasicButton
(but there is
BasicText
), button is just a clickable box with a row with content inside. All the rest is just default look and click animations.
👍 3