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

Floating labels: Add an artificial background to label #37125

Merged

Conversation

louismaximepiton
Copy link
Member

@louismaximepiton louismaximepiton commented Sep 12, 2022

Fixes #32800.

Here is a proposal for floating labels in textareas.

Solution

Patchwork of many comments/solution wrote in #32800. I tried to not add an extra class but it might be harder to maintain, I let you decide what would be better here.

Checks

  • Works with everything in the page (even valid and invalid state, select)
  • Works with sizes on input
  • Couldn't spot any breaking change with the actual implementation

Live preview

https://deploy-preview-37125--twbs-bootstrap.netlify.app/docs/5.2/forms/floating-labels/#textareas

@louismaximepiton louismaximepiton requested a review from a team as a code owner September 12, 2022 10:48
@louismaximepiton louismaximepiton force-pushed the main-lmp-floating-label-textareas branch from bbc175f to c068e71 Compare September 27, 2022 14:45
@@ -1001,6 +1001,7 @@ $form-floating-padding-x: $input-padding-x !default;
$form-floating-padding-y: 1rem !default;
$form-floating-input-padding-t: 1.625rem !default;
$form-floating-input-padding-b: .625rem !default;
$form-floating-label-height: 1.875em !default;
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should use a calc function or some math here to get the 1.875em?

Copy link
Member Author

@louismaximepiton louismaximepiton Oct 4, 2022

Choose a reason for hiding this comment

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

Actually, I've chosen this value arbitrarily, it "feels right" to me. Open to any thoughts here!

Copy link
Member

Choose a reason for hiding this comment

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

Oh well the math works out perfectly lol. $form-floating-height is about 3.5rem (not including border), the top padding is 1.625rem, so 3.5-1.625=1.875. 😅

But since the math is a little janky because of the border additions, I'm inclined to ship as-is.

@julien-deramond julien-deramond self-requested a review October 6, 2022 06:09
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.

LGTM as well! 🚀
Thanks @louismaximepiton

@julien-deramond julien-deramond merged commit bf6240d into twbs:main Oct 6, 2022
@louismaximepiton louismaximepiton deleted the main-lmp-floating-label-textareas branch October 6, 2022 06:51
@AgentSmith0
Copy link

Hello, I noticed that a disabled floating label looks pretty bad due to this change:
grafik

@julien-deramond
Copy link
Member

Could you please create a dedicated issue for that @AgentSmith0?

@AgentSmith0
Copy link

#37297

@jonnysp jonnysp mentioned this pull request Oct 17, 2022
3 tasks
@saranglakare
Copy link

Any idea when this will be released? The problem exists on latest 5.3 as of 4 Feb 2023. Thanks!

@AgentSmith0
Copy link

True, this issue seems to appear again. See here: https://twbs-bootstrap.netlify.app/docs/5.3/forms/floating-labels/#disabled

@saranglakare
Copy link

@louismaximepiton @mdo could you please cross-check? The fix mentioned still works - so not sure if this change was never published or something caused this change to be reverted. Thanks a ton!

@louismaximepiton
Copy link
Member Author

Hey Saranglakare, AgentQmith0,

Just pushed a PR fixing this issue, thanks for raising a flag here !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Floating label on textarea overlaps content
5 participants