From 32930bc06e2a75f05c41948a7e7dff84cc9c9b62 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Thu, 6 May 2021 15:51:23 -0700 Subject: [PATCH] Add support for Bootstrap Icons on floating label forms --- scss/forms/_floating-labels.scss | 20 ++++++++++++ .../content/docs/5.0/forms/floating-labels.md | 31 +++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/scss/forms/_floating-labels.scss b/scss/forms/_floating-labels.scss index 8b2e2b8eb6..9154373314 100644 --- a/scss/forms/_floating-labels.scss +++ b/scss/forms/_floating-labels.scss @@ -59,3 +59,23 @@ } // stylelint-enable no-duplicate-selectors } + +.form-floating-icon { + position: absolute; + top: 0; + bottom: 0; + left: 0; + display: flex; + align-items: center; + justify-content: center; + width: 2.5rem + $form-floating-padding-x; + + ~ label { + left: 2.5rem; + } + + ~ .form-control, + ~ .form-select { + padding-left: 2.5rem + $form-floating-padding-x; + } +} diff --git a/site/content/docs/5.0/forms/floating-labels.md b/site/content/docs/5.0/forms/floating-labels.md index 9410550898..bc1b58bcb4 100644 --- a/site/content/docs/5.0/forms/floating-labels.md +++ b/site/content/docs/5.0/forms/floating-labels.md @@ -75,6 +75,37 @@ Other than `.form-control`, floating labels are only available on `.form-select` {{< /example >}} +## With icons + +Add [Bootstrap Icons]({{< param icons >}}) or other SVGs to floating label forms. Depending on your icons and content, you may want to add more utilities or custom styles. + +{{< example >}} + + + + + + + + + + +
+
+ +
+ + +
+
+
+ +
+ + +
+{{< /example >}} + ## Layout When working with the Bootstrap grid system, be sure to place form elements within column classes.