Update form validation styles to use new CSS variables for color and border-color#38044
Merged
Update form validation styles to use new CSS variables for color and border-color#38044
color and border-color#38044Conversation
Member
julien-deramond
left a comment
There was a problem hiding this comment.
Suggestion for the documentation:
diff --git a/scss/_root.scss b/scss/_root.scss
index d2216cdcf..1fc660b8d 100644
--- a/scss/_root.scss
+++ b/scss/_root.scss
@@ -124,10 +124,12 @@
--#{$prefix}focus-ring-box-shadow: var(--#{$prefix}focus-ring-x, 0) var(--#{$prefix}focus-ring-y, 0) var(--#{$prefix}focus-ring-blur, 0) var(--#{$prefix}focus-ring-width) var(--#{$prefix}focus-ring-color);
// scss-docs-end root-focus-variables
+ // scss-docs-start root-form-validation-variables
--#{$prefix}form-valid-color: #{$green-500};
--#{$prefix}form-valid-border-color: #{$green-500};
--#{$prefix}form-invalid-color: #{$red-500};
--#{$prefix}form-invalid-border-color: #{$red-500};
+ // scss-docs-end root-form-validation-variables
}
@if $enable-dark-mode {
diff --git a/site/content/docs/5.3/forms/validation.md b/site/content/docs/5.3/forms/validation.md
index cf2a87e80..03dd9de5e 100644
--- a/site/content/docs/5.3/forms/validation.md
+++ b/site/content/docs/5.3/forms/validation.md
@@ -351,6 +351,14 @@ If your form layout allows it, you can swap the `.{valid|invalid}-feedback` clas
## CSS
+### Variables
+
+{{< added-in "5.3.0" >}}
+
+As part of Bootstrap's evolving CSS variables approach, forms now use local CSS variables for validation for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
+
+{{< scss-docs name="root-form-validation-variables" file="scss/_root.scss" >}}
+
### Sass variables
{{< scss-docs name="form-feedback-variables" file="scss/_variables.scss" >}}7eb2dec to
b71ef7f
Compare
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked to #38041.
This is an alternate fix that includes some new CSS variables dedicated to form validation
validandinvalidcolors. This approach should suffice for a number of customization options while also solving our color contrast and color mode issues.What this doesn't, and can't, resolve is the icon color since we're embedding SVGs. I don't think the path of duplicating the SVG as embedded in our CSS is a good option either since that adds a good chunk of file size.