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

Form field sizing #35896

Closed
2 tasks done
WinterSilence opened this issue Feb 24, 2022 · 3 comments
Closed
2 tasks done

Form field sizing #35896

WinterSilence opened this issue Feb 24, 2022 · 3 comments
Labels

Comments

@WinterSilence
Copy link
Contributor

Prerequisites

Proposal

  1. checkbox/switch, radio, range inputs and textareas don't have sizing classes as form-control-sm and form-control-lg.
    grouply:
<div class="form-check form-check-sm mb-3">
  <!-- + "form-check-input-sm" -->
  <input class="form-check-input" type="checkbox" id="remember-me">
  <!-- + "form-check-label-sm" -->
  <label class="form-check-label" for="remember-me">Remember me</label>
</div>

or directly:

<div class="form-check mb-3">
  <input class="form-check-input form-check-input-sm" type="checkbox" id="remember-me">
  <label class="form-check-label form-check-label-sm" for="remember-me">Remember me</label>
</div>
  1. input color with sizing class form-control-* have wrong height: <input type="color" class="form-control form-control-sm form-control-color"> - 35px, <input type="text" class="form-control form-control-sm"> - 31px
  2. input width (css width, min-width and max-width) by attributes minlength, maxlength or size: if maxlength="250" is width:100%, then maxlength="100" is width:40% i.e. 100 / (250 / 100) or by size(step size: 10): input[size="10"] is input{min-width:10em;}, input[size="20"] is input{min-width:20em;}
  3. There are no classes that allow to set size for all controls, labels and buttons in form/fieldset by default like as:
<!-- class "form-sm" similar to adding classes to elements: -->
<form class="form-sm">
  <div class="row mb-3">
    <!-- + "col-form-label-sm" -->
    <label for="email" class="col-2 col-form-label">Email</label>
    <div class="col-10">
      <!-- + "form-control-sm" -->
      <input type="email" class="form-control" id="email">
    </div>
  </div>
  <div class="row mb-3">
    <!-- + "col-form-label-sm" -->
    <label for="password" class="col-2 col-form-label">Password</label>
    <div class="col-10">
      <!-- + "form-control-sm" -->
      <input type="password" class="form-control" id="password">
    </div>
  </div>
  <!-- + "btn-sm" -->
  <button type="submit" class="btn btn-primary">Sign in</button>
</form>

Motivation and context

  1. Setting size for any control, label or button in form
  2. Setting size for inner controls, labels and buttons by container(form/fieldset/row) class
@mdo
Copy link
Member

mdo commented Apr 12, 2022

  1. Checks, radios, and switches are sized with font-size. Annoying in some respects, but also a nice convenience IMO. We'll stick with that for now.
  2. Good callout, I've opened Update .form-control-color sizing and styles #36156 to address that.
  3. I see what you're going for, but using we'll stick to explicit width dimensions for sizing inputs. minlength and maxlength affect the number of characters within an input, not it's size. size is interesting, but going by character count when variable fonts across browsers and devices is a recipe for some difficult inconsistencies.
  4. No plans to add form-wide sizing.

@mdo mdo closed this as completed Apr 12, 2022
@WinterSilence
Copy link
Contributor Author

WinterSilence commented Apr 12, 2022

  1. why? set form size(.form-sm) and customize some controls(.form-control-md) are shortest and easy than sets sizes for all controls in form(.form-control-sm/.form-control-md, .form-label-sm/.form-label-md)

@David-Baron
Copy link

Sorry, I missed your answers. When you have a design, it is (usually) the same for the whole form. When you have a form with 50 inputs/labels, it would be better to have a general style in the form tag. This was just an idea, but if it doesn't please anyone...sorry for the inconvenience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants