From 4308b67e59bfb47d386c3cc585e4a0fb759f6de6 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Tue, 8 Feb 2022 12:33:39 -0800 Subject: [PATCH] Add `.form-check-reverse` modifier class (#33606) * Add .form-check-reverse modifier class * Update checks-radios.md Co-authored-by: XhmikosR --- scss/forms/_form-check.scss | 22 ++++++++++++++++++ site/content/docs/5.1/forms/checks-radios.md | 24 ++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/scss/forms/_form-check.scss b/scss/forms/_form-check.scss index a52a2e7c81..8e7cbed43c 100644 --- a/scss/forms/_form-check.scss +++ b/scss/forms/_form-check.scss @@ -14,6 +14,18 @@ } } +.form-check-reverse { + padding-right: $form-check-padding-start; + padding-left: 0; + text-align: right; + + .form-check-input { + float: right; + margin-right: $form-check-padding-start * -1; + margin-left: 0; + } +} + .form-check-input { width: $form-check-input-width; height: $form-check-input-width; @@ -130,6 +142,16 @@ } } } + + &.form-check-reverse { + padding-right: $form-switch-padding-start; + padding-left: 0; + + .form-check-input { + margin-right: $form-switch-padding-start * -1; + margin-left: 0; + } + } } .form-check-inline { diff --git a/site/content/docs/5.1/forms/checks-radios.md b/site/content/docs/5.1/forms/checks-radios.md index efd040de03..2ca72543ca 100644 --- a/site/content/docs/5.1/forms/checks-radios.md +++ b/site/content/docs/5.1/forms/checks-radios.md @@ -197,6 +197,30 @@ Group checkboxes or radios on the same horizontal row by adding `.form-check-inl {{< /example >}} +## Reverse + +Put your checkboxes, radios, and switches on the opposite side with the `.form-check-reverse` modifier class. + +{{< example >}} +
+ + +
+
+ + +
+ +
+ + +
+{{< /example >}} + ## Without labels Omit the wrapping `.form-check` for checkboxes and radios that have no label text. Remember to still provide some form of accessible name for assistive technologies (for instance, using `aria-label`). See the [forms overview accessibility]({{< docsref "/forms/overview#accessibility" >}}) section for details.