Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Merge requests
  • !23444

Form check markup

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Mark Otto requested to merge form-check-markup into v4-dev Aug 15, 2017
  • Overview 0
  • Commits 16
  • Pipelines 0
  • Changes 6

This fixes #23426 (closed), but might constitute as a breaking change.

What changes

Validating an input within our .form-check component is straightforward—it'll handle :valid and :invalid with ease. However, styling the label's text based on the input's state is another thing. Let's look at what we have now:

<div class="form-check">
  <label class="form-check-label">
    <input type="checkbox" class="form-check-input">
    Check me out
  </label>
</div>

With the above HTML, you cannot style Check me out in CSS based on .form-check-input's state. To make that happen, we need a sibling element to style, something like:

<div class="form-check">
  <label class="form-check-label">
    <input type="checkbox" class="form-check-input">
    <span class="form-check-description">Check me out</span>
  </label>
</div>

That's what this PR changes all our checkboxes and radios to. This matches custom forms more and enables CSS-only validation of checkboxes/radios.

Breaking or non-breaking?

So, why the question of maybe breaks backward compatibility? It's not strictly required. Right now, there's no need to include it for anything but validation. However, it could help improve styling of disabled inputs as well. Here's the current CSS for disabled .form-checks, which requires a parent class:

https://github.com/twbs/bootstrap/blob/5b8738afc1c7e746d6f08ec0f25f83603307de45/scss/_forms.scss#L218-L228

With this change, we could do:

.form-check {
  position: relative;
  display: block;
  margin-bottom: $form-check-margin-bottom;
}

.form-check-input:disabled {
  + .form-check-description {
    color: $text-muted;
  }
}

Thoughts?

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: form-check-markup