mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-16 10:34:07 +02:00
File chooser size (#30040)
Co-authored-by: David Van Doninck <david.vandoninck@intracto.com> Co-authored-by: XhmikosR <xhmikosr@gmail.com> Co-authored-by: Martijn Cuppens <martijn.cuppens@gmail.com>
This commit is contained in:
@@ -747,6 +747,16 @@ $form-file-box-shadow: $input-box-shadow !default;
|
|||||||
$form-file-button-color: $form-file-color !default;
|
$form-file-button-color: $form-file-color !default;
|
||||||
$form-file-button-bg: $input-group-addon-bg !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
|
// Form validation
|
||||||
|
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: $form-file-height;
|
height: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
left: 0;
|
left: 0;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
height: $form-file-height;
|
height: 100%;
|
||||||
border-color: $form-file-border-color;
|
border-color: $form-file-border-color;
|
||||||
@include border-radius($form-file-border-radius);
|
@include border-radius($form-file-border-radius);
|
||||||
@include box-shadow($form-file-box-shadow);
|
@include box-shadow($form-file-box-shadow);
|
||||||
@@ -69,3 +69,23 @@
|
|||||||
border-width: $form-file-border-width;
|
border-width: $form-file-border-width;
|
||||||
@include border-right-radius(inherit);
|
@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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -3,13 +3,15 @@ layout: docs
|
|||||||
title: File browser
|
title: File browser
|
||||||
description: Use our custom file inputs for consistent cross-browser styling, built-in customization, and lightweight JavaScript.
|
description: Use our custom file inputs for consistent cross-browser styling, built-in customization, and lightweight JavaScript.
|
||||||
group: forms
|
group: forms
|
||||||
toc: false
|
toc: true
|
||||||
---
|
---
|
||||||
|
|
||||||
{{< callout info >}}
|
{{< 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 >}}
|
{{< /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.
|
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 >}}
|
||||||
@@ -47,3 +49,25 @@ Longer placeholder text is truncated and an ellipsis is added when there's not e
|
|||||||
{{< /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.
|
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 >}}
|
||||||
|
Reference in New Issue
Block a user