rem Units and Font-Sizing with ' @use' in Dart Sass v1.80.0+ #4
ByteB4rb1e
started this conversation in
Mind Meld
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
As part of the reference implementation, I've been exploring effective ways to manage rem units, determine where font-sizing variables should live, and leverage Dart Sass' @use syntax to streamline modularity and maintainability.
Handling rem Units and Font-Sizing
Since rem units are based on the root font-size, font-sizing becomes more than just a styling choice—it directly impacts layout structure. This shifts some responsibilities from components to layouts, as layouts define the global scaling system.
A practical approach is to:
Placement of Font-Sizing Variables
While these variables are often placed in a shared
abstracts/_variables.scssfile, the shift in responsibility raises the question of whether they belong inbase/_typography.scssinstead. Doing so clarifies ownership, as typography is conceptually tied to these variables.This approach lets typography "own" the definitions while keeping them accessible wherever needed through SCSS imports.
Leveraging Dart Sass’ @use Syntax
The
@usesyntax enables cleaner modularization by:Example workflow
This setup demonstrates how to retrofit font-sizing and rem scaling with
@use, while still keeping things vanilla as intended by the 7:1 pattern:Font-Sizing in
base/_typography.scss:Using Font-Sizing in Layouts:
This workflow aligns font-sizing with the scaling system in layouts while ensuring typography variables are accessible without bloating the global namespace.
Conclusion
Aligning rem units and font-sizing with the structural responsibilities of layouts provides a solid foundation for scalable and maintainable themes. By leveraging Dart Sass’
@usesyntax, it's possible to streamline SCSS workflows further, eliminating unnecessary abstraction layers and enabling clearer ownership of variables like font-sizing. These approaches reduce technical debt, improve modularity, and make the codebase more intuitive for collaboration and extension.Beta Was this translation helpful? Give feedback.
All reactions