mirror of
https://github.com/jgthms/bulma.git
synced 2024-11-14 11:14:24 +00:00
580 lines
14 KiB
HTML
580 lines
14 KiB
HTML
---
|
|
title: File upload
|
|
layout: documentation
|
|
doc-tab: form
|
|
doc-subtab: file
|
|
file_name: "Screen Shot 2017-07-29 at 15.54.25.png"
|
|
variables:
|
|
- name: $file-border-color
|
|
value: transparent
|
|
- name: $file-radius
|
|
value: $radius
|
|
- name: $file-cta-background-color
|
|
value: $white-ter
|
|
- name: $file-cta-color
|
|
value: $grey-dark
|
|
- name: $file-cta-hover-color
|
|
value: $grey-darker
|
|
- name: $file-cta-active-color
|
|
value: $grey-darker
|
|
- name: $file-name-border-color
|
|
value: $file-cta-background-color
|
|
- name: $file-name-border-style
|
|
value: solid
|
|
- name: $file-name-border-width
|
|
value: 1px 1px 1px 0
|
|
- name: $file-name-max-width
|
|
value: 16em
|
|
---
|
|
|
|
{% capture file %}
|
|
<div class="file">
|
|
<label class="file-label">
|
|
<input class="file-input" type="file" name="resume">
|
|
<span class="file-cta">
|
|
<span class="file-icon">
|
|
<i class="fa fa-upload"></i>
|
|
</span>
|
|
<span class="file-label">
|
|
Choose a file…
|
|
</span>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
{% endcapture %}
|
|
|
|
{% capture file_name %}
|
|
<div class="file has-name">
|
|
<label class="file-label">
|
|
<input class="file-input" type="file" name="resume">
|
|
<span class="file-cta">
|
|
<span class="file-icon">
|
|
<i class="fa fa-upload"></i>
|
|
</span>
|
|
<span class="file-label">
|
|
Choose a file…
|
|
</span>
|
|
</span>
|
|
<span class="file-name">
|
|
{{ page.file_name }}
|
|
</span>
|
|
</label>
|
|
</div>
|
|
{% endcapture %}
|
|
|
|
{% capture file_centered %}
|
|
<div class="file is-centered">
|
|
<label class="file-label">
|
|
<input class="file-input" type="file" name="resume">
|
|
<span class="file-cta">
|
|
<span class="file-icon">
|
|
<i class="fa fa-upload"></i>
|
|
</span>
|
|
<span class="file-label">
|
|
Choose a file…
|
|
</span>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
{% endcapture %}
|
|
|
|
{% capture file_centered_name %}
|
|
<div class="file has-name is-centered">
|
|
<label class="file-label">
|
|
<input class="file-input" type="file" name="resume">
|
|
<span class="file-cta">
|
|
<span class="file-icon">
|
|
<i class="fa fa-upload"></i>
|
|
</span>
|
|
<span class="file-label">
|
|
Choose a file…
|
|
</span>
|
|
</span>
|
|
<span class="file-name">
|
|
{{ page.file_name }}
|
|
</span>
|
|
</label>
|
|
</div>
|
|
{% endcapture %}
|
|
|
|
{% capture file_sizes %}
|
|
<div class="field">
|
|
<div class="file is-small">
|
|
<label class="file-label">
|
|
<input class="file-input" type="file" name="resume">
|
|
<span class="file-cta">
|
|
<span class="file-icon">
|
|
<i class="fa fa-upload"></i>
|
|
</span>
|
|
<span class="file-label">
|
|
Small file…
|
|
</span>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<div class="file">
|
|
<label class="file-label">
|
|
<input class="file-input" type="file" name="resume">
|
|
<span class="file-cta">
|
|
<span class="file-icon">
|
|
<i class="fa fa-upload"></i>
|
|
</span>
|
|
<span class="file-label">
|
|
Normal file…
|
|
</span>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<div class="file is-medium">
|
|
<label class="file-label">
|
|
<input class="file-input" type="file" name="resume">
|
|
<span class="file-cta">
|
|
<span class="file-icon">
|
|
<i class="fa fa-upload"></i>
|
|
</span>
|
|
<span class="file-label">
|
|
Medium file…
|
|
</span>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<div class="file is-large">
|
|
<label class="file-label">
|
|
<input class="file-input" type="file" name="resume">
|
|
<span class="file-cta">
|
|
<span class="file-icon">
|
|
<i class="fa fa-upload"></i>
|
|
</span>
|
|
<span class="file-label">
|
|
Large file…
|
|
</span>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
{% endcapture %}
|
|
|
|
{% capture file_sizes_name %}
|
|
<div class="field">
|
|
<div class="file is-small has-name">
|
|
<label class="file-label">
|
|
<input class="file-input" type="file" name="resume">
|
|
<span class="file-cta">
|
|
<span class="file-icon">
|
|
<i class="fa fa-upload"></i>
|
|
</span>
|
|
<span class="file-label">
|
|
Small file…
|
|
</span>
|
|
</span>
|
|
<span class="file-name">
|
|
{{ page.file_name }}
|
|
</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<div class="file has-name">
|
|
<label class="file-label">
|
|
<input class="file-input" type="file" name="resume">
|
|
<span class="file-cta">
|
|
<span class="file-icon">
|
|
<i class="fa fa-upload"></i>
|
|
</span>
|
|
<span class="file-label">
|
|
Normal file…
|
|
</span>
|
|
</span>
|
|
<span class="file-name">
|
|
{{ page.file_name }}
|
|
</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<div class="file is-medium has-name">
|
|
<label class="file-label">
|
|
<input class="file-input" type="file" name="resume">
|
|
<span class="file-cta">
|
|
<span class="file-icon">
|
|
<i class="fa fa-upload"></i>
|
|
</span>
|
|
<span class="file-label">
|
|
Medium file…
|
|
</span>
|
|
</span>
|
|
<span class="file-name">
|
|
{{ page.file_name }}
|
|
</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<div class="file is-large has-name">
|
|
<label class="file-label">
|
|
<input class="file-input" type="file" name="resume">
|
|
<span class="file-cta">
|
|
<span class="file-icon">
|
|
<i class="fa fa-upload"></i>
|
|
</span>
|
|
<span class="file-label">
|
|
Large file…
|
|
</span>
|
|
</span>
|
|
<span class="file-name">
|
|
{{ page.file_name }}
|
|
</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
{% endcapture %}
|
|
|
|
{% capture file_sizes_centered %}
|
|
<div class="field">
|
|
<div class="file is-small is-centered">
|
|
<label class="file-label">
|
|
<input class="file-input" type="file" name="resume">
|
|
<span class="file-cta">
|
|
<span class="file-icon">
|
|
<i class="fa fa-upload"></i>
|
|
</span>
|
|
<span class="file-label">
|
|
Small file…
|
|
</span>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<div class="file is-centered">
|
|
<label class="file-label">
|
|
<input class="file-input" type="file" name="resume">
|
|
<span class="file-cta">
|
|
<span class="file-icon">
|
|
<i class="fa fa-upload"></i>
|
|
</span>
|
|
<span class="file-label">
|
|
Normal file…
|
|
</span>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<div class="file is-medium is-centered">
|
|
<label class="file-label">
|
|
<input class="file-input" type="file" name="resume">
|
|
<span class="file-cta">
|
|
<span class="file-icon">
|
|
<i class="fa fa-upload"></i>
|
|
</span>
|
|
<span class="file-label">
|
|
Medium file…
|
|
</span>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<div class="file is-large is-centered">
|
|
<label class="file-label">
|
|
<input class="file-input" type="file" name="resume">
|
|
<span class="file-cta">
|
|
<span class="file-icon">
|
|
<i class="fa fa-upload"></i>
|
|
</span>
|
|
<span class="file-label">
|
|
Large file…
|
|
</span>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
{% endcapture %}
|
|
|
|
{% capture file_sizes_centered_name %}
|
|
<div class="field">
|
|
<div class="file is-small is-centered has-name">
|
|
<label class="file-label">
|
|
<input class="file-input" type="file" name="resume">
|
|
<span class="file-cta">
|
|
<span class="file-icon">
|
|
<i class="fa fa-upload"></i>
|
|
</span>
|
|
<span class="file-label">
|
|
Small file…
|
|
</span>
|
|
</span>
|
|
<span class="file-name">
|
|
{{ page.file_name }}
|
|
</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<div class="file is-centered has-name">
|
|
<label class="file-label">
|
|
<input class="file-input" type="file" name="resume">
|
|
<span class="file-cta">
|
|
<span class="file-icon">
|
|
<i class="fa fa-upload"></i>
|
|
</span>
|
|
<span class="file-label">
|
|
Normal file…
|
|
</span>
|
|
</span>
|
|
<span class="file-name">
|
|
{{ page.file_name }}
|
|
</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<div class="file is-medium is-centered has-name">
|
|
<label class="file-label">
|
|
<input class="file-input" type="file" name="resume">
|
|
<span class="file-cta">
|
|
<span class="file-icon">
|
|
<i class="fa fa-upload"></i>
|
|
</span>
|
|
<span class="file-label">
|
|
Medium file…
|
|
</span>
|
|
</span>
|
|
<span class="file-name">
|
|
{{ page.file_name }}
|
|
</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<div class="file is-large is-centered has-name">
|
|
<label class="file-label">
|
|
<input class="file-input" type="file" name="resume">
|
|
<span class="file-cta">
|
|
<span class="file-icon">
|
|
<i class="fa fa-upload"></i>
|
|
</span>
|
|
<span class="file-label">
|
|
Large file…
|
|
</span>
|
|
</span>
|
|
<span class="file-name">
|
|
{{ page.file_name }}
|
|
</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
{% endcapture %}
|
|
|
|
{% include subnav-form.html %}
|
|
|
|
<section class="section">
|
|
<div class="container">
|
|
<h1 class="title">File upload</h1>
|
|
<h2 class="subtitle">
|
|
A custom <strong>file upload</strong> input, without JavaScript
|
|
</h2>
|
|
{%
|
|
include meta.html
|
|
experimental=true
|
|
since="0.5.1"
|
|
colors=false
|
|
sizes=true
|
|
variables=true
|
|
%}
|
|
|
|
<hr>
|
|
|
|
<div class="content">
|
|
<p>
|
|
The <code>.file</code> element is a simple <strong>interactive label</strong> that wraps an <code><input type="file"></code>. It comprises several sub-elements:
|
|
</p>
|
|
<ul>
|
|
<li>
|
|
<code>.file</code> the main <strong>container</strong>
|
|
<ul>
|
|
<li>
|
|
<code>.file-label</code> the actual <strong>interactive</strong> and clickable part of the element
|
|
<ul>
|
|
<li>
|
|
<code>.file-input</code> the <strong>native</strong> file input, hidden for styling purposes
|
|
</li>
|
|
<li>
|
|
<code>.file-cta</code> the upload <strong>call-to-action</strong>
|
|
<ul>
|
|
<li>
|
|
<code>.file-icon</code> an optional <strong>upload</strong> icon
|
|
</li>
|
|
<li>
|
|
<code>.file-label</code> the "Choose a file…" text
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<code>.file-name</code> a container for the <strong>chosen file</strong> name
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="columns">
|
|
<div class="column">
|
|
<div class="example">
|
|
{{ file }}
|
|
</div>
|
|
</div>
|
|
<div class="column highlight-full">
|
|
{% highlight html %}{{ file }}{% endhighlight %}
|
|
</div>
|
|
</div>
|
|
|
|
{% include heading.html name="Modifiers" %}
|
|
|
|
<div class="columns">
|
|
<div class="column">
|
|
<div class="content">
|
|
<p>
|
|
With the <code>.has-name</code> modifier combined with the <code>.file-name</code> element, you can add a <strong>placeholder</strong> for the selected file name.
|
|
</p>
|
|
</div>
|
|
<div class="example">
|
|
{{ file_name }}
|
|
</div>
|
|
</div>
|
|
<div class="column highlight-full">
|
|
{% highlight html %}{{ file_name }}{% endhighlight %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="columns">
|
|
<div class="column">
|
|
<div class="content">
|
|
<p>
|
|
You can have a <strong>centered block</strong> with the <code>.is-centered</code> modifier.
|
|
</p>
|
|
</div>
|
|
<div class="example">
|
|
{{ file_centered }}
|
|
</div>
|
|
</div>
|
|
<div class="column highlight-full">
|
|
{% highlight html %}{{ file_centered }}{% endhighlight %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="columns">
|
|
<div class="column">
|
|
<div class="content">
|
|
<p>
|
|
You can <strong>combine</strong> <code>.has-name</code> and <code>.is-centered</code>.
|
|
</p>
|
|
</div>
|
|
<div class="example">
|
|
{{ file_centered_name }}
|
|
</div>
|
|
</div>
|
|
<div class="column highlight-full">
|
|
{% highlight html %}{{ file_centered_name }}{% endhighlight %}
|
|
</div>
|
|
</div>
|
|
|
|
{% include heading.html name="Sizes" %}
|
|
|
|
<div class="content">
|
|
<p>
|
|
You can append one of <strong>3 additional sizes</strong>:
|
|
</p>
|
|
<ul>
|
|
<li>
|
|
<code>.is-small</code>
|
|
</li>
|
|
<li>
|
|
<code>.is-medium</code>
|
|
</li>
|
|
<li>
|
|
<code>.is-large</code>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="columns">
|
|
<div class="column">
|
|
<div class="example">
|
|
{{ file_sizes }}
|
|
</div>
|
|
</div>
|
|
<div class="column">
|
|
{% highlight html %}{{ file_sizes }}{% endhighlight %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="columns">
|
|
<div class="column">
|
|
<div class="example">
|
|
{{ file_sizes_name }}
|
|
</div>
|
|
</div>
|
|
<div class="column">
|
|
{% highlight html %}{{ file_sizes_name }}{% endhighlight %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="columns">
|
|
<div class="column">
|
|
<div class="example">
|
|
{{ file_sizes_centered }}
|
|
</div>
|
|
</div>
|
|
<div class="column">
|
|
{% highlight html %}{{ file_sizes_centered }}{% endhighlight %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="columns">
|
|
<div class="column">
|
|
<div class="example">
|
|
{{ file_sizes_centered_name }}
|
|
</div>
|
|
</div>
|
|
<div class="column">
|
|
{% highlight html %}{{ file_sizes_centered_name }}{% endhighlight %}
|
|
</div>
|
|
</div>
|
|
|
|
{% include heading.html name="JavaScript" %}
|
|
|
|
<div class="content">
|
|
<p>
|
|
A file upload input requires JavaScript to <strong>retrieve</strong> the <strong>selected file name</strong>.
|
|
<br>
|
|
User <a href="https://github.com/chintanbanugaria"><strong>@chintanbanugaria</strong></a> on GitHub <a href="https://github.com/jgthms/bulma/issues/280#issuecomment-294099510">has provided</a> a simple solution <a href="https://jsfiddle.net/chintanbanugaria/uzva5byy/">on JSFiddle</a>.
|
|
</p>
|
|
</div>
|
|
|
|
{% include variables.html element=true %}
|
|
|
|
</div>
|
|
</section>
|