text-decoration: none;
}
+a strong {
+ color: currentColor;
+}
+
a:hover {
color: #363636;
}
}
.file {
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
align-items: stretch;
display: flex;
justify-content: flex-start;
font-size: 28px;
}
-.file.has-path .file-cta {
+.file.has-name .file-cta {
border-bottom-right-radius: 0;
border-top-right-radius: 0;
}
-.file.has-path .file-path {
+.file.has-name .file-name {
border-bottom-left-radius: 0;
border-top-left-radius: 0;
}
padding: 1em 3em;
}
-.file.is-centered .file-path {
+.file.is-centered .file-name {
border-width: 0 1px 1px;
}
font-size: 35px;
}
-.file.is-centered.has-path .file-cta {
+.file.is-centered.has-name .file-cta {
border-radius: 3px 3px 0 0;
}
-.file.is-centered.has-path .file-path {
+.file.is-centered.has-name .file-name {
border-radius: 0 0 3px 3px;
border-width: 0 1px 1px;
}
}
.file-label:hover .file-cta {
- background-color: #ff2b56;
+ background-color: #eeeeee;
color: #363636;
}
-.file-label:hover .file-path {
- border-color: #ff2b56;
+.file-label:hover .file-name {
+ border-color: #eeeeee;
}
.file-label:active .file-cta {
- background-color: #ff1f4b;
+ background-color: #e8e8e8;
color: #363636;
}
-.file-label:active .file-path {
- border-color: #ff1f4b;
+.file-label:active .file-name {
+ border-color: #e8e8e8;
}
.file-input {
}
.file-cta,
-.file-path {
+.file-name {
-moz-appearance: none;
-webkit-appearance: none;
align-items: center;
}
.file-cta:focus, .file-cta.is-focused, .file-cta:active, .file-cta.is-active,
-.file-path:focus,
-.file-path.is-focused,
-.file-path:active,
-.file-path.is-active {
+.file-name:focus,
+.file-name.is-focused,
+.file-name:active,
+.file-name.is-active {
outline: none;
}
.file-cta[disabled],
-.file-path[disabled] {
+.file-name[disabled] {
cursor: not-allowed;
}
.file-cta {
- background-color: #ff3860;
+ background-color: whitesmoke;
color: #4a4a4a;
}
-.file-path {
- border-color: #ff3860;
+.file-name {
+ border-color: whitesmoke;
border-style: solid;
border-width: 1px 1px 1px 0;
display: block;
title: File upload
layout: documentation
doc-tab: form
-doc-subtab: upload
+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>
{% endcapture %}
-{% capture file_path %}
-<div class="file has-path">
+{% capture file_name %}
+<div class="file has-name">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
Choose a file…
</span>
</span>
- <span class="file-path">
+ <span class="file-name">
{{ page.file_name }}
</span>
</label>
</div>
{% endcapture %}
-{% capture file_centered_path %}
-<div class="file is-centered has-path">
+{% 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">
Choose a file…
</span>
</span>
- <span class="file-path">
+ <span class="file-name">
{{ page.file_name }}
</span>
</label>
</div>
{% endcapture %}
-{% capture file_sizes_path %}
+{% capture file_sizes_name %}
<div class="field">
- <div class="file is-small has-path">
+ <div class="file is-small has-name">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
Small file…
</span>
</span>
- <span class="file-path">
+ <span class="file-name">
{{ page.file_name }}
</span>
</label>
</div>
<div class="field">
- <div class="file has-path">
+ <div class="file has-name">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
Normal file…
</span>
</span>
- <span class="file-path">
+ <span class="file-name">
{{ page.file_name }}
</span>
</label>
</div>
<div class="field">
- <div class="file is-medium has-path">
+ <div class="file is-medium has-name">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
Medium file…
</span>
</span>
- <span class="file-path">
+ <span class="file-name">
{{ page.file_name }}
</span>
</label>
</div>
<div class="field">
- <div class="file is-large has-path">
+ <div class="file is-large has-name">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
Large file…
</span>
</span>
- <span class="file-path">
+ <span class="file-name">
{{ page.file_name }}
</span>
</label>
</div>
{% endcapture %}
-{% capture file_sizes_centered_path %}
+{% capture file_sizes_centered_name %}
<div class="field">
- <div class="file is-small is-centered has-path">
+ <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">
Small file…
</span>
</span>
- <span class="file-path">
+ <span class="file-name">
{{ page.file_name }}
</span>
</label>
</div>
<div class="field">
- <div class="file is-centered has-path">
+ <div class="file is-centered has-name">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
Normal file…
</span>
</span>
- <span class="file-path">
+ <span class="file-name">
{{ page.file_name }}
</span>
</label>
</div>
<div class="field">
- <div class="file is-medium is-centered has-path">
+ <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">
Medium file…
</span>
</span>
- <span class="file-path">
+ <span class="file-name">
{{ page.file_name }}
</span>
</label>
</div>
<div class="field">
- <div class="file is-large is-centered has-path">
+ <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">
Large file…
</span>
</span>
- <span class="file-path">
+ <span class="file-name">
{{ page.file_name }}
</span>
</label>
<div class="content">
<p>
- The <code>.file</code> class is a simple wrapper around the <code><input type="radio"></code> HTML elements. It is intentionally not styled, to preserve cross-browser compatibility and the user experience.
- </p>
- <p>
- Make sure the linked radio buttons have the <strong>same value</strong> for their <code>name</code> HTML attribute.
+ 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="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_path }}
+ {{ file_name }}
</div>
</div>
<div class="column highlight-full">
- {% highlight html %}{{ file_path }}{% endhighlight %}
+ {% 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 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_path }}
+ {{ file_centered_name }}
</div>
</div>
<div class="column highlight-full">
- {% highlight html %}{{ file_centered_path }}{% endhighlight %}
+ {% 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">
<div class="columns">
<div class="column">
<div class="example">
- {{ file_sizes_path }}
+ {{ file_sizes_name }}
</div>
</div>
<div class="column">
- {% highlight html %}{{ file_sizes_path }}{% endhighlight %}
+ {% highlight html %}{{ file_sizes_name }}{% endhighlight %}
</div>
</div>
<div class="columns">
<div class="column">
<div class="example">
- {{ file_sizes_centered_path }}
+ {{ file_sizes_centered_name }}
</div>
</div>
<div class="column">
- {% highlight html %}{{ file_sizes_centered_path }}{% endhighlight %}
+ {% 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>
$input-radius: $radius !default
+$file-border-color: transparent !default
+$file-radius: $radius !default
+
+$file-cta-background-color: $white-ter !default
+$file-cta-color: $grey-dark !default
+$file-cta-hover-color: $grey-darker !default
+$file-cta-active-color: $grey-darker !default
+
+$file-name-border-color: $file-cta-background-color !default
+$file-name-border-style: solid !default
+$file-name-border-width: 1px 1px 1px 0 !default
+$file-name-max-width: 16em !default
+
$label-color: $grey-darker !default
$label-weight: $weight-bold !default
&.is-large:after
font-size: $size-large
-$file-border-color: transparent !default
-$file-radius: $radius !default
-
-// $file-cta-background-color: $white-ter !default
-$file-cta-background-color: $red !default
-$file-cta-color: $grey-dark !default
-$file-cta-hover-color: $grey-darker !default
-$file-cta-active-color: $grey-darker !default
-
-$file-path-border-color: $file-cta-background-color !default
-$file-path-border-style: solid !default
-$file-path-border-width: 1px 1px 1px 0 !default
-$file-path-max-width: 16em !default
-
.file
+ +unselectable
align-items: stretch
display: flex
justify-content: flex-start
.file-icon
.fa
font-size: 28px
- &.has-path
+ &.has-name
.file-cta
border-bottom-right-radius: 0
border-top-right-radius: 0
- .file-path
+ .file-name
border-bottom-left-radius: 0
border-top-left-radius: 0
&.is-centered
flex-direction: column
height: auto
padding: 1em 3em
- .file-path
+ .file-name
border-width: 0 1px 1px
.file-icon
height: 1.5em
&.is-large
.file-icon .fa
font-size: 35px
- &.has-path
+ &.has-name
.file-cta
border-radius: $file-radius $file-radius 0 0
- .file-path
+ .file-name
border-radius: 0 0 $file-radius $file-radius
border-width: 0 1px 1px
.file-cta
background-color: darken($file-cta-background-color, 2.5%)
color: $file-cta-hover-color
- .file-path
- border-color: darken($file-path-border-color, 2.5%)
+ .file-name
+ border-color: darken($file-name-border-color, 2.5%)
&:active
.file-cta
background-color: darken($file-cta-background-color, 5%)
color: $file-cta-active-color
- .file-path
- border-color: darken($file-path-border-color, 5%)
+ .file-name
+ border-color: darken($file-name-border-color, 5%)
.file-input
height: 0.01em
width: 0.01em
.file-cta,
-.file-path
+.file-name
+control
border-color: $file-border-color
border-radius: $file-radius
background-color: $file-cta-background-color
color: $file-cta-color
-.file-path
- border-color: $file-path-border-color
- border-style: $file-path-border-style
- border-width: $file-path-border-width
+.file-name
+ border-color: $file-name-border-color
+ border-style: $file-name-border-style
+ border-width: $file-name-border-width
display: block
- max-width: $file-path-max-width
+ max-width: $file-name-max-width
overflow: hidden
text-align: left
text-overflow: ellipsis