0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-11-30 12:24:19 +01:00
Bootstrap/site/content/docs/4.3/forms/file.md
Mark Otto cef69b9a65 v5: Fix disabled styling on .form-file (#29022)
While #28450 overhauled a ton of forms work, the  support for this custom file input was ineffective. This updates the selector to target the custom field and gray out the entire field.

Fixes #28176.
2019-07-14 12:00:57 +03:00

2.1 KiB

layout title description group toc
docs File browser Use our custom file inputs for consistent cross-browser styling, built-in customization, and lightweight JavaScript. forms false

{{< callout info >}} The recommended plugin to animate custom file input: bs-custom-file-input, that's what we are using currently here in our docs. {{< /callout >}}

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 >}}

Add the disabled attribute to the <input> and the custom markup will be updated to appear disabled.

{{< example >}}

{{< /example >}}

Longer placeholder text is truncated and an ellipsis is added when there's not enough space.

{{< example >}}

{{< /example >}}

We hide the default file <input> via opacity and instead style the <label>. The button is generated and positioned with ::after. Lastly, we declare a width and height on the <input> for proper spacing for surrounding content.