Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set floating-labels default color equal to the input placeholder color #39172

Closed
wants to merge 2 commits into from

Conversation

pine3ree
Copy link
Contributor

@pine3ree pine3ree commented Sep 12, 2023

Motivation & Context

Floating labels (after not focused inputs and not plaintext form-control) are used as input placeholders, so they should have the same styling (read $input-placeholder-color) of actual input-placeholders.

(edit)
Added (and used) new var:

$form-floating-label-color:             $input-placeholder-color !default;

to allow easier extra customization

@pine3ree pine3ree requested a review from a team as a code owner September 12, 2023 13:52
…lor)

to allow extra customization

Signed-off-by: pine3ree <[email protected]>
Copy link
Member

@julien-deramond julien-deramond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR @pine3ree

I'm not so sure about the change of color given the fact that is first a label, so should be black. But it's also temporary a kind of placeholder too when not focused. Maybe what's strange, is not having the same color when focused and not focused.
I'll let @mdo check that from a design point of view.

However, I'd say that having a $form-floating-label-color (whatever the color chosen in the end) could be useful to override the default label color (when not focused).

@@ -1075,6 +1075,7 @@ $form-floating-input-padding-b: .625rem !default;
$form-floating-label-height: 1.5em !default;
$form-floating-label-opacity: .65 !default;
$form-floating-label-transform: scale(.85) translateY(-.5rem) translateX(.15rem) !default;
$form-floating-label-color: $input-placeholder-color !default; // When the label is acting as a placeholder
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment can be removed. The naming of the Sass var is sufficient to understand what it does IMO.

Suggested change
$form-floating-label-color: $input-placeholder-color !default; // When the label is acting as a placeholder
$form-floating-label-color: $input-placeholder-color !default;

@julien-deramond julien-deramond requested a review from mdo September 12, 2023 16:34
@pine3ree
Copy link
Contributor Author

Hello @julien-deramond ,

form what I've learned (but I could have missed something) labels (after .form-control) inside a .floating-label are displayed as labels when (

> .form-control:focus,
)

  • the .form-control has focus (.form-control:focus)
  • the control is a .form-select
  • there is no placeholder attribute (.form-control:not(:placeholder-shown))
  • the control is a .form-control-plaintext (btw, I use this for divs when displaying application entity properties)

In all the cases listed above the label is actually positioned as an inside-input label and assigned a different color and size (more appropriate for the label role), while the default behavior (

) is to take the place of the input placeholder.

Granted, at the same time it also acts as a label, so it has to be easy to read (like a placeholder). What is kind of confusing is that the .form-floating inputs look much like already filled inputs rather than inputs with placeholders.

Thanks and kind regards!

@theodorejb
Copy link

I believe this can be closed since #39720 was merged.

@pine3ree
Copy link
Contributor Author

pine3ree commented Oct 8, 2024

I believe this can be closed since #39720 was merged.

Hello @theodorejb,
the pr #39720 set the background color, while my suggestion was to make floating-labels (when acting as input placeholders) and input-placeholders have the same color (the input-placeholder assigned color)
kind regards

@theodorejb
Copy link

the pr #39720 set the background color, while my suggestion was to make floating-labels (when acting as input placeholders) and input-placeholders have the same color

@pine3ree That PR didn't only change the background color. It also fixed the floating label color so it no longer looks like input text when acting as a placeholder. See the preview: https://deploy-preview-39720--twbs-bootstrap.netlify.app/docs/5.3/forms/floating-labels/

@pine3ree
Copy link
Contributor Author

pine3ree commented Oct 8, 2024

@theodorejb
I must have missed it, sorry... closing it!

@pine3ree pine3ree closed this Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants