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
  • !25050

Form check markup v2

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Mark Otto requested to merge form-check-markup-v2 into v4-dev Dec 21, 2017
  • Overview 0
  • Commits 10
  • Pipelines 0
  • Changes 7

I opened #23444 several weeks ago to gather feedback, but I haven't seen or heard much. This past week I put the changes to the test in this Codepen and found a simpler, more flexible path forward. Thus, I've once again rewritten the native and custom checks.

Now, both native and custom checks share the same HTML, but different classes:

<!-- Default -->
<div class="form-check">
  <input type="checkbox" class="form-check-input" id="exampleCheck1">
  <label class="form-check-label" for="exampleCheck1">Browser default checkbox</label>
</div>

<!-- Custom -->
<div class="custom-control custom-checkbox">
  <input type="checkbox" class="custom-control-input" id="customCheck1">
  <label class="custom-control-label" for="customCheck1">Custom checkbox</label>
</div>

Here's why things have changed:

  • This structure allows sibling selectors (~) to style the <label> based on the <input> state.
  • For form validation feedback, we can also use sibling selectors to show valid or invalid text.
  • Previously, default and custom checks were vastly different in markup. They're now the same, but different classes. For custom checks, the custom indicator was previously a <span>—it's now generated ::before and ::after pseudo-elements.
  • Default and custom checks layout previously behaved differently—default being stacked, custom being inline. Now, both are the same and .custom-controls-stacked is no more. Inline custom checks need the .custom-control-inline modifier, matching the defaults.

Altogether, these changes fix #23426 (closed), fix #23449 (closed), close #23503, fix #24624 (closed), fix #24888 (closed).

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