How can one import only variables and mixins from Sass stylesheets?

Imports are an all or nothing thing. Everything that’s in the file is what you get. If you look through the source of Foundation, though, there are variables you can modify that will suppress emitting styles (eg. in buttons, setting $include-html-button-classes to false will disable the styles). This design pattern is Foundation specific, you cannot expect other libraries to be authored this way.

When you import foundation via @import "foundation", you’re importing this file: https://github.com/zurb/foundation/blob/master/scss/foundation.scss. As you can see, it imports other files. You don’t have to import this file if you don’t need everything: just import the specific file you want (eg. @import 'foundation/components/side-nav' for only the side-nav file).

Leave a Comment