bulma/docs/documentation/sass/extends.html

76 lines
2.3 KiB
HTML
Raw Permalink Normal View History

2021-09-19 00:23:53 +00:00
---
2024-03-21 16:11:54 +00:00
title: Bulma Sass Extends
layout: docs
theme: sass
doc-tab: sass
2021-09-19 22:36:15 +00:00
doc-subtab: extends
2021-09-19 00:23:53 +00:00
breadcrumb:
2024-03-21 16:11:54 +00:00
- home
- documentation
- sass
- sass-extends
2021-09-19 00:23:53 +00:00
---
2024-03-21 16:11:54 +00:00
2021-09-19 00:23:53 +00:00
<div class="content">
2021-09-19 22:36:15 +00:00
<p>
In Bulma, a lot of element <strong>share</strong> a set of styles. While mixins allow sharing, they repeat the CSS rules everytime they are used.
</p>
<p>
To avoid the repetition, Bulma uses the <code>@extend</code> rule to share code. This rule tells Sass that one selector should inherit the styles of another. <a href="https://sass-lang.com/documentation/at-rules/extend" target="_blank">Learn more about the extend rule</a>.
</p>
<p>
Instead of creating CSS classes that might not be used to be the <strong>source</strong> of the set of styles, Bulma uses Sass <strong>placeholders</strong>:
</p>
<ul>
<li>
2024-03-21 16:11:54 +00:00
{% include docs/elements/snippet-inline.html content="%control" %}
2021-09-19 22:36:15 +00:00
</li>
<li>
2024-03-21 16:11:54 +00:00
{% include docs/elements/snippet-inline.html content="%unselectable" %}
2021-09-19 22:36:15 +00:00
</li>
<li>
2024-03-21 16:11:54 +00:00
{% include docs/elements/snippet-inline.html content="%arrow" %}
2021-09-19 22:36:15 +00:00
</li>
<li>
2024-03-21 16:11:54 +00:00
{% include docs/elements/snippet-inline.html content="%block" %}
2021-09-19 22:36:15 +00:00
</li>
<li>
2024-03-21 16:11:54 +00:00
{% include docs/elements/snippet-inline.html content="%delete" %}
2021-09-19 22:36:15 +00:00
</li>
<li>
2024-03-21 16:11:54 +00:00
{% include docs/elements/snippet-inline.html content="%loader" %}
2021-09-19 22:36:15 +00:00
</li>
<li>
2024-03-21 16:11:54 +00:00
{% include docs/elements/snippet-inline.html content="%overlay" %}
2021-09-19 22:36:15 +00:00
</li>
<li>
2024-03-21 16:11:54 +00:00
{% include docs/elements/snippet-inline.html content="%reset" %}
2021-09-19 22:36:15 +00:00
</li>
</ul>
{% assign mixins_link = site.data.links.by_id['utilities-mixins'] %}
{% assign controls_link = site.data.links.by_id['utilities-control-mixins'] %}
<p>
Each of these placeholders are simply the <code>@extend</code> version of their <a href="{{ site.url }}{{ mixins_link.path }}">corresponding mixins</a> (here for the <a href="{{ site.url }}{{ controls_link.path }}">control mixin</a>).
</p>
2021-09-19 00:23:53 +00:00
</div>
2024-03-21 16:11:54 +00:00
{% include docs/elements/anchor.html name="How to use Bulma extends" %}
<div class="content">Import the extend rules with <code>@use</code> and use them with <code>@extend</code>:</div>
{% highlight sass %}
@use "bulma/sass/utilities/extends";
.my-control {
@extend %control;
background-color: purple;
color: white;
}
{% endhighlight %}