What's your criteria on using padding vs spacer ? ...
# compose
s
What's your criteria on using padding vs spacer ? Most of the time I got confused whether to apply padding or use the spacer.
c
I've been using a spacer as much as possible on the outside edges of a component. I use padding when I need space between composables (like between two Text composables) in a component. There was some more discussion around this here: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1607996900279600
k
Similar to padding vs margins in "regular" Android layouts. Paddings are from the edge of a component inwards, so they count for the component's bounds. Margins are between the components at the level of the parent container. Sometimes you can use both for the same purpose if you will. The answer to which one to use is where does that space belong. Does it belong inside the component, or in between the components?
☝️ 3
☝🏽 1
☝🏼 1
You can also ask the question "Do I want this seemingly empty area to respond to user interaction, including taps and ripples?"
👍🏽 1
👍 4
176 Views