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

Change floating label background-color to transparent #39480

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Nickiam7
Copy link

@Nickiam7 Nickiam7 commented Dec 9, 2023

Description

Floating labels have a background-color set to $input-bg. This can look odd if an input uses a browsers native autocomplete which adds a light blue background to the input. Additionally, if a sites design requires styling of input background colors the floating label will appear with the $input-bg color on top of the input background color.

Motivation & Context

Removes the need to manually override the floating label background color.

Type of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would change existing functionality)

Checklist

  • I have read the contributing guidelines
  • My code follows the code style of the project (using npm run lint)
  • My change introduces changes to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Live previews

@Nickiam7 Nickiam7 marked this pull request as ready for review December 10, 2023 00:30
@Nickiam7 Nickiam7 requested a review from a team as a code owner December 10, 2023 00:30
@theodorejb
Copy link

@Nickiam7
Copy link
Author

@theodorejb thanks for adding screenshots!

@mdo
Copy link
Member

mdo commented Dec 12, 2023

The background color was added to ensure labels were legible on multi-line inputs or textareas.

@theodorejb
Copy link

@mdo Is there an example where it improves legibility? It seems like the label background is only visible when an input is autofilled.

@julien-deramond
Copy link
Member

Here's an example where a solid background is useful:
Screenshot 2023-12-19 at 18 29 48

With the fix in this PR:

Screenshot 2023-12-19 at 18 31 14

@theodorejb
Copy link

@julien-deramond Ah, that is useful for when textarea contents are scrolled.

@Nickiam7
Copy link
Author

Thanks for the context @mdo and thanks for the screenshots @julien-deramond! It does make sense for textareas, I def agree.

Does it makes sense to apply this fix to an input field of type password and email since those will almost always be single line inputs? Or I could just make a note how to adjust the css to fix this in the docs.

@mdo
Copy link
Member

mdo commented Jan 9, 2024

Does it makes sense to apply this fix to an input field of type password and email since those will almost always be single line inputs? Or I could just make a note how to adjust the css to fix this in the docs.

I don't think there was any particular reason we didn't special case this based on the HTML element. I'm down to see if we can scope the addition of the background-color to just the textarea. Want to take a crack?

theodorejb added a commit to theodorejb/bootstrap that referenced this pull request Jan 30, 2024
Only apply extra top padding to textareas where it is needed.

Also removed unnecessary floating label background for non-textareas (supersedes twbs#39480).
theodorejb added a commit to theodorejb/bootstrap that referenced this pull request Jan 30, 2024
Only apply extra top padding to textareas where it is needed.

Also removed unnecessary floating label background for non-textareas (supersedes twbs#39480).
theodorejb added a commit to theodorejb/bootstrap that referenced this pull request Jan 30, 2024
Only apply extra top padding to textareas where it is needed.

Also removed unnecessary floating label background for non-textareas (supersedes twbs#39480).
theodorejb added a commit to theodorejb/bootstrap that referenced this pull request Jan 30, 2024
Only apply extra padding to textareas where it is needed.

Also removed unnecessary floating label background for non-textareas (supersedes twbs#39480).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Needs review
Development

Successfully merging this pull request may close these issues.

None yet

5 participants