bulma/docs/documentation/form/input.html

445 lines
11 KiB
HTML
Raw Normal View History

2017-07-17 14:51:22 +00:00
---
2017-07-29 12:02:00 +00:00
title: Input
2024-03-21 16:11:54 +00:00
layout: docs
theme: library
2017-07-17 14:51:22 +00:00
doc-tab: form
doc-subtab: input
2018-04-09 15:15:58 +00:00
breadcrumb:
2024-03-21 16:11:54 +00:00
- home
- documentation
- form
- form-input
variables_keys:
2024-03-21 16:11:54 +00:00
- $input-color
- $input-background-color
- $input-border-color
- $input-shadow
- $input-hover-color
- $input-hover-border-color
- $input-focus-color
- $input-focus-border-color
- $input-focus-box-shadow-size
- $input-focus-box-shadow-color
- $input-disabled-color
- $input-disabled-background-color
- $input-disabled-border-color
- $input-arrow
- $input-icon-color
- $input-icon-active-color
- $input-radius
2018-04-09 15:15:58 +00:00
meta:
colors: true
sizes: true
variables: true
2017-07-17 14:51:22 +00:00
---
{% capture input_example %}
2024-03-21 16:11:54 +00:00
<input class="input" type="text" placeholder="Text input" />
2017-07-17 14:51:22 +00:00
{% endcapture %}
2017-12-04 15:48:33 +00:00
{% capture rounded_example %}
2024-03-21 16:11:54 +00:00
<input class="input is-rounded" type="text" placeholder="Rounded input" />
2017-12-04 15:48:33 +00:00
{% endcapture %}
2017-07-17 14:51:22 +00:00
{% capture normal_example %}
<div class="control">
2024-03-21 16:11:54 +00:00
<input class="input" type="text" placeholder="Normal input" />
2017-07-17 14:51:22 +00:00
</div>
{% endcapture %}
{% capture hover_example %}
<div class="control">
2024-03-21 16:11:54 +00:00
<input class="input is-hovered" type="text" placeholder="Hovered input" />
2017-07-17 14:51:22 +00:00
</div>
{% endcapture %}
{% capture focus_example %}
<div class="control">
2024-03-21 16:11:54 +00:00
<input class="input is-focused" type="text" placeholder="Focused input" />
2017-07-17 14:51:22 +00:00
</div>
{% endcapture %}
{% capture loading_example %}
<div class="control is-loading">
2024-03-21 16:11:54 +00:00
<input class="input" type="text" placeholder="Loading input" />
2017-07-17 14:51:22 +00:00
</div>
{% endcapture %}
{% capture loading_sizes_example %}
<div class="field">
<div class="control is-small is-loading">
2024-03-21 16:11:54 +00:00
<input
class="input is-small"
type="text"
placeholder="Small loading input"
/>
2017-07-17 14:51:22 +00:00
</div>
</div>
<div class="field">
<div class="control is-loading">
2024-03-21 16:11:54 +00:00
<input class="input" type="text" placeholder="Normal loading input" />
2017-07-17 14:51:22 +00:00
</div>
</div>
<div class="field">
<div class="control is-medium is-loading">
2024-03-21 16:11:54 +00:00
<input
class="input is-medium"
type="text"
placeholder="Medium loading input"
/>
2017-07-17 14:51:22 +00:00
</div>
</div>
<div class="field">
<div class="control is-large is-loading">
2024-03-21 16:11:54 +00:00
<input
class="input is-large"
type="text"
placeholder="Large loading input"
/>
2017-07-17 14:51:22 +00:00
</div>
</div>
{% endcapture %}
{% capture disabled_example %}
<div class="control">
2024-03-21 16:11:54 +00:00
<input class="input" type="text" placeholder="Disabled input" disabled />
2017-07-17 14:51:22 +00:00
</div>
{% endcapture %}
2017-09-18 22:33:19 +00:00
{% capture readonly_example %}
<div class="control">
2024-03-21 16:11:54 +00:00
<input class="input" type="text" value="This text is readonly" readonly />
2017-09-18 22:33:19 +00:00
</div>
{% endcapture %}
{% capture static_example %}
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">From</label>
</div>
<div class="field-body">
<div class="field">
<p class="control">
2024-03-21 16:11:54 +00:00
<input
class="input is-static"
type="email"
value="me@example.com"
readonly
/>
2017-09-18 22:33:19 +00:00
</p>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">To</label>
</div>
<div class="field-body">
<div class="field">
<p class="control">
2024-03-21 16:11:54 +00:00
<input class="input" type="email" placeholder="Recipient email" />
2017-09-18 22:33:19 +00:00
</p>
</div>
</div>
</div>
{% endcapture %}
2017-07-17 14:51:22 +00:00
{% capture icons_example %}
<div class="field">
<p class="control has-icons-left has-icons-right">
2024-03-21 16:11:54 +00:00
<input class="input" type="email" placeholder="Email" />
2017-07-17 14:51:22 +00:00
<span class="icon is-small is-left">
2018-01-10 16:30:23 +00:00
<i class="fas fa-envelope"></i>
2017-07-17 14:51:22 +00:00
</span>
<span class="icon is-small is-right">
2018-01-10 16:30:23 +00:00
<i class="fas fa-check"></i>
2017-07-17 14:51:22 +00:00
</span>
</p>
</div>
<div class="field">
<p class="control has-icons-left">
2024-03-21 16:11:54 +00:00
<input class="input" type="password" placeholder="Password" />
2017-07-17 14:51:22 +00:00
<span class="icon is-small is-left">
2018-01-10 16:30:23 +00:00
<i class="fas fa-lock"></i>
2017-07-17 14:51:22 +00:00
</span>
</p>
</div>
{% endcapture %}
{% capture has_icons_small_example %}
<div class="control has-icons-left has-icons-right">
2024-03-21 16:11:54 +00:00
<input class="input is-small" type="email" placeholder="Email" />
2017-07-17 14:51:22 +00:00
<span class="icon is-small is-left">
2018-01-10 16:30:23 +00:00
<i class="fas fa-envelope"></i>
2017-07-17 14:51:22 +00:00
</span>
<span class="icon is-small is-right">
2018-01-10 16:30:23 +00:00
<i class="fas fa-check"></i>
2017-07-17 14:51:22 +00:00
</span>
</div>
{% endcapture %}
{% capture has_icons_normal_example %}
<div class="control has-icons-left has-icons-right">
2024-03-21 16:11:54 +00:00
<input class="input" type="email" placeholder="Email" />
2017-07-17 14:51:22 +00:00
<span class="icon is-small is-left">
2018-01-10 16:30:23 +00:00
<i class="fas fa-envelope"></i>
2017-07-17 14:51:22 +00:00
</span>
<span class="icon is-small is-right">
2018-01-10 16:30:23 +00:00
<i class="fas fa-check"></i>
2017-07-17 14:51:22 +00:00
</span>
</div>
{% endcapture %}
{% capture has_icons_medium_example %}
<div class="control has-icons-left has-icons-right">
2024-03-21 16:11:54 +00:00
<input class="input is-medium" type="email" placeholder="Email" />
2017-07-17 14:51:22 +00:00
<span class="icon is-left">
2018-01-10 16:30:23 +00:00
<i class="fas fa-envelope"></i>
2017-07-17 14:51:22 +00:00
</span>
<span class="icon is-right">
2018-01-10 16:30:23 +00:00
<i class="fas fa-check"></i>
2017-07-17 14:51:22 +00:00
</span>
</div>
{% endcapture %}
{% capture has_icons_large_example %}
<div class="control has-icons-left has-icons-right">
2024-03-21 16:11:54 +00:00
<input class="input is-large" type="email" placeholder="Email" />
2017-07-17 14:51:22 +00:00
<span class="icon is-medium is-left">
2018-01-10 16:30:23 +00:00
<i class="fas fa-envelope"></i>
2017-07-17 14:51:22 +00:00
</span>
<span class="icon is-medium is-right">
2018-01-10 16:30:23 +00:00
<i class="fas fa-check"></i>
2017-07-17 14:51:22 +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 Bulma <code>input</code> CSS class is meant for <code>&lt;input&gt;</code> HTML elements. The following
<a href="http://htmlreference.io/element/input/" target="_blank">type attributes</a>
are supported:
2019-10-13 19:06:56 +00:00
</p>
2018-04-09 15:15:58 +00:00
<ul>
<li><code>type="text"</code></li>
<li><code>type="password"</code></li>
<li><code>type="email"</code></li>
<li><code>type="tel"</code></li>
</ul>
2024-03-21 16:11:54 +00:00
<p>Several <strong>modifiers</strong> are supported which affect:</p>
2019-10-13 19:06:56 +00:00
<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>
2018-04-09 15:15:58 +00:00
</div>
2017-07-17 14:51:22 +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">{{ input_example }}</div>
<div class="column is-half bd-highlight-full">
2024-03-21 16:11:54 +00:00
{% highlight html -%}
{{- input_example -}}
{%- endhighlight %}
2018-04-09 15:15:58 +00:00
</div>
</div>
2017-07-17 14:51:22 +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 %}
<input
class="input is-{{ color }}"
type="text"
placeholder="{{ color | capitalize }} input"
/>
{% 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="Sizes" %}
{% for size in site.data.sizes %}
2024-03-21 16:11:54 +00:00
{% capture foobar %}
<input
class="input is-{{ size }}"
type="text"
placeholder="{{ size | capitalize }} input"
/>
{% 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-12-04 15:48:33 +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">{{ 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-07-17 14:51:22 +00:00
2024-03-21 16:11:54 +00:00
{% include docs/elements/anchor.html name="States" %}
2017-07-17 14:51:22 +00:00
<h4 class="title is-5">Normal</h4>
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 14:51:22 +00:00
<h4 class="title is-5">Hover</h4>
2018-04-09 15:15:58 +00:00
<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 14:51:22 +00:00
<h4 class="title is-5">Focus</h4>
2018-04-09 15:15:58 +00:00
<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 14:51:22 +00:00
<h4 class="title is-5">Loading</h4>
2018-04-09 15:15:58 +00:00
<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 14:51:22 +00:00
2018-04-09 15:15:58 +00:00
<div class="columns">
<div class="column is-half">
2017-09-18 22:33:19 +00:00
<div class="content">
<p>
2024-03-21 16:11:54 +00:00
You can resize the loading spinner by appending <code>is-small</code>, <code>is-medium</code> or
<code>is-large</code> to the <code>control</code> container.
2017-09-18 22:33:19 +00:00
</p>
</div>
2024-03-21 16:11:54 +00:00
{{ loading_sizes_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 -%}
{{- loading_sizes_example -}}
{%- endhighlight %}
2018-04-09 15:15:58 +00:00
</div>
</div>
2017-09-18 22:33:19 +00:00
<h4 class="title is-5">Disabled</h4>
2018-04-09 15:15:58 +00:00
<div class="columns">
2024-03-21 16:11:54 +00:00
<div class="column is-half">{{ disabled_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 -%}
{{- disabled_example -}}
{%- endhighlight %}
2018-04-09 15:15:58 +00:00
</div>
</div>
2017-09-18 22:33:19 +00:00
<h4 class="title is-5">Readonly and static inputs</h4>
2018-04-09 15:15:58 +00:00
<div class="content">
<p>
2024-03-21 16:11:54 +00:00
If you use the <code>readonly</code> HTML attribute, the input will look similar to a normal one, but is not
editable and has no shadow.
2018-04-09 15:15:58 +00:00
</p>
</div>
<div class="columns">
2024-03-21 16:11:54 +00:00
<div class="column is-half">{{ readonly_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 -%}
{{- readonly_example -}}
{%- endhighlight %}
2018-04-09 15:15:58 +00:00
</div>
</div>
2017-09-18 22:33:19 +00:00
2018-04-09 15:15:58 +00:00
<div class="content">
<p>
2024-03-21 16:11:54 +00:00
If you <em>also</em> append the <code>is-static</code> modifier, it removes the background, border, shadow, and
horizontal padding, while maintaining the <strong>vertical spacing</strong> so you can easily align the input in any
context, like a horizontal form.
2018-04-09 15:15:58 +00:00
</p>
</div>
2017-07-17 14:51:22 +00:00
2024-03-21 16:11:54 +00:00
<div class="bd-example">{{ static_example }}</div>
{% highlight html -%}
{{- static_example -}}
{%- endhighlight %}
2018-04-09 15:15:58 +00:00
<!-- Font Awesome Icons -->
2024-03-21 16:11:54 +00:00
{% include docs/elements/anchor.html name="With Font Awesome icons" %}
2018-04-09 15:15:58 +00:00
<div class="content">
<p>You can append one of 2 <strong>modifiers</strong> on a control:</p>
<ul>
<li>
<code>has-icons-left</code>
</li>
2024-03-21 16:11:54 +00:00
<li>and/or <code>has-icons-right</code></li>
2018-04-09 15:15:58 +00:00
</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> if <code>has-icons-left</code> is used</li>
<li><code>icon is-right</code> if <code>has-icons-right</code> is used</li>
2018-04-09 15:15:58 +00:00
</ul>
<p>The size of the <strong>input</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 14:51:22 +00:00
2018-04-09 15:15:58 +00:00
<div class="columns">
<div class="column is-half">
<div class="content">
<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 14:51:22 +00:00
</div>
2024-03-21 16:11:54 +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 14:51:22 +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 14:51:22 +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 14:51:22 +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 %}
2018-04-09 15:15:58 +00:00
</div>
</div>