Is it possible in SASS to inherit from a class in another file?

Dan Tao picture Dan Tao · Aug 3, 2012 · Viewed 57.3k times · Source

The question pretty much says it all.

For instance, if I were using, say, Twitter Bootstrap, could I define classes in my own SASS stylesheet that inherit from Bootstrap's CSS classes? Or does inheritance in SASS only work within the scope of a single file?

Answer

agustibr picture agustibr · Mar 7, 2013

YES! its possible.

If you want all <button> elements to inherit the .btn class from Twitter Bootstrap's Default buttons

In your styles.scss file you would have to first import _bootstrap.scss:

@import "_bootstrap.scss";

Then below the import:

button { @extend .btn; }