Bootstrap5 check box and radio box


Release date:2024-01-12 Update date:2024-01-12 Editor:admin View counts:69

Label:

Bootstrap5 check box and radio box

If you want the user to select any number of options from the list of preset options, you can use the check box:

Image0

Example

<div class="form-check">
  <input class="form-check-input" type="checkbox" id="check1" name="option1" value="something" checked>
  <label class="form-check-label">Option 1</label>
</div>

Check boxes ensure that labels and check boxes have appropriate margins by using class= “form-check”.

.form-check-label Class is added to the tag element, and to the .form- check container .form-check-input class to style the check box.

checked Property is used to set the options selected by default.

Check box

If you want the user to select an option from the list of preset options, you can use the check box:

Image1

Example

<div class="form-check">
  <input type="radio" class="form-check-input" id="radio1" name="optradio" value="option1" checked>Option 1
  <label class="form-check-label" for="radio1"></label>
</div>
<div class="form-check">
  <input type="radio" class="form-check-input" id="radio2" name="optradio" value="option2">Option 2
  <label class="form-check-label" for="radio2"></label>
</div>
<div class="form-check">
  <input type="radio" class="form-check-input" disabled>Option 3
  <label class="form-check-label"></label>
</div>

Changeover switch

If you want to turn the check box into a switchable switch, you can use the .form-check Use in the container .form-switch class:

Image2

Example

<div class="form-check form-switch">
  <input class="form-check-input" type="checkbox" id="mySwitch" name="darkmode" value="yes" checked>
  <label class="form-check-label" for="mySwitch">Dark Mode</label>
</div>

Powered by TorCMS (https://github.com/bukun/TorCMS).