Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Bootstrap4 Custom Forms

Bootstrap4 Custom Forms

Bootstrap4 can customize some form styles to replace the browser's default styles.


Custom Checkboxes

To customize a checkbox, you can set the

as the parent element with classes .custom-control and .custom-checkbox, place the checkbox as a child inside that
, then set the checkbox to the type="checkbox"class .custom-control-input.

The text of the checkbox uses the label label, with the .custom-control-label class on the label,label 's for and the attribute value must match the checkbox's id.

Bootstrap4 Example

<form>
<div class=">

custom-control custom-checkbox

"

<input type="checkbox" class="custom-control-input" id="customCheck" name="example1">
<label class="custom-control-label" for="customCheck">

Custom Checkboxes

label

div

form

Try it »


Custom Radios

To customize a radio, you can set the

as the parent element with classes .custom-control and .custom-radio, place the radio as a child inside that
, then set the radio to the type="radio"class .custom-control-input.

The text of the radio uses the label label, with the .custom-control-label class on the label,label 's for and the attribute value must match the radio's id。

Bootstrap4 Example

<form>
<div class=">

custom-control custom-radio

"

<input type="radio" class="custom-control-input" id="customRadio" name="example1" value="customEx">
<label class="custom-control-label" for="customRadio">

Custom Radios

label

div

form

Try it »


Displaying Custom Controls on the Same Line

We can use the .custom-control-inline class on the outer element to wrap custom form controls so they display on the same line:

Bootstrap4 Example

<form>
<div class=">

custom-control custom-radio custom-control-inline

"

<input type="radio" class="custom-control-input" id="customRadio" name="example" value="customEx">
<label class="custom-control-label" for="customRadio">

Custom radio 1

label

div

<div class=">

custom-control custom-radio custom-control-inline

"

<input type="radio" class="custom-control-input" id="customRadio2" name="example" value="customEx">
<label class="custom-control-label" for="customRadio2">

Custom radio 2

label

div

form

Try it »


Custom Select Menu

To create a custom select menu, you can add the .custom-select class to the