bulma/docs/documentation/sass/form-control-mixins.html

137 lines
3.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 Form Control Mixins
layout: docs
theme: sass
doc-tab: sass
doc-subtab: form-control-mixins
2021-09-19 00:23:53 +00:00
breadcrumb:
2024-03-21 16:11:54 +00:00
- home
- documentation
- sass
- sass-form-control-mixins
2021-09-19 00:23:53 +00:00
---
2024-03-21 16:11:54 +00:00
2021-09-19 22:36:15 +00:00
<div class="content">
<p>
In Bulma, the <strong>form controls</strong> are an essential part of the framework. They comprise the following elements:
</p>
<ul>
<li>
<code>.button</code>
</li>
<li>
<code>.input</code>
</li>
<li>
<code>.select</code>
</li>
<li>
<code>.file-cta</code>
<code>.file-name</code>
</li>
<li>
<code>.pagination-previous</code>
<code>.pagination-next</code>
<code>.pagination-link</code>
<code>.pagination-ellipsis</code>
</li>
</ul>
<p>
The <code>control()</code> mixin ensures <strong>consistency</strong> by providing a set of styles that are shared between all these form controls. You can use it to create additional controls:
</p>
</div>
2024-03-21 16:11:54 +00:00
{% highlight sass %}@use "bulma/sass/utilities/controls";
.bulma-control-mixin {
@include controls.control;
2021-09-19 22:36:15 +00:00
background: deeppink;
color: white;
}{% endhighlight %}
{% capture control-mixin %}
<button class="bulma-control-mixin">
My control
</button>
{% endcapture %}
2024-03-21 16:11:54 +00:00
{% include docs/elements/snippet.html content=control-mixin %}
2021-09-19 22:36:15 +00:00
2024-03-21 16:11:54 +00:00
{% include docs/elements/anchor.html name="Sizes" %}
2021-09-19 22:36:15 +00:00
<div class="content">
<p>
2022-01-24 11:52:36 +00:00
Controls have a default font size of <code>$size-normal</code> and also come in <strong>3 additional sizes</strong>, which can be accessed via 3 additional mixins:
2021-09-19 22:36:15 +00:00
</p>
<ul>
<li>
2024-04-29 12:17:18 +00:00
{% include docs/elements/snippet-inline.html content="@include controls.control-small;" %} with a font size <code>$size-small</code>
2021-09-19 22:36:15 +00:00
</li>
<li>
2024-04-29 12:17:18 +00:00
{% include docs/elements/snippet-inline.html content="@include controls.control-medium;" %} with a font size <code>$size-medium</code>
2021-09-19 22:36:15 +00:00
</li>
<li>
2024-04-29 12:17:18 +00:00
{% include docs/elements/snippet-inline.html content="@include controls.control-large;" %} with a font size <code>$size-large</code>
2021-09-19 22:36:15 +00:00
</li>
</ul>
2021-09-19 00:23:53 +00:00
</div>
2021-09-19 22:36:15 +00:00
{% highlight sass %}.bulma-control-mixin {
&.is-small {
2024-04-29 12:17:18 +00:00
@include controls.control-small;
2021-09-19 22:36:15 +00:00
}
&.is-medium {
2024-04-29 12:17:18 +00:00
@include controls.control-medium;
2021-09-19 22:36:15 +00:00
}
&.is-large {
2024-04-29 12:17:18 +00:00
@include controls.control-large;
2021-09-19 22:36:15 +00:00
}
}{% endhighlight %}
{% capture control-mixin-sizes %}
<button class="bulma-control-mixin is-small">
Small
</button>
<button class="bulma-control-mixin">
Normal
</button>
<button class="bulma-control-mixin is-medium">
Medium
</button>
<button class="bulma-control-mixin is-large">
Large
</button>
{% endcapture %}
2024-03-21 16:11:54 +00:00
{% include docs/elements/snippet.html content=control-mixin-sizes %}
2021-09-19 22:36:15 +00:00
2024-03-21 16:11:54 +00:00
{% include docs/elements/anchor.html name="Control placeholder" %}
2021-09-19 22:36:15 +00:00
2021-09-19 00:23:53 +00:00
<div class="content">
2021-09-19 22:36:15 +00:00
<p>
The <code>control()</code> mixin also exists as <a href="https://sass-lang.com/documentation/at-rules/extend#placeholder-selectors" target="_blank">Sass placeholder</a> <code>%control</code>
</p>
2021-09-19 00:23:53 +00:00
</div>
2021-09-19 22:36:15 +00:00
2024-03-21 16:11:54 +00:00
{% highlight sass %}@use "bulma/sass/utilities/extends";
.bulma-control-extend {
2021-09-19 22:36:15 +00:00
@extend %control;
background: mediumblue;
color: white;
}{% endhighlight %}
{% capture control-extend %}
<button class="bulma-control-extend">
My control
</button>
{% endcapture %}
2024-03-21 16:11:54 +00:00
{% include docs/elements/snippet.html content=control-extend %}