$form-file-button-color: $form-file-color !default;
$form-file-button-bg: $input-group-addon-bg !default;
+$form-file-padding-y-sm: $input-padding-y-sm !default;
+$form-file-padding-x-sm: $input-padding-x-sm !default;
+$form-file-font-size-sm: $input-font-size-sm !default;
+$form-file-height-sm: $input-height-sm !default;
+
+$form-file-padding-y-lg: $input-padding-y-lg !default;
+$form-file-padding-x-lg: $input-padding-x-lg !default;
+$form-file-font-size-lg: $input-font-size-lg !default;
+$form-file-height-lg: $input-height-lg !default;
+
// Form validation
position: relative;
z-index: 2;
width: 100%;
- height: $form-file-height;
+ height: 100%;
margin: 0;
opacity: 0;
left: 0;
z-index: 1;
display: flex;
- height: $form-file-height;
+ height: 100%;
border-color: $form-file-border-color;
@include border-radius($form-file-border-radius);
@include box-shadow($form-file-box-shadow);
border-width: $form-file-border-width;
@include border-right-radius(inherit);
}
+
+.form-file-sm {
+ height: $form-file-height-sm;
+ @include font-size($form-file-font-size-sm);
+
+ .form-file-text,
+ .form-file-button {
+ padding: $form-file-padding-y-sm $form-file-padding-x-sm;
+ }
+}
+
+.form-file-lg {
+ height: $form-file-height-lg;
+ @include font-size($form-file-font-size-lg);
+
+ .form-file-text,
+ .form-file-button {
+ padding: $form-file-padding-y-lg $form-file-padding-x-lg;
+ }
+}
title: File browser
description: Use our custom file inputs for consistent cross-browser styling, built-in customization, and lightweight JavaScript.
group: forms
-toc: false
+toc: true
---
{{< callout info >}}
-The recommended plugin to animate custom file input: [bs-custom-file-input](https://www.npmjs.com/package/bs-custom-file-input), that's what we are using currently here in our docs.
+The recommended plugin to animate custom file inputs is [bs-custom-file-input](https://www.npmjs.com/package/bs-custom-file-input); it's what we use here in our docs.
{{< /callout >}}
+## Default
+
The file input is the most gnarly of the bunch and requires additional JavaScript if you'd like to hook them up with functional *Choose file...* and selected file name text.
{{< example >}}
{{< /example >}}
We hide the default file `<input>` via `opacity` and instead style the `<label>`, and declare a `width` and `height` on the `<input>` for proper spacing for surrounding content.
+
+## Sizing
+
+You may also choose from small and large file inputs to match our similarly sized text inputs.
+
+{{< example >}}
+<div class="form-file form-file-lg mb-3">
+ <input type="file" class="form-file-input" id="customFileLg">
+ <label class="form-file-label" for="customFileLg">
+ <span class="form-file-text">Choose file...</span>
+ <span class="form-file-button">Browse</span>
+ </label>
+</div>
+
+<div class="form-file form-file-sm">
+ <input type="file" class="form-file-input" id="customFileSm">
+ <label class="form-file-label" for="customFileSm">
+ <span class="form-file-text">Choose file...</span>
+ <span class="form-file-button">Browse</span>
+ </label>
+</div>
+{{< /example >}}