bulma/docs/documentation/form/select.html

379 lines
9.5 KiB
HTML
Raw Normal View History

2017-07-17 18:17:57 +00:00
---
2017-07-29 12:02:00 +00:00
title: Select
2024-03-21 16:11:54 +00:00
layout: docs
theme: library
2017-07-17 18:17:57 +00:00
doc-tab: form
doc-subtab: select
2018-04-09 15:15:58 +00:00
breadcrumb:
2024-03-21 16:11:54 +00:00
- home
- documentation
- form
- form-select
2018-04-09 15:15:58 +00:00
meta:
colors: true
sizes: true
variables: false
2017-07-17 18:17:57 +00:00
---
{% capture select_example %}
<div class="select">
<select>
<option>Select dropdown</option>
<option>With options</option>
</select>
</div>
{% endcapture %}
{% capture select_multiple_example %}
<div class="select is-multiple">
<select multiple size="8">
<option value="Argentina">Argentina</option>
<option value="Bolivia">Bolivia</option>
<option value="Brazil">Brazil</option>
<option value="Chile">Chile</option>
<option value="Colombia">Colombia</option>
<option value="Ecuador">Ecuador</option>
<option value="Guyana">Guyana</option>
<option value="Paraguay">Paraguay</option>
<option value="Peru">Peru</option>
<option value="Suriname">Suriname</option>
<option value="Uruguay">Uruguay</option>
<option value="Venezuela">Venezuela</option>
</select>
</div>
{% endcapture %}
2017-12-04 15:48:33 +00:00
{% capture rounded_example %}
<div class="select is-rounded">
<select>
<option>Rounded dropdown</option>
<option>With options</option>
</select>
</div>
{% endcapture %}
2017-07-17 18:17:57 +00:00
{% capture normal_example %}
<div class="select">
<select>
<option>Select dropdown</option>
<option>With options</option>
</select>
2017-07-17 18:17:57 +00:00
</div>
{% endcapture %}
{% capture hover_example %}
<div class="select">
<select class="is-hovered">
<option>Select dropdown</option>
<option>With options</option>
</select>
2017-07-17 18:17:57 +00:00
</div>
{% endcapture %}
{% capture focus_example %}
<div class="select">
<select class="is-focused">
<option>Select dropdown</option>
<option>With options</option>
</select>
2017-07-17 18:17:57 +00:00
</div>
{% endcapture %}
{% capture loading_example %}
<div class="select is-loading">
<select>
<option>Select dropdown</option>
<option>With options</option>
</select>
2017-07-17 18:17:57 +00:00
</div>
{% endcapture %}
{% capture disabled_example %}
<div class="select is-disabled">
<select disabled>
<option>Select dropdown</option>
<option>With options</option>
</select>
2017-07-17 18:17:57 +00:00
</div>
{% endcapture %}
{% capture icons_example %}
<div class="control has-icons-left">
<div class="select">
<select>
<option selected>Country</option>
<option>Select dropdown</option>
<option>With options</option>
</select>
</div>
<div class="icon is-small is-left">
<i class="fas fa-globe"></i>
2017-07-17 18:17:57 +00:00
</div>
</div>
{% endcapture %}
{% capture has_icons_small_example %}
<div class="control has-icons-left">
<div class="select is-small">
<select>
<option selected>Country</option>
<option>Select dropdown</option>
<option>With options</option>
</select>
</div>
<span class="icon is-small is-left">
2018-01-10 16:30:23 +00:00
<i class="fas fa-globe"></i>
2017-07-17 18:17:57 +00:00
</span>
</div>
{% endcapture %}
{% capture has_icons_normal_example %}
<div class="control has-icons-left">
<div class="select">
<select>
<option selected>Country</option>
<option>Select dropdown</option>
<option>With options</option>
</select>
</div>
<span class="icon is-left">
2018-01-10 16:30:23 +00:00
<i class="fas fa-globe"></i>
2017-07-17 18:17:57 +00:00
</span>
</div>
{% endcapture %}
{% capture has_icons_medium_example %}
<div class="control has-icons-left">
<div class="select is-medium">
<select>
<option selected>Country</option>
<option>Select dropdown</option>
<option>With options</option>
</select>
</div>
<span class="icon is-medium is-left">
2018-01-10 16:30:23 +00:00
<i class="fas fa-globe"></i>
2017-07-17 18:17:57 +00:00
</span>
</div>
{% endcapture %}
{% capture has_icons_large_example %}
<div class="control has-icons-left">
<div class="select is-large">
<select>
<option selected>Country</option>
<option>Select dropdown</option>
<option>With options</option>
</select>
</div>
<span class="icon is-large is-left">
2018-01-10 16:30:23 +00:00
<i class="fas fa-globe"></i>
2017-07-17 18:17:57 +00:00
</span>
</div>
{% endcapture %}
2018-04-09 15:15:58 +00:00
<div class="content">
2019-10-13 19:06:56 +00:00
<p>
2024-03-21 16:11:54 +00:00
The <code>select</code> class is a simple wrapper around the <code>&lt;select&gt;</code> HTML element, which gives
the styling more flexibility and support for icons.
2019-10-13 19:06:56 +00:00
</p>
2018-04-09 15:15:58 +00:00
</div>
<div class="columns">
2024-03-21 16:11:54 +00:00
<div class="column is-half">{{ select_example }}</div>
<div class="column is-half bd-highlight-full">
2024-03-21 16:11:54 +00:00
{% highlight html -%}
{{- select_example -}}
{%- endhighlight %}
2018-04-09 15:15:58 +00:00
</div>
</div>
2017-07-17 18:17:57 +00:00
2019-10-13 19:06:56 +00:00
<div class="content">
<p>Several <strong>modifiers</strong> are supported which affect:</p>
<ul>
2024-03-21 16:11:54 +00:00
<li>
the <strong><a href="#colors">color</a></strong>
</li>
<li>
the <strong><a href="#sizes">size</a></strong>
</li>
<li>
the <strong><a href="#states">state</a></strong>
</li>
2019-10-13 19:06:56 +00:00
</ul>
</div>
2017-07-17 18:17:57 +00:00
2024-03-21 16:11:54 +00:00
{% include docs/elements/anchor.html name="Multiple select" %}
2017-07-17 18:17:57 +00:00
2018-04-09 15:15:58 +00:00
<div class="columns">
<div class="column is-half">
2017-07-17 18:17:57 +00:00
<div class="content">
2018-04-09 15:15:58 +00:00
<p>
2024-03-21 16:11:54 +00:00
You can style a <strong>multiple select</strong> dropdown, by using the <code>is-multiple</code> modifier, and
by using the <code>multiple</code> HTML attribute.
2018-04-09 15:15:58 +00:00
</p>
2017-07-17 18:17:57 +00:00
</div>
2019-10-13 19:06:56 +00:00
{{ select_multiple_example }}
2018-04-09 15:15:58 +00:00
</div>
<div class="column is-half bd-highlight-full">
2024-03-21 16:11:54 +00:00
{% highlight html -%}
{{- select_multiple_example -}}
{%- endhighlight %}
2018-04-09 15:15:58 +00:00
</div>
</div>
2017-07-17 18:17:57 +00:00
2024-03-21 16:11:54 +00:00
{% include docs/elements/anchor.html name="Colors" %}
{% for color in site.data.colors.justColors %}
2024-03-21 16:11:54 +00:00
{% capture foobar %}
<div class="select is-{{ color }}">
<select>
<option>Select dropdown</option>
<option>With options</option>
</select>
2018-04-09 15:15:58 +00:00
</div>
{% endcapture %}
2024-03-21 16:11:54 +00:00
{% include docs/elements/snippet.html content=foobar %}
{% endfor %}
2024-03-21 16:11:54 +00:00
{% include docs/elements/anchor.html name="Styles" %}
2017-07-17 18:17:57 +00:00
2019-10-13 19:06:56 +00:00
<div class="content">
2024-03-21 16:11:54 +00:00
<p>You can create a <strong>rounded dropdown</strong> by appending the <code>is-rounded</code> modifier:</p>
2019-10-13 19:06:56 +00:00
</div>
2018-04-09 15:15:58 +00:00
<div class="columns">
2024-03-21 16:11:54 +00:00
<div class="column is-half">{{ rounded_example }}</div>
2018-04-09 15:15:58 +00:00
<div class="column is-half">
2024-03-21 16:11:54 +00:00
{% highlight html -%}
{{- rounded_example -}}
{%- endhighlight %}
2018-04-09 15:15:58 +00:00
</div>
</div>
2017-12-04 15:48:33 +00:00
2024-03-21 16:11:54 +00:00
{% include docs/elements/anchor.html name="Sizes" %}
2017-12-04 15:48:33 +00:00
2019-10-13 19:06:56 +00:00
<div class="content">
2024-03-21 16:11:54 +00:00
<p>The <code>select</code> element comes in <strong>4</strong> different sizes:</p>
2019-10-13 19:06:56 +00:00
</div>
{% for size in site.data.sizes %}
2024-03-21 16:11:54 +00:00
{% capture foobar %}
<div class="select is-{{ size }}">
<select>
<option>Select dropdown</option>
<option>With options</option>
</select>
2018-04-09 15:15:58 +00:00
</div>
{% endcapture %}
2024-03-21 16:11:54 +00:00
{% include docs/elements/snippet.html content=foobar %}
{% endfor %}
2024-03-21 16:11:54 +00:00
{% include docs/elements/anchor.html name="States" %}
2019-10-13 19:06:56 +00:00
<div class="content">
<p>
2024-03-21 16:11:54 +00:00
Bulma styles the different <strong>states</strong> of the <code>select</code> element. Each state is available as a
pseudo-class and a CSS class:
2019-10-13 19:06:56 +00:00
</p>
<ul>
2024-03-21 16:11:54 +00:00
<li><code>:hover</code> and <code>is-hovered</code></li>
<li><code>:focus</code> and <code>is-focused</code></li>
<li><code>:active</code> and <code>is-active</code></li>
2019-10-13 19:06:56 +00:00
</ul>
2024-03-21 16:11:54 +00:00
<p>This allows you to obtain the style of a certain state without having to trigger it.</p>
2019-10-13 19:06:56 +00:00
</div>
2017-07-17 18:17:57 +00:00
2018-04-09 15:15:58 +00:00
<h4 class="subtitle">Normal</h4>
2019-10-13 19:06:56 +00:00
2018-04-09 15:15:58 +00:00
<div class="columns">
2024-03-21 16:11:54 +00:00
<div class="column is-half">{{ normal_example }}</div>
2018-04-09 15:15:58 +00:00
<div class="column is-half">
2024-03-21 16:11:54 +00:00
{% highlight html -%}
{{- normal_example -}}
{%- endhighlight %}
2018-04-09 15:15:58 +00:00
</div>
</div>
2017-07-17 18:17:57 +00:00
2018-04-09 15:15:58 +00:00
<h4 class="subtitle">Hover</h4>
<div class="columns">
2024-03-21 16:11:54 +00:00
<div class="column is-half">{{ hover_example }}</div>
2018-04-09 15:15:58 +00:00
<div class="column is-half">
2024-03-21 16:11:54 +00:00
{% highlight html -%}
{{- hover_example -}}
{%- endhighlight %}
2018-04-09 15:15:58 +00:00
</div>
</div>
2017-07-17 18:17:57 +00:00
2018-04-09 15:15:58 +00:00
<h4 class="subtitle">Focus</h4>
<div class="columns">
2024-03-21 16:11:54 +00:00
<div class="column is-half">{{ focus_example }}</div>
2018-04-09 15:15:58 +00:00
<div class="column is-half">
2024-03-21 16:11:54 +00:00
{% highlight html -%}
{{- focus_example -}}
{%- endhighlight %}
2018-04-09 15:15:58 +00:00
</div>
</div>
2017-07-17 18:17:57 +00:00
2018-04-09 15:15:58 +00:00
<h4 class="subtitle">Loading</h4>
<div class="columns">
2024-03-21 16:11:54 +00:00
<div class="column is-half">{{ loading_example }}</div>
2018-04-09 15:15:58 +00:00
<div class="column is-half">
2024-03-21 16:11:54 +00:00
{% highlight html -%}
{{- loading_example -}}
{%- endhighlight %}
2018-04-09 15:15:58 +00:00
</div>
</div>
2017-07-17 18:17:57 +00:00
2024-03-21 16:11:54 +00:00
{% include docs/elements/anchor.html name="With icons" %}
2018-04-09 15:15:58 +00:00
<div class="content">
<p>You can append the <strong>modifier</strong> on a control:</p>
<ul>
<li>
<code>has-icons-left</code>
</li>
</ul>
<p>You also need to add a modifier on the <strong>icon</strong>:</p>
<ul>
2024-03-21 16:11:54 +00:00
<li><code>icon is-left</code> since <code>has-icons-left</code> is used</li>
2018-04-09 15:15:58 +00:00
</ul>
<p>The size of the <strong>select</strong> will define the size of the icon container.</p>
</div>
<div class="columns">
2024-03-21 16:11:54 +00:00
<div class="column is-half">{{ icons_example }}</div>
2018-04-09 15:15:58 +00:00
<div class="column is-half">
2024-03-21 16:11:54 +00:00
{% highlight html -%}
{{- icons_example -}}
{%- endhighlight %}
2018-04-09 15:15:58 +00:00
</div>
</div>
2017-07-17 18:17:57 +00:00
2018-04-09 15:15:58 +00:00
<div class="columns">
<div class="column is-half">
2017-07-17 18:17:57 +00:00
<div class="content">
2018-04-09 15:15:58 +00:00
<p>
2024-03-21 16:11:54 +00:00
If the control contains an icon, Bulma will make sure the icon remains
<strong>centered</strong>, no matter the size of the input <em>or</em> of the icon.
2018-04-09 15:15:58 +00:00
</p>
2017-07-17 18:17:57 +00:00
</div>
2019-10-13 19:06:56 +00:00
{{ has_icons_small_example }}
2018-04-09 15:15:58 +00:00
</div>
<div class="column is-half">
2024-03-21 16:11:54 +00:00
{% highlight html -%}
{{- has_icons_small_example -}}
{%- endhighlight %}
2018-04-09 15:15:58 +00:00
</div>
</div>
2017-07-17 18:17:57 +00:00
2018-04-09 15:15:58 +00:00
<div class="columns">
2024-03-21 16:11:54 +00:00
<div class="column is-half">{{ has_icons_normal_example }}</div>
2018-04-09 15:15:58 +00:00
<div class="column is-half">
2024-03-21 16:11:54 +00:00
{% highlight html -%}
{{- has_icons_normal_example -}}
{%- endhighlight %}
2018-04-09 15:15:58 +00:00
</div>
</div>
2017-07-17 18:17:57 +00:00
2018-04-09 15:15:58 +00:00
<div class="columns">
2024-03-21 16:11:54 +00:00
<div class="column is-half">{{ has_icons_medium_example }}</div>
2018-04-09 15:15:58 +00:00
<div class="column is-half">
2024-03-21 16:11:54 +00:00
{% highlight html -%}
{{- has_icons_medium_example -}}
{%- endhighlight %}
2018-04-09 15:15:58 +00:00
</div>
</div>
2017-07-17 18:17:57 +00:00
2018-04-09 15:15:58 +00:00
<div class="columns">
2024-03-21 16:11:54 +00:00
<div class="column is-half">{{ has_icons_large_example }}</div>
2018-04-09 15:15:58 +00:00
<div class="column is-half">
2024-03-21 16:11:54 +00:00
{% highlight html -%}
{{- has_icons_large_example -}}
{%- endhighlight %}
2017-07-17 18:17:57 +00:00
</div>
2018-04-09 15:15:58 +00:00
</div>