I
I
Ilya Pirozhok2016-09-02 15:05:25
css
Ilya Pirozhok, 2016-09-02 15:05:25

Include or extend in Sass?

So I can not figure out which is preferable and in what situations? Tell me from your experience. Thanks

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
fetis26, 2016-09-02
@fetis26

In my opinion include. The abundance of extends litters the selectors.

M
metaf, 2016-09-02
@metaf

Think of it like this - extend creates relationships between selectors. Consider whether you need to link h1 and button to make them bold or green? I think no.
but extend for general styles of the same single button can be useful. Although, if you need a mixin for the buttons (and you most likely will, because you will need to pass parameters), then use a mixin. Also extend can be useful in headers and the like.
Many people don’t like Extend because if you have more than one nesting level + you write several selectors (separated by commas), then the result in the collected CSS can be the most unexpected ...
In all other cases, it makes more sense to use a mixin.

A
andead, 2016-09-02
@andead

I only use mixin because extend doesn't work in media.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question