🦀 clamp()
battle
#2322
zarahzachz
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The design system currently has a small selection of responsive font-sizes being used (mostly for large headings, Drawer, and StepList).
We’re hoping in our next major release to bundle all font changes in that release, so this seems a prime opportunity to figure out if we want to go all in on responsive font-sizing, or if we want to move away from that pattern and adopt the UKGOV solution of flat sizing across viewports.
🟢 Pro-Clamp (expanding responsive font-sizes)
clamp()
is a new CSS function that allows you to define ideal minimum and maximum sizes, and scale between those values based on the viewport size.E.g., say you want the text within a button to be the equivalent of 14px on mobile, but 18px on desktop; it would look something like
font-size: clamp(14px, 5vw, 18px)
. The middle value in that function represents the ideal font-size and must be a responsive value (5% of the device viewport width, orvw
, in this case).There are several reasons clamp() is cool:
clamp()
is a one-line solution that empowers the browser to handle the math to create responsive font sizesWe can implement clamp() today on the few responsive font sizes we have with little to no noticeable change, but if we’re doing the work we might as well look at how we’re scaling font-size across the entire system while we’re at it.
Responsive font-sizing is good because:
🔴 Anti-Clamp (remove responsive font-sizes)
Alternatively, we could remove the few responsive font sizes we use from the design system, again, following UKGOV's lead.
Removing responsive sizing has the following benefits:
clamp()
, we can remove the media queries)It's worth noting some of our larger fonts might be less legible on smaller viewports if responsive sizing is removed. Also, if we remove our responsive sizing, we would need to reevaluate the purpose our responsive utility classes serve.
Beta Was this translation helpful? Give feedback.
All reactions