Tuesday, June 28, 2022
  • Home
  • Event
  • Technology
  • Program
  • Education
No Result
View All Result
E-Capitals
No Result
View All Result
Home Program

Component Spacing in a Design System | CSS-Tricks

admin by admin
January 26, 2022
in Program
0
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter

Related Posts

Great Web Development Books You Can Read Free | CSS-Tricks

Top 10 Computer Science Universities in USA

Single Element Loaders: The Bars | CSS-Tricks

Different Ways to Write CSS in React | CSS-Tricks

Say you’ve got a <Card /> component. It’s highly likely it shouldn’t be butted right up against any other components with no spacing around it. That’s true for… pretty much every component. So, how do you handle component spacing in a design system?

Do you apply spacing using margin directly on the <Card />? Perhaps margin-block-end: 1rem; margin-inline-end: 1rem; so it pushes away from the two sides where more content natural flows? That’s a little presumptuous. Perhaps the cards are children inside a <Grid /> component and the grid applies a gap: 1rem. That’s awkward, as now the <Card /> component spacing is going to conflict with the <Grid /> component spacing, which is very likely not what you want, not to mention the amount of space is hard coded.

Adding space to the inline start and block end of a card component.

Different perspectives on component spacing

Eric Bailey got into this recently and looked at some options:

  • You could bake spacing into every component and try to be as clever as you can about it. (But that’s pretty limiting.)
  • You could pass in component spacing, like <Card space="xxl" />. (That can be a good approach, likely needs more than one prop, maybe even one for each direction, which is quite verbose.)
  • You could use no component spacing and create something like a <Spacer /> or <Layout /> component specifically for spacing between components. (It breaks up the job of components nicely, but can also be verbose and add unnecessary DOM weight.)

This conversation has a wide spectrum of viewpoints, some as extreme as Max Stoiber saying just never use margin ever at all. That’s a little dogmatic for me, but I like that it’s trying to rethink things. I do like the idea of taking the job of spacing and layout away from components themselves — like, for example, those content components should completely not care where they are used and let layout happen a level up from them.

Adam Argyle predicted a few years back that the use of margin in CSS would decline as the use of gap rises. He’s probably going to end up right about this, especially now that flexbox has gap and that developers have an appetite these dats to use CSS Flexbox and Grid on nearly everything at both a macro and micro level.

Next Post

Microsoft Teams surpasses 270M monthly active users, as growth slows from early days of pandemic

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Popular Posts

Event

Events May Turn Away From States Where Abortion is Now Illegal

by admin
June 28, 2022
0

Skift Take The U.S. Supreme Court’s seismic decision to strike down Roe v. Wade is sending shock waves through the...

Read more

Events May Turn Away From States Where Abortion is Now Illegal

Fan uses Twitter and DoorDash to deliver pizza to Mariners player at Angel Stadium after brawl – GeekWire

Expedia hires chief security officer; Microsoft technical fellow departing; and more – GeekWire

Help! My Husband Resents My Summers Off

UW program supports underserved STEM students – GeekWire

Challenge Kids to Complete This Color-as-You-Go Reading Challenge

Load More

Popular Posts

Best Winter Olympics Activities for Kids in the Classroom

by admin
January 19, 2022
0

What is Packet Sniffing Attack? – Types and How to Prevent It?

by admin
December 11, 2021
0

Zain Nadella, 1996-2022: Microsoft CEO’s son remembered for love of music, bright smile, profound impact on his dad

by admin
March 1, 2022
0

Copyright © 2021 - e-Capitals.com DESIGNED AND DEVELOPED BY TEAM WORDPRESS BLOGX

No Result
View All Result
  • Home
    • Home 1
    • Home 2
    • Home 3
  • Event
  • Technology
  • Program
  • Education

Copyright © 2021 - e-capitals.com - DESIGNED AND DEVELOPED BY TEAM WORDPRESS BLOGX