Course Content
Bootstrap 5 Grid
In Bootstrap 5, the grid system is a powerful and flexible feature that allows you to create responsive layouts for your web pages. The grid system is based on a 12-column layout, which helps you organize and align content effectively.
0/9
Bootstrap 5 Other
Bootstrap 5 offers many other features and components in addition to the ones mentioned earlier
0/4
Bootstrap 5 – A Comprehensive Guide to Modern Web Development
About Lesson

In Bootstrap 5, you can create stylish checkboxes and radio buttons using the <input> element and Bootstrap’s form styling classes. Here’s how you can create checkboxes and radio buttons in Bootstrap 5:

  1. Checkboxes:
<div class="form-check">
  <input class="form-check-input" type="checkbox" value="" id="checkbox1">
  <label class="form-check-label" for="checkbox1">
    Checkbox 1
  </label>
</div>

<div class="form-check">
  <input class="form-check-input" type="checkbox" value="" id="checkbox2">
  <label class="form-check-label" for="checkbox2">
    Checkbox 2
  </label>
</div>

In this example, the form-check class is applied to a <div> container, and the checkbox is created using the <input> element with the form-check-input class. The associated label is created using the <label> element with the form-check-label class.

  1. Inline Checkboxes:
<div class="form-check form-check-inline">
  <input class="form-check-input" type="checkbox" value="" id="checkbox1">
  <label class="form-check-label" for="checkbox1">
    Checkbox 1
  </label>
</div>

<div class="form-check form-check-inline">
  <input class="form-check-input" type="checkbox" value="" id="checkbox2">
  <label class="form-check-label" for="checkbox2">
    Checkbox 2
  </label>
</div>

By adding the form-check-inline class to the <div> container, the checkboxes will be displayed inline, horizontally.

  1. Radio Buttons:
<div class="form-check">
  <input class="form-check-input" type="radio" name="radioGroup" id="radio1" value="option1">
  <label class="form-check-label" for="radio1">
    Radio 1
  </label>
</div>

<div class="form-check">
  <input class="form-check-input" type="radio" name="radioGroup" id="radio2" value="option2">
  <label class="form-check-label" for="radio2">
    Radio 2
  </label>
</div>

Radio buttons are created using the <input> element with the type="radio" attribute. Make sure to give each radio button in a group the same name attribute to enable the selection of a single option from the group.

  1. Inline Radio Buttons:
<div class="form-check form-check-inline">
  <input class="form-check-input" type="radio" name="radioGroup" id="radio1" value="option1">
  <label class="form-check-label" for="radio1">
    Radio 1
  </label>
</div>

<div class="form-check form-check-inline">
  <input class="form-check-input" type="radio" name="radioGroup" id="radio2" value="option2">
  <label class="form-check-label" for="radio2">
    Radio 2
  </label>
</div>

By adding the form-check-inline class to the <div> container, the radio buttons will be displayed inline, horizontally.

These examples demonstrate how to create checkboxes and radio buttons in Bootstrap 5. You can further customize the appearance and behavior of checkboxes and radio buttons using additional Bootstrap classes and JavaScript-based plugins if needed.

Remember to include the necessary Bootstrap 5 CSS and JavaScript files in your project to apply the checkbox and radio button styling and functionality provided by Bootstrap

Join the conversation