LiftKit Spacing Explained (In Detail) — Transcript
Full transcript
- 0:03hi welcome back to chainlift in the last
- 0:04video we talked a lot about spacing but
- 0:07we didn't go too far into the details we
- 0:09talked about how related elements should
- 0:11be closer together and we briefly
- 0:13touched on how you can use variables to
- 0:15control the size of spacing increments
- 0:17but we can go even deeper and I intend
- 0:19to you see spacing is just one component
- 0:22of the overarching global scaling system
- 0:25this scaling system controls the size of
- 0:27everything including typography and
- 0:29space sping but what does that mean for
- 0:31us well let's start by simply
- 0:34establishing that spacing in lift kit at
- 0:36least is dynamic it's not fixed in other
- 0:39words you don't use spacer blocks with
- 0:41fixed Heights like 20 pixels instead
- 0:44spacing is always determined relative to
- 0:46the elements you are applying that
- 0:48spacing to for example if you want to
- 0:50put space between two text elements
- 0:52you're going to apply a margin property
- 0:54measured in M instead of inserting a
- 0:56spacer block this makes the space
- 0:58responsive meaning it scales
- 1:00proportionately according to the
- 1:01browser's default font size now you
- 1:04might be asking why is that important
- 1:05let's look at some sample
- 1:07implementations on the right is a layout
- 1:09using fixed spacing units measured in
- 1:11pixels and on the left is a layout using
- 1:13relative spacing if we have our browser
- 1:15font size set to the default and our
- 1:17screen is 1600 pixels wide they both
- 1:20look about the same but now let's say I
- 1:23have a vision impairment and I need to
- 1:25set my browser's default font size to be
- 1:27a little bit larger if my minimum font F
- 1:30size is higher at the browser level the
- 1:32card using the spacer blocks loses its
- 1:34proportions that's because the card on
- 1:36the right has fixed spacing of 20 pixels
- 1:38between the text elements and no matter
- 1:41how big or small your font preferences
- 1:43are 20 pixels is 20 pixels so to
- 1:45summarize relative spacing ensures your
- 1:48layouts display consistently at
- 1:50different screen sizes and zoom levels
- 1:52and it's able to do that because it
- 1:53defines space in terms of font size but
- 1:55why font size what about needing to
- 1:57define space between non-text elements
- 2:00like an image grid where I have to
- 2:01define the size of all these gaps am I
- 2:03really telling you that we're going to
- 2:04Define that based on font size when
- 2:06there's no text on the screen whatsoever
- 2:09you better believe I am and it requires
- 2:11us to understand something called the
- 2:13root font size let's take a second to
- 2:15review how relative units work in
- 2:17general and we'll start with a square
- 2:20all its sides are one unit long and this
- 2:22rectangle is three units long that's how
- 2:24relative units work I'm describing
- 2:26everything in terms of that arbitrary
- 2:28base that I've decided it is just
- 2:30whatever this one unit square is in web
- 2:33design our base unit is not going to be
- 2:35an arbitrary Square it's going to be the
- 2:37root font size or the default font size
- 2:40in your browser now this is the ideal
- 2:42choice for our base unit because it's
- 2:43the simplest unit of size that is built
- 2:46into the fabric of the internet and it's
- 2:47at the core of all user configurable
- 2:50scaling preferences if one Rim is 16
- 2:53pixels then if I want to make a
- 2:55rectangle that's two rims long I can
- 2:58know it'll render to 32 pixels long
- 3:01spacing is relative to font size but we
- 3:03don't just have one font size and if
- 3:06we're defining space in terms of rims
- 3:08then we're just going to run into a new
- 3:10problem look at these three cards
- 3:12they're all just a title and a paragraph
- 3:14but they're using different styles now
- 3:16we know the space between two elements
- 3:18should be proportional to the size of
- 3:20those elements but if I'm defining them
- 3:22in terms of Rim I'm going to have a lot
- 3:24to keep track of I'm going to have to
- 3:26look at the big one and say okay so if
- 3:28this is 1.5 rim and then the body text
- 3:30is one Rim maybe 0.25 Rim looks good for
- 3:33the space great let's go to the next one
- 3:35where it's down to 1.25 and then 75 I'm
- 3:39going to have to find another value for
- 3:41that one and then for the third card the
- 3:43fonts change again so I'm going to have
- 3:44to remember a third one and if you have
- 3:46a type system with 12 unique class
- 3:49styles that gives us 66 possible unique
- 3:52font pairings I do not want to have to
- 3:54remember 66 different values here what I
- 3:58would love to do is just come on in and
- 4:01have a utility class where I can just
- 4:03remember oh that's a title in a
- 4:05paragraph doesn't matter what their
- 4:08actual class names are I know based on
- 4:10my preferences that I want these to be
- 4:13equal to extra small and because I'm
- 4:15defining these relative to the larger
- 4:18text element with m not rims I'm able to
- 4:22just reliably build utility classes like
- 4:24that that makes sense cool the benefit
- 4:27of this system is that it's not not
- 4:29always going to guarantee Perfection but
- 4:31it is going to make it difficult to look
- 4:34bad the math behind this is really
- 4:36simple in lift kit spacing is defined as
- 4:39any value that's applied to an element's
- 4:41margin padding or Gap properties and
- 4:43there are seven preset sizes or varibles
- 4:45of spacing that are baked into the
- 4:47framework the table below describes what
- 4:50their default values are and how they're
- 4:52derived it's pretty simple basically you
- 4:55start with the base unit that's what
- 4:57medium is it's always just one and then
- 4:59you scale up or down by multiplying or
- 5:02dividing by five the golden ratio but
- 5:05this is just the default configuration
- 5:07and its values are R whenever you're
- 5:08applying spacing properties to non-text
- 5:11elements but spacing behaves quite
- 5:13differently when you're applying it to
- 5:15actual text elements because in that
- 5:17scenario spacing is referring to the
- 5:19text element not the root font size in
- 5:22addition to that because we have to
- 5:24account for the height of the element's
- 5:25bounding box and not just its rendered
- 5:28text height or Point height we get
- 5:31unique Behavior which happens luckily
- 5:33automatically and is controlled by the
- 5:35global CSS at the top of the page the
- 5:37only special cases here are going to be
- 5:40for the display one text class and the
- 5:42body text class as well as their bold uh
- 5:46variants because they have different
- 5:47line Heights the display one needs to be
- 5:50a little bit shorter and body is a
- 5:52little bit
- 5:53taller so let's talk about some common
- 5:55questions namely what if you need
- 5:58something in between
- 6:00these seven default spacing sizes after
- 6:02all towards the larger side of things
- 6:05they definitely take some significant
- 6:06jumps that's okay these spacing
- 6:08increments are described in steps and
- 6:11steps work the same way as they do in
- 6:13musical notation a whole step is a
- 6:15factor of 1.618 or five a half step is a
- 6:19factor of 1
- 6:29step which is a factor of 1.128 or the
- 6:32square root of the square root of five I
- 6:35have never needed more Nuance than a
- 6:36quarter step but if you do you can keep
- 6:38following this pattern although you may
- 6:40want to consult a psychiatrist let's go
- 6:42over some common use cases and as we do
- 6:44please keep in mind that just like in
- 6:46the real world Size Matters nine times
- 6:49out of 10 you should set the spacing
- 6:50property relative to the larger element
- 6:53it was designed this way and if you do
- 6:54make them relative to smaller units you
- 6:56might wind up with some unexpected
- 6:58Behavior first up is card padding for
- 7:00cards containing two or more text Styles
- 7:03you may remember this from the first
- 7:04video where we provided Optical
- 7:06Corrections here's the formula for how I
- 7:09derive the rest of the padding I'm going
- 7:11to say let x equal the largest font size
- 7:14in the container and let H equal the
- 7:16line height of X with that in mind we
- 7:19can derive padding left right and Bottom
- 7:21by simply setting them equal to X
- 7:24padding top is equal to X overh and the
- 7:26Border radius is equal to the padding on
- 7:29the top
- 7:30this is to provide an optical correction
- 7:32to the extra space on top that is caused
- 7:35by symmetrical padding I think that this
- 7:37is worth focusing on because the eye is
- 7:39naturally focused on the top left
- 7:41there's a lot more visual weight there
- 7:44due to the presence of the heading and
- 7:45so asymmetry there is more noticeable
- 7:48than anywhere else in the card now this
- 7:51is still a really small amount of space
- 7:54that we're talking about so don't forget
- 7:56that we're just splitting hairs here if
- 7:58you thought that was contr buckle up
- 8:00because we're about to talk about
- 8:02buttons this is a lift kit button and it
- 8:05can be annotated like this it spacing
- 8:07properties are derived from these
- 8:09formulas which in CSS look like this the
- 8:12reason I went into all of this trouble
- 8:14is because iOS 17 and material 3 both
- 8:17have asymmetries with inline buttons for
- 8:19inline I want it to feel like this icon
- 8:22has the same amount of space on all
- 8:24sides of it but in order to do that you
- 8:26need to provide Optical corrections to
- 8:29highlight the asymmetry we can expand
- 8:32these circles uh around the bounding
- 8:34boxes and see that the lift kit button
- 8:37fits very nicely into that shape but
- 8:39both iOS and material 3 have this little
- 8:41bit of extra space on the end uh that
- 8:44irritates me maybe it doesn't bother you
- 8:46but if it does this is how you fix it
- 8:48list items are not as convoluted
- 8:50thankfully you all remember this from
- 8:52the last one we were talking about the
- 8:54relations of these things and so let's
- 8:57just dive in here
- 9:00if you wanted to convert this to lift
- 9:02kit tight Styles you shouldn't but if we
- 9:04did it would look like this and then
- 9:07from here we could let X be the element
- 9:10with the largest font size let y be the
- 9:12element at the bottom of the card and we
- 9:14can set the margins accordingly using
- 9:16the M top extra small and M bottom small
- 9:20respectively and when we take away the
- 9:22annotations you can see that it's not
- 9:25necessarily better but that's how you
- 9:26would do it remember I mean I'm applying
- 9:29lift rules inside of a Mac OS system so
- 9:31it's going to look a little bit off but
- 9:33honestly it's still not that bad I mean
- 9:35a simpler application would be if you're
- 9:37adding M top Xs and M bottom XS uh to
- 9:42these list items which only have a
- 9:44single text element on the inside that
- 9:46definitely makes things a little bit
- 9:47easier all right so what's next well
- 9:50it's time to experiment and try it out
- 9:53for yourself you can get the global CSS
- 9:55that's available at chainlift io/
- 9:58liftkit of course you can still try it
- 10:00in web flow that clonable is going to be
- 10:02the fastest way for you to get building
- 10:04with it and igma file is coming soon I
- 10:06don't know how long it's going to take
- 10:08but it is the next priority in the
- 10:10meantime thank you for watching and I'll
- 10:13see you in the next video
About this transcript
This page contains the full transcript of LiftKit Spacing Explained (In Detail) by Chainlift, generated from the public captions YouTube serves with the video. The transcript has 1,926 words across 266 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.