.btn-group-toggle {
> .btn,
> .btn-group > .btn {
- margin-bottom: 0; // Override default `<label>` value
-
input[type="radio"],
input[type="checkbox"] {
position: absolute;
position: relative;
display: block;
padding: $list-group-item-padding-y $list-group-item-padding-x;
- margin-bottom: 0; // for <label> variations
color: $list-group-color;
text-decoration: if($link-decoration == none, null, none);
background-color: $list-group-bg;
label {
display: inline-block; // 1
- margin-bottom: $label-margin-bottom;
}
// Remove the default `border-radius` that macOS Chrome adds.
// Forms
-$label-margin-bottom: .5rem !default;
+$form-label-margin-bottom: .5rem !default;
+$form-label-font-size: null !default;
+$form-label-font-style: null !default;
+$form-label-font-weight: null !default;
+$form-label-color: null !default;
$input-padding-y: $input-btn-padding-y !default;
$input-padding-x: $input-btn-padding-x !default;
}
.form-check-label {
- margin-bottom: 0;
color: $form-check-label-color;
cursor: $form-check-label-cursor;
}
display: flex;
align-items: center;
padding: $input-padding-y $input-padding-x;
- margin-bottom: 0; // Allow use of <label> elements by overriding our default margin-bottom
@include font-size($input-font-size); // Match inputs
font-weight: $font-weight-normal;
line-height: $input-line-height;
// Labels
//
+.form-label {
+ margin-bottom: $form-label-margin-bottom;
+ @include font-size($form-label-font-size);
+ font-style: $form-label-font-style;
+ font-weight: $form-label-font-weight;
+ color: $form-label-color;
+}
+
// For use with horizontal and inline forms, when you need the label (or legend)
// text to align with the form controls.
.col-form-label {
padding-top: add($input-padding-y, $input-border-width);
padding-bottom: add($input-padding-y, $input-border-width);
- margin-bottom: 0; // Override the `<label>/<legend>` default
+ margin-bottom: 0; // Override the `<legend>` default
@include font-size(inherit); // Override the `<legend>` default
+ font-style: $form-label-font-style;
+ font-weight: $form-label-font-weight;
line-height: $input-line-height;
+ color: $form-label-color;
}
.col-form-label-lg {
<div class="dropdown-menu">
<form class="px-4 py-3">
<div class="mb-3">
- <label for="exampleDropdownFormEmail1">Email address</label>
+ <label for="exampleDropdownFormEmail1" class="form-label">Email address</label>
<input type="email" class="form-control" id="exampleDropdownFormEmail1" placeholder="email@example.com">
</div>
<div class="mb-3">
- <label for="exampleDropdownFormPassword1">Password</label>
+ <label for="exampleDropdownFormPassword1" class="form-label">Password</label>
<input type="password" class="form-control" id="exampleDropdownFormPassword1" placeholder="Password">
</div>
<div class="mb-3">
{{< example >}}
<form class="dropdown-menu p-4">
<div class="mb-3">
- <label for="exampleDropdownFormEmail2">Email address</label>
+ <label for="exampleDropdownFormEmail2" class="form-label">Email address</label>
<input type="email" class="form-control" id="exampleDropdownFormEmail2" placeholder="email@example.com">
</div>
<div class="mb-3">
- <label for="exampleDropdownFormPassword2">Password</label>
+ <label for="exampleDropdownFormPassword2" class="form-label">Password</label>
<input type="password" class="form-control" id="exampleDropdownFormPassword2" placeholder="Password">
</div>
<div class="mb-3">
<form class="needs-validation" novalidate>
<div class="row g-3">
<div class="col-sm-6">
- <label for="firstName">First name</label>
+ <label for="firstName" class="form-label">First name</label>
<input type="text" class="form-control" id="firstName" placeholder="" value="" required>
<div class="invalid-feedback">
Valid first name is required.
</div>
<div class="col-sm-6">
- <label for="lastName">Last name</label>
+ <label for="lastName" class="form-label">Last name</label>
<input type="text" class="form-control" id="lastName" placeholder="" value="" required>
<div class="invalid-feedback">
Valid last name is required.
</div>
<div class="col-12">
- <label for="username">Username</label>
+ <label for="username" class="form-label">Username</label>
<div class="input-group">
<span class="input-group-text">@</span>
<input type="text" class="form-control" id="username" placeholder="Username" required>
</div>
<div class="col-12">
- <label for="email">Email <span class="text-muted">(Optional)</span></label>
+ <label for="email" class="form-label">Email <span class="text-muted">(Optional)</span></label>
<input type="email" class="form-control" id="email" placeholder="you@example.com">
<div class="invalid-feedback">
Please enter a valid email address for shipping updates.
</div>
<div class="col-12">
- <label for="address">Address</label>
+ <label for="address" class="form-label">Address</label>
<input type="text" class="form-control" id="address" placeholder="1234 Main St" required>
<div class="invalid-feedback">
Please enter your shipping address.
</div>
<div class="col-12">
- <label for="address2">Address 2 <span class="text-muted">(Optional)</span></label>
+ <label for="address2" class="form-label">Address 2 <span class="text-muted">(Optional)</span></label>
<input type="text" class="form-control" id="address2" placeholder="Apartment or suite">
</div>
<div class="col-md-5">
- <label for="country">Country</label>
+ <label for="country" class="form-label">Country</label>
<select class="form-select" id="country" required>
<option value="">Choose...</option>
<option>United States</option>
</div>
<div class="col-md-4">
- <label for="state">State</label>
+ <label for="state" class="form-label">State</label>
<select class="form-select" id="state" required>
<option value="">Choose...</option>
<option>California</option>
</div>
<div class="col-md-3">
- <label for="zip">Zip</label>
+ <label for="zip" class="form-label">Zip</label>
<input type="text" class="form-control" id="zip" placeholder="" required>
<div class="invalid-feedback">
Zip code required.
<div class="row gy-3">
<div class="col-md-6">
- <label for="cc-name">Name on card</label>
+ <label for="cc-name" class="form-label">Name on card</label>
<input type="text" class="form-control" id="cc-name" placeholder="" required>
<small class="text-muted">Full name as displayed on card</small>
<div class="invalid-feedback">
</div>
<div class="col-md-6">
- <label for="cc-number">Credit card number</label>
+ <label for="cc-number" class="form-label">Credit card number</label>
<input type="text" class="form-control" id="cc-number" placeholder="" required>
<div class="invalid-feedback">
Credit card number is required
</div>
<div class="col-md-3">
- <label for="cc-expiration">Expiration</label>
+ <label for="cc-expiration" class="form-label">Expiration</label>
<input type="text" class="form-control" id="cc-expiration" placeholder="" required>
<div class="invalid-feedback">
Expiration date required
</div>
<div class="col-md-3">
- <label for="cc-cvv">CVV</label>
+ <label for="cc-cvv" class="form-label">CVV</label>
<input type="text" class="form-control" id="cc-cvv" placeholder="" required>
<div class="invalid-feedback">
Security code required
left: 0;
display: block;
width: 100%;
- margin-bottom: 0; /* Override default `<label>` margin */
color: #495057;
pointer-events: none;
cursor: text; /* Match the input under the label */
{{< example >}}
<div class="mb-3">
- <label for="exampleFormControlInput1">Email address</label>
+ <label for="exampleFormControlInput1" class="form-label">Email address</label>
<input type="email" class="form-control" id="exampleFormControlInput1" placeholder="name@example.com">
</div>
<div class="mb-3">
- <label for="exampleFormControlTextarea1">Example textarea</label>
+ <label for="exampleFormControlTextarea1" class="form-label">Example textarea</label>
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3"></textarea>
</div>
{{< /example >}}
## Color
{{< example >}}
-<label for="exampleColorInput">Color picker</label>
+<label for="exampleColorInput" class="form-label">Color picker</label>
<input type="color" class="form-control form-control-color" id="exampleColorInput" value="#563d7c" title="Choose your color">
{{< /example >}}
Learn more about [support for datalist elements](https://caniuse.com/#feat=datalist).
{{< example >}}
-<label for="exampleDataList">Datalist example</label>
+<label for="exampleDataList" class="form-label">Datalist example</label>
<input class="form-control" list="datalistOptions" id="exampleDataList" placeholder="Type to search...">
<datalist id="datalistOptions">
<option value="San Francisco">
<span class="input-group-text" id="basic-addon2">@example.com</span>
</div>
-<label for="basic-url">Your vanity URL</label>
+<label for="basic-url" class="form-label">Your vanity URL</label>
<div class="input-group mb-3">
<span class="input-group-text" id="basic-addon3">https://example.com/users/</span>
<input type="text" class="form-control" id="basic-url" aria-describedby="basic-addon3">
{{< example >}}
<div class="mb-3">
- <label for="formGroupExampleInput">Example label</label>
+ <label for="formGroupExampleInput" class="form-label">Example label</label>
<input type="text" class="form-control" id="formGroupExampleInput" placeholder="Example input placeholder">
</div>
<div class="mb-3">
- <label for="formGroupExampleInput2">Another label</label>
+ <label for="formGroupExampleInput2" class="form-label">Another label</label>
<input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Another input placeholder">
</div>
{{< /example >}}
{{< example >}}
<form class="row g-3">
<div class="col-md-6">
- <label for="inputEmail4">Email</label>
+ <label for="inputEmail4" class="form-label">Email</label>
<input type="email" class="form-control" id="inputEmail4">
</div>
<div class="col-md-6">
- <label for="inputPassword4">Password</label>
+ <label for="inputPassword4" class="form-label">Password</label>
<input type="password" class="form-control" id="inputPassword4">
</div>
<div class="col-12">
- <label for="inputAddress">Address</label>
+ <label for="inputAddress" class="form-label">Address</label>
<input type="text" class="form-control" id="inputAddress" placeholder="1234 Main St">
</div>
<div class="col-12">
- <label for="inputAddress2">Address 2</label>
+ <label for="inputAddress2" class="form-label">Address 2</label>
<input type="text" class="form-control" id="inputAddress2" placeholder="Apartment, studio, or floor">
</div>
<div class="col-md-6">
- <label for="inputCity">City</label>
+ <label for="inputCity" class="form-label">City</label>
<input type="text" class="form-control" id="inputCity">
</div>
<div class="col-md-4">
- <label for="inputState">State</label>
+ <label for="inputState" class="form-label">State</label>
<select id="inputState" class="form-select">
<option selected>Choose...</option>
<option>...</option>
</select>
</div>
<div class="col-md-2">
- <label for="inputZip">Zip</label>
+ <label for="inputZip" class="form-label">Zip</label>
<input type="text" class="form-control" id="inputZip">
</div>
<div class="col-12">
{{< example >}}
<form>
<div class="mb-3">
- <label for="exampleInputEmail1">Email address</label>
+ <label for="exampleInputEmail1" class="form-label">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<div class="mb-3">
- <label for="exampleInputPassword1">Password</label>
+ <label for="exampleInputPassword1" class="form-label">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1">
</div>
<div class="mb-3 form-check">
Help text below inputs can be styled with `.form-text`. This class includes `display: block` and adds some top margin for easy spacing from the inputs above.
{{< example >}}
-<label for="inputPassword5">Password</label>
+<label for="inputPassword5" class="form-label">Password</label>
<input type="password" id="inputPassword5" class="form-control" aria-describedby="passwordHelpBlock">
<small id="passwordHelpBlock" class="form-text text-muted">
Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters, or emoji.
<form>
<fieldset disabled aria-label="Disabled fieldset example">
<div class="mb-3">
- <label for="disabledTextInput">Disabled input</label>
+ <label for="disabledTextInput" class="form-label">Disabled input</label>
<input type="text" id="disabledTextInput" class="form-control" placeholder="Disabled input">
</div>
<div class="mb-3">
- <label for="disabledSelect">Disabled select menu</label>
+ <label for="disabledSelect" class="form-label">Disabled select menu</label>
<select id="disabledSelect" class="form-select">
<option>Disabled select</option>
</select>
Create custom `<input type="range">` controls with `.form-range`. The track (the background) and thumb (the value) are both styled to appear the same across browsers. As only Firefox supports "filling" their track from the left or right of the thumb as a means to visually indicate progress, we do not currently support it.
{{< example >}}
-<label for="customRange1">Example range</label>
+<label for="customRange1" class="form-label">Example range</label>
<input type="range" class="form-range" id="customRange1">
{{< /example >}}
Range inputs have implicit values for `min` and `max`—`0` and `100`, respectively. You may specify new values for those using the `min` and `max` attributes.
{{< example >}}
-<label for="customRange2">Example range</label>
+<label for="customRange2" class="form-label">Example range</label>
<input type="range" class="form-range" min="0" max="5" id="customRange2">
{{< /example >}}
By default, range inputs "snap" to integer values. To change this, you can specify a `step` value. In the example below, we double the number of steps by using `step="0.5"`.
{{< example >}}
-<label for="customRange3">Example range</label>
+<label for="customRange3" class="form-label">Example range</label>
<input type="range" class="form-range" min="0" max="5" step="0.5" id="customRange3">
{{< /example >}}
{{< example >}}
<form class="row g-3 needs-validation" novalidate>
<div class="col-md-4">
- <label for="validationCustom01">First name</label>
+ <label for="validationCustom01" class="form-label">First name</label>
<input type="text" class="form-control" id="validationCustom01" value="Mark" required>
<div class="valid-feedback">
Looks good!
</div>
</div>
<div class="col-md-4">
- <label for="validationCustom02">Last name</label>
+ <label for="validationCustom02" class="form-label">Last name</label>
<input type="text" class="form-control" id="validationCustom02" value="Otto" required>
<div class="valid-feedback">
Looks good!
</div>
</div>
<div class="col-md-4">
- <label for="validationCustomUsername">Username</label>
+ <label for="validationCustomUsername" class="form-label">Username</label>
<div class="input-group">
<span class="input-group-text" id="inputGroupPrepend">@</span>
<input type="text" class="form-control" id="validationCustomUsername" aria-describedby="inputGroupPrepend" required>
</div>
</div>
<div class="col-md-6">
- <label for="validationCustom03">City</label>
+ <label for="validationCustom03" class="form-label">City</label>
<input type="text" class="form-control" id="validationCustom03" required>
<div class="invalid-feedback">
Please provide a valid city.
</div>
</div>
<div class="col-md-3">
- <label for="validationCustom04">State</label>
+ <label for="validationCustom04" class="form-label">State</label>
<select class="form-select" id="validationCustom04" required>
<option selected disabled value="">Choose...</option>
<option>...</option>
</div>
</div>
<div class="col-md-3">
- <label for="validationCustom05">Zip</label>
+ <label for="validationCustom05" class="form-label">Zip</label>
<input type="text" class="form-control" id="validationCustom05" required>
<div class="invalid-feedback">
Please provide a valid zip.
{{< example >}}
<form class="row g-3">
<div class="col-md-4">
- <label for="validationDefault01">First name</label>
+ <label for="validationDefault01" class="form-label">First name</label>
<input type="text" class="form-control" id="validationDefault01" value="Mark" required>
</div>
<div class="col-md-4">
- <label for="validationDefault02">Last name</label>
+ <label for="validationDefault02" class="form-label">Last name</label>
<input type="text" class="form-control" id="validationDefault02" value="Otto" required>
</div>
<div class="col-md-4">
- <label for="validationDefaultUsername">Username</label>
+ <label for="validationDefaultUsername" class="form-label">Username</label>
<div class="input-group">
<span class="input-group-text" id="inputGroupPrepend2">@</span>
<input type="text" class="form-control" id="validationDefaultUsername" aria-describedby="inputGroupPrepend2" required>
</div>
</div>
<div class="col-md-6">
- <label for="validationDefault03">City</label>
+ <label for="validationDefault03" class="form-label">City</label>
<input type="text" class="form-control" id="validationDefault03" required>
</div>
<div class="col-md-3">
- <label for="validationDefault04">State</label>
+ <label for="validationDefault04" class="form-label">State</label>
<select class="form-select" id="validationDefault04" required>
<option selected disabled value="">Choose...</option>
<option>...</option>
</select>
</div>
<div class="col-md-3">
- <label for="validationDefault05">Zip</label>
+ <label for="validationDefault05" class="form-label">Zip</label>
<input type="text" class="form-control" id="validationDefault05" required>
</div>
<div class="col-12">
{{< example >}}
<form class="row g-3">
<div class="col-md-4">
- <label for="validationServer01">First name</label>
+ <label for="validationServer01" class="form-label">First name</label>
<input type="text" class="form-control is-valid" id="validationServer01" value="Mark" required>
<div class="valid-feedback">
Looks good!
</div>
</div>
<div class="col-md-4">
- <label for="validationServer02">Last name</label>
+ <label for="validationServer02" class="form-label">Last name</label>
<input type="text" class="form-control is-valid" id="validationServer02" value="Otto" required>
<div class="valid-feedback">
Looks good!
</div>
</div>
<div class="col-md-4">
- <label for="validationServerUsername">Username</label>
+ <label for="validationServerUsername" class="form-label">Username</label>
<div class="input-group">
<span class="input-group-text" id="inputGroupPrepend3">@</span>
<input type="text" class="form-control is-invalid" id="validationServerUsername" aria-describedby="inputGroupPrepend3" required>
</div>
</div>
<div class="col-md-6">
- <label for="validationServer03">City</label>
+ <label for="validationServer03" class="form-label">City</label>
<input type="text" class="form-control is-invalid" id="validationServer03" required>
<div class="invalid-feedback">
Please provide a valid city.
</div>
</div>
<div class="col-md-3">
- <label for="validationServer04">State</label>
+ <label for="validationServer04" class="form-label">State</label>
<select class="form-select is-invalid" id="validationServer04" required>
<option selected disabled value="">Choose...</option>
<option>...</option>
</div>
</div>
<div class="col-md-3">
- <label for="validationServer05">Zip</label>
+ <label for="validationServer05" class="form-label">Zip</label>
<input type="text" class="form-control is-invalid" id="validationServer05" required>
<div class="invalid-feedback">
Please provide a valid zip.
{{< example >}}
<form class="was-validated">
<div class="mb-3">
- <label for="validationTextarea">Textarea</label>
+ <label for="validationTextarea" class="form-label">Textarea</label>
<textarea class="form-control is-invalid" id="validationTextarea" placeholder="Required example textarea" required></textarea>
<div class="invalid-feedback">
Please enter a message in the textarea.
{{< example >}}
<form class="row g-3 needs-validation" novalidate>
<div class="col-md-4 position-relative">
- <label for="validationTooltip01">First name</label>
+ <label for="validationTooltip01" class="form-label">First name</label>
<input type="text" class="form-control" id="validationTooltip01" value="Mark" required>
<div class="valid-tooltip">
Looks good!
</div>
</div>
<div class="col-md-4 position-relative">
- <label for="validationTooltip02">Last name</label>
+ <label for="validationTooltip02" class="form-label">Last name</label>
<input type="text" class="form-control" id="validationTooltip02" value="Otto" required>
<div class="valid-tooltip">
Looks good!
</div>
</div>
<div class="col-md-4 position-relative">
- <label for="validationTooltipUsername">Username</label>
+ <label for="validationTooltipUsername" class="form-label">Username</label>
<div class="input-group">
<span class="input-group-text" id="validationTooltipUsernamePrepend">@</span>
<input type="text" class="form-control" id="validationTooltipUsername" aria-describedby="validationTooltipUsernamePrepend" required>
</div>
</div>
<div class="col-md-6 position-relative">
- <label for="validationTooltip03">City</label>
+ <label for="validationTooltip03" class="form-label">City</label>
<input type="text" class="form-control" id="validationTooltip03" required>
<div class="invalid-tooltip">
Please provide a valid city.
</div>
</div>
<div class="col-md-3 position-relative">
- <label for="validationTooltip04">State</label>
+ <label for="validationTooltip04" class="form-label">State</label>
<select class="form-select" id="validationTooltip04" required>
<option selected disabled value="">Choose...</option>
<option>...</option>
</div>
</div>
<div class="col-md-3 position-relative">
- <label for="validationTooltip05">Zip</label>
+ <label for="validationTooltip05" class="form-label">Zip</label>
<input type="text" class="form-control" id="validationTooltip05" required>
<div class="invalid-tooltip">
Please provide a valid zip.
- Dropped support for `.form-control-plaintext` inside `.input-group`s.
- Dropped `.form-text` as existing utilities cover this use class's former use case (e.g., `.mt-2`, `.text-small`, and/or `.text-muted`).
- Dropped `.input-group-append` and `.input-group-prepend`. You can now just add buttons and `.input-group-text` as direct children of the input groups.
+- Form labels now require the `.form-label` class. Sass variables are now available to style form labels to your needs. [See #30476](https://github.com/twbs/bootstrap/pull/30476)
## Components