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

Feature request: col-form-label should have optional size classes #24917

Closed
tmorehouse opened this issue Nov 29, 2017 · 10 comments
Closed

Feature request: col-form-label should have optional size classes #24917

tmorehouse opened this issue Nov 29, 2017 · 10 comments

Comments

@tmorehouse
Copy link
Contributor

tmorehouse commented Nov 29, 2017

  • Operating system and version: Any
  • Browser and version: Any
  • Bootstrap V4

Currently, .col-form-label and two helper classes for sizing .col-form-label-sm and .col-form-label-lg, so that the label can be matched with the form-control's sizing.

When using a <fieldset> to group related controls in a form-group, one uses the <legend> element to label the group of inputs, and one can use the corresponding class .col-form-legend to style the legend.

Unfortunately there are no helper classes .col-form-legend-sm or .col-form-legend-lg to control the legend text size so that it matches up with the form-control size or other col-form-labels that may be in the same form.

I have tried applying the .col-form-label-sm (or -lg) classes to the <legend> along with .col-form-legend, but it does not work, due to the order of the definition of the CSS rules which make .col-form-legend's font size overrule .col-form-label-sm

Maybe just simply moving the .col-form-legend CSS rule before the .col-form-label-{size} rules would suffice?

@tmorehouse
Copy link
Contributor Author

PR #24932 adds in two size classes for horizontal form-group legend elements

@XhmikosR XhmikosR added the has-pr label Dec 1, 2017
@mdo
Copy link
Member

mdo commented Dec 2, 2017

Maybe just simply moving the .col-form-legend CSS rule before the .col-form-label-{size} rules would suffice?

Why do the PR if this would've sufficed? I'd prefer the simpler rearrangement vs a whole new suite of modifier classes.

@tmorehouse
Copy link
Contributor Author

tmorehouse commented Dec 2, 2017

There are a few differences between label and legend, when I checked the latest _forms.scss, where .col-form-label includes a calculation to add on the input border widths (when calculating padding), while the .col-form-legend class doesn't:

.col-form-label {
   padding-top: calc(#{$input-padding-y} + #{$input-border-width});
   padding-bottom: calc(#{$input-padding-y} + #{$input-border-width});
   margin-bottom: 0; // Override the `<label>` default
   line-height: $input-line-height;
}

.col-form-legend {
   padding-top: $input-padding-y;
   padding-bottom: $input-padding-y;
   margin-bottom: 0;
   font-size: $font-size-base;
 }

If they were identical styling, it would be just a matter of moving the base .col-form-legend class above the label definitions and using the .col-form-label-{size} classes

@tmorehouse
Copy link
Contributor Author

tmorehouse commented Dec 2, 2017

The question is, why couldn't legend and label use the same classes (.col-form-label & .col-form-label-{size}) and forgo the use of a special class for .col-form-legend? Would it be possible to normalize the two into a single namespace of classes that work for both?

@mdo
Copy link
Member

mdo commented Dec 2, 2017

Yeah, I feel that. Just tested it—can you make that change? Let's drop .col-form-legend and move the font-size reset to .col-form-label as font-size: inherit.

@mdo
Copy link
Member

mdo commented Dec 2, 2017

Maybe there's something more in the log as to why it needed to be another class?

@tmorehouse
Copy link
Contributor Author

OK, I'll make some tweaks

@tmorehouse
Copy link
Contributor Author

It appears .col-form-legend (when it was called -form-control-legend) was added in this commit 727722d#diff-55562cf68df408880356390d08c7a3cb but no real explanation why it is not the same as .col-form-label

@tmorehouse
Copy link
Contributor Author

tmorehouse commented Dec 2, 2017

.col-form-legend is now gone altogether (and form docs updated)

For backwards comparability, would it be good to specify both class names?

.col-form-label,
.col-form-legend {
 /* ... */
}

@mdo
Copy link
Member

mdo commented Dec 2, 2017

For backwards comparability, would it be good to specify both class names?

Not necessary—we're still at beta, so we can break things.

@mdo mdo closed this as completed in #24932 Dec 2, 2017
@mdo mdo mentioned this issue Dec 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants