Skip to content

v5: Floating labels#30449

Merged
mdo merged 15 commits intomainfrom
v5-floating-labels
Oct 28, 2020
Merged

v5: Floating labels#30449
mdo merged 15 commits intomainfrom
v5-floating-labels

Conversation

@mdo
Copy link
Copy Markdown
Member

@mdo mdo commented Mar 25, 2020

Comment thread scss/forms/_floating-labels.scss Outdated
Comment thread scss/forms/_floating-labels.scss
@micka-fdz
Copy link
Copy Markdown

Good news! Is it possible to add support for <textarea> and .form-file elements?

Comment thread scss/forms/_floating-labels.scss Outdated
@MartijnCuppens
Copy link
Copy Markdown
Member

It feels a bit odd to me that the label doesn't shrink when The input field is focused, it looks like you're going to type in text before the password text:
image

I would prefer:
image

Thoughts?

Comment thread scss/forms/_floating-labels.scss Outdated
Comment thread scss/forms/_floating-labels.scss Outdated
Comment thread scss/forms/_floating-labels.scss Outdated
Comment thread scss/forms/_floating-labels.scss Outdated
Comment thread scss/forms/_floating-labels.scss Outdated
Comment thread scss/forms/_floating-labels.scss Outdated
Comment thread scss/forms/_floating-labels.scss Outdated
Comment thread scss/forms/_floating-labels.scss Outdated
Comment thread scss/forms/_floating-labels.scss Outdated
Comment thread scss/forms/_form-select.scss
@alecpl
Copy link
Copy Markdown
Contributor

alecpl commented Mar 30, 2020

  1. The "placeholder" color is wrong. Should be grey-ish, now it uses input text color. Is this something possible to fix?
  2. I think I would prefer the way it looks as proposed in Feature Request: Floating Labels #21312 (comment)

@mdo mdo changed the base branch from master to main June 16, 2020 20:04
@mdo mdo force-pushed the v5-floating-labels branch from 855e2a2 to 50a6a16 Compare September 17, 2020 19:06
@mdo
Copy link
Copy Markdown
Member Author

mdo commented Sep 17, 2020

Pushed some changes based on the code review and fixing some conflicts. Also made the change from @MartijnCuppens's suggestion and moved the label on :focus now, too. I dig!

Added textarea support too, @micka-fdz. Unsure about file inputs... those ones are more complicated. Could be an add-on in the future once this gets settled.

@mdo mdo force-pushed the v5-floating-labels branch from 50a6a16 to ab6c6f9 Compare September 21, 2020 01:22
@mdo
Copy link
Copy Markdown
Member Author

mdo commented Sep 21, 2020

Pushed some more updates to address @MartijnCuppens's comments. Wondering if there's some more I can do to make this more bulletproof. Happy to hear out any comments!

@ffoodd
Copy link
Copy Markdown
Contributor

ffoodd commented Sep 21, 2020

@mdo Regarding browser support and accessibility, I think my PR against our example (#30966) should help:

  1. Better fallback for Legacy Edge, avoiding to hide labels,
  2. more precise browser support doc.

@patrickhlauke
Copy link
Copy Markdown
Member

once you/we settled on the definitive version, i can have a quick look accessibility-wise if needed / if you ping me and point me to it.

@mdo mdo force-pushed the v5-floating-labels branch from 0e3a92c to defdf95 Compare October 26, 2020 22:22
@mdo
Copy link
Copy Markdown
Member Author

mdo commented Oct 26, 2020

@eduardogoncalves Yup, pushed a new fix to override that last commit with separated rules. Should be good now.

@mdo
Copy link
Copy Markdown
Member Author

mdo commented Oct 26, 2020

This should be good to go now! Can I get a final review?

mdo and others added 12 commits October 26, 2020 16:46
- Adds new .form-floating
- Stubs out basics of a docs page
- Removes existing Example
…ts more consistent

- To do this, I made the .form-control and .form-select consistent in min-height vs height
- Removed some unused variables now
- Updated -color to be the -color because I don't know why this was any different before
- Update page to include some examples for layout, validation, and value
- Rewrite styles to not modify padding, but instead transform and opacity
- Apply some optimizations from code review
- Removed unecessary properties from the label
- Add some comments for what properties are required
- Move from fixed height for labels to height 100% so we can support textareas
- Improve docs a little bit, add ToC
@mdo mdo force-pushed the v5-floating-labels branch from 33a0a0c to e4f7f67 Compare October 26, 2020 23:47
@alecpl
Copy link
Copy Markdown
Contributor

alecpl commented Oct 27, 2020

I think I don't like these big inputs (and with strange padding when they are empty). Something like in #30449 (comment) would be better.

@micka-fdz
Copy link
Copy Markdown

I agree, fields are currently much too big.
I prefer this render : https://getbootstrap.com/docs/4.5/examples/floating-labels/

@MartijnCuppens
Copy link
Copy Markdown
Member

#30449 (comment) would require an additional background to fix the border and shadow overlap

image

This will look weird if the parent element has another background
image

Or if the background of the input is semi-transparent:
image

But I can agree the input looks a little to big. https://getbootstrap.com/docs/4.5/examples/floating-labels/ might indeed be a better look as @micka-fdz suggests.

@alecpl
Copy link
Copy Markdown
Contributor

alecpl commented Oct 27, 2020

Semi-transparent input is a rare-case that could be just unsupported by floating labels. The other label background issue I could live with if the padding-top was smaller (and maybe with rounded corners). Still I would prefer this over what's proposed in the PR.

@alecpl
Copy link
Copy Markdown
Contributor

alecpl commented Oct 27, 2020

@mdo, in firefox 82 on linux the label animation has some issue. When you focus the input there are two steps of the animation visible, first the label moves up, then it's font size drops to even smaller. Maybe it's a firefox's transform/scale bug. Looks like when the text is moving it is blured then it sharpens. I don't see this in Chrome.

Comment thread scss/forms/_floating-labels.scss Outdated
pointer-events: none;
border: $input-border-width solid transparent; // Required for aligning label's text with the input as it affects inner box model
transform-origin: 0 0;
@include transition(opacity .1s ease-in-out, transform .1s ease-in-out);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't this value be variable, as we do with $input-transition?
Apart from that, seems fine!

Copy link
Copy Markdown
Contributor

@ffoodd ffoodd Oct 27, 2020

Choose a reason for hiding this comment

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

Trying this on both Firefox & Chromium on Ubuntu, I can see a little font rendering jump (more obvious on Firefox). I guess it can be related to the font-stack I updated recently—already mentionned a related bug in #31955 by @MartijnCuppens.

That's unrelated to the PR I guess, I'd need more testing on those using our old font-stack and compare other possibilities… Opening an issue to track this. Edit: #31991

@mdo mdo requested a review from a team as a code owner October 28, 2020 03:02
@mdo mdo merged commit 3e2f9ab into main Oct 28, 2020
@mdo mdo deleted the v5-floating-labels branch October 28, 2020 03:45
@micka-fdz
Copy link
Copy Markdown

micka-fdz commented Oct 30, 2020

Hi @MartijnCuppens, what about my suggestion of inputs height? I think it’s a quick modification. Maybe can I help?

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.

Feature Request: Floating Labels

10 participants