Use padding, paddingXY and paddingEach with elm-ui

Flavio Corpa
InstructorFlavio Corpa
Share this video with your friends

Social Share Links

Send Tweet
Published 3 years ago
Updated 3 years ago

Since we mentioned in a previous lesson that there is no concept of "margin" in elm-ui, we are goint to learn how to se padding, paddingXY and paddingEach to compensate for that, and a little trick defining a value edges that is going to be pretty useful.

Instructor: [0:00] You might remember that we mentioned before that there's no concept of margin in Elm-UI. You already are familiar with padding, which gives the same amount to the four different sides, top, bottom, left, and right.

[0:13] We're going to go to our breakdown button, and we want to make it a bit more special. We're going to say paddingXY. We're going to say 20 for the x-axis and for the y's. You notice that now it's centered.

[0:28] With padding we effect the four sides. With paddingXY we can affect two sides at the same time. What happens if we want to be more custom since we don't have margins and the only thing we have is spacing and padding?

[0:41] We're going to do a little trick. We're going to say edges, and we're going to give it top = , right = , bottom = , and left = . We're going to Int for the annotation. Now we're going to say paddingEach, we're going to pass edges. We're just going to modify and say that we want the left to be 20 and the top to be 30.

[1:08] This way, we can handle all possible cases and we can use our edge trick, and you will notice that you won't miss having margins at all. Padding and spacing is all we need.

egghead
egghead
~ 4 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today