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
fix(form): update label alignment #2200
Conversation
PatternFly-Next preview: https://patternfly-next-pr-2200.surge.sh |
|
||
<br> | ||
|
||
{{#> form form--modifier="pf-m-horizontal" form--id="horizontal-align-labels"}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
form--id
needs to be unique
If a user has a horizontal group with multiple form control elements, or just a tall element, the label is going to be vertically aligned to the center. Is that OK or would that be breaking? This is what that will look like if a user just pulls in this PR without adding the And personally I think labels adjacent to groups with multiple lines where the first line is a form control element, I would still expect the label text to align with the text in the form control element. So this (top padding) instead of this (no padding) |
@mcoker Yeah I think that will be a breaking change, would you recommend that I make this an opt-in solution or release it during the breaking change period? In the screenshot below is this how you would expect to see it happen? By default the label is vertically-aligned in the center (helper text is outside of |
It is, but that's just my opinion :) If we went that way, couldn't we just add a I was also going to say that we could also just apply the |
@mcoker @mattnolting made updates so that this isn't breaking... adding a modifier for when the label is adjacent to a non-formcontrol element Also confirmed with @mcarrano that wrapping the label is fine, but from a design perspective long labels should be avoided. |
.pf-c-form__group .pf-c-form__label { | ||
padding-top: var(--pf-c-form__label--PaddingTop); | ||
padding-bottom: 0; | ||
|
||
&.pf-m-no-padding { | ||
padding-top: 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
padding-top: 0; | |
--pf-c-form__label--PaddingTop: 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
@@ -28,4 +28,5 @@ | |||
| `.pf-m-inactive` | `.pf-c-form__helper-text`| Modifies display of helper text to none. | | |||
| `.pf-m-border` | `.pf-c-form__section` | Modifies form element border-bottom. | | |||
| `.pf-m-disabled` | `.pf-c-form__label` | Modifies form label to show disabled state. | | |||
| `.pf-m-no-padding` | `.pf-c-form__label` | Removes top padding from the label element for labels adjacent to an element that isn't a form control. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be .pf-m-no-padding-top
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me!! I left a couple of comments. We can address in this PR if you want, or we can open a new issue to look at later.
Thanks for reviewing. I think I captured all of your comments and removed the text underneath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! LGTM
🎉 This PR is included in version 2.31.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
closes #2167
Spoke with @kybaker about how we should handle form labels. We came to the conclusion that: -
This should allow for these labels to more flexible, especially with font-sizes changing. The downside is that the user will have to add a modifier to change the label to align to the top.
Here is the example in the horizontal form demo:
Bootstrap does something similar: