custom-control-input
bootstrap5.css
bootstrap5.css
.was-validated .custom-control-input:valid ~ .custom-control-label,
.custom-control-input.is-valid ~ .custom-control-label {
color: #28a745;
}
bootstrap5.css
.was-validated .custom-control-input:valid ~ .custom-control-label::before,
.custom-control-input.is-valid ~ .custom-control-label::before {
border-color: #28a745;
}
bootstrap5.css
.was-validated .custom-control-input:valid ~ .valid-feedback,
.was-validated .custom-control-input:valid ~ .valid-tooltip,
.custom-control-input.is-valid ~ .valid-feedback,
.custom-control-input.is-valid ~ .valid-tooltip {
display: block;
}
bootstrap5.css
.was-validated .custom-control-input:valid:checked ~ .custom-control-label::before,
.custom-control-input.is-valid:checked ~ .custom-control-label::before {
border-color: #34ce57;
background-color: #34ce57;
}
bootstrap5.css
.was-validated .custom-control-input:valid:focus ~ .custom-control-label::before,
.custom-control-input.is-valid:focus ~ .custom-control-label::before {
box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}
bootstrap5.css
.was-validated .custom-control-input:valid:focus:not(:checked) ~ .custom-control-label::before,
.custom-control-input.is-valid:focus:not(:checked) ~ .custom-control-label::before {
border-color: #28a745;
}
bootstrap5.css
.was-validated .custom-control-input:invalid ~ .custom-control-label,
.custom-control-input.is-invalid ~ .custom-control-label {
color: #dc3545;
}
bootstrap5.css
.was-validated .custom-control-input:invalid ~ .custom-control-label::before,
.custom-control-input.is-invalid ~ .custom-control-label::before {
border-color: #dc3545;
}
bootstrap5.css
.was-validated .custom-control-input:invalid ~ .invalid-feedback,
.was-validated .custom-control-input:invalid ~ .invalid-tooltip,
.custom-control-input.is-invalid ~ .invalid-feedback,
.custom-control-input.is-invalid ~ .invalid-tooltip {
display: block;
}
bootstrap5.css
.was-validated .custom-control-input:invalid:checked ~ .custom-control-label::before,
.custom-control-input.is-invalid:checked ~ .custom-control-label::before {
border-color: #e4606d;
background-color: #e4606d;
}
bootstrap5.css
.was-validated .custom-control-input:invalid:focus ~ .custom-control-label::before,
.custom-control-input.is-invalid:focus ~ .custom-control-label::before {
box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}
bootstrap5.css
.was-validated .custom-control-input:invalid:focus:not(:checked) ~ .custom-control-label::before,
.custom-control-input.is-invalid:focus:not(:checked) ~ .custom-control-label::before {
border-color: #dc3545;
}
bootstrap5.css
.custom-control-input {
position: absolute;
z-index: -1;
opacity: 0;
}
bootstrap5.css
.custom-control-input:checked ~ .custom-control-label::before {
color: #fff;
border-color: #007bff;
background-color: #007bff;
}
bootstrap5.css
.custom-control-input:focus ~ .custom-control-label::before {
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}
bootstrap5.css
.custom-control-input:focus:not(:checked) ~ .custom-control-label::before {
border-color: #80bdff;
}
bootstrap5.css
.custom-control-input:not(:disabled):active ~ .custom-control-label::before {
color: #fff;
background-color: #b3d7ff;
border-color: #b3d7ff;
}
bootstrap5.css
.custom-control-input:disabled ~ .custom-control-label {
color: #6c757d;
}
bootstrap5.css
.custom-control-input:disabled ~ .custom-control-label::before {
background-color: #e9ecef;
}
bootstrap5.css
.custom-checkbox .custom-control-input:indeterminate ~ .custom-control-label::before {
border-color: #007bff;
background-color: #007bff;
}
bootstrap5.css
.custom-checkbox .custom-control-input:disabled:checked ~ .custom-control-label::before {
background-color: rgba(0, 123, 255, 0.5);
}
bootstrap5.css
.custom-checkbox .custom-control-input:disabled:indeterminate ~ .custom-control-label::before {
background-color: rgba(0, 123, 255, 0.5);
}
bootstrap5.css
.custom-radio .custom-control-input:disabled:checked ~ .custom-control-label::before {
background-color: rgba(0, 123, 255, 0.5);
}
bootstrap5.css
.custom-switch .custom-control-input:checked ~ .custom-control-label::after {
background-color: #fff;
-webkit-transform: translateX(0.75rem);
transform: translateX(0.75rem);
}
bootstrap5.css
.custom-switch .custom-control-input:disabled:checked ~ .custom-control-label::before {
background-color: rgba(0, 123, 255, 0.5);
}
html bootstrap5 Sample
カスタムのチェックボックスに不確定を指定する:indeterminate
<form>
<!-- カスタムフォームのチェックボックス -->
<div class="custom-control custom-checkbox mb-3">
<input type="checkbox" class="custom-control-input" id="checkbox08" checked>
<label class="custom-control-label" for="checkbox08">選択済み</label>
</div>
<div class="custom-control custom-checkbox mb-3">
<input type="checkbox" class="custom-control-input" id="checkbox09" unchecked>
<label class="custom-control-label" for="checkbox09">未選択</label>
</div>
<div class="custom-control custom-checkbox mb-3">
<input type="checkbox" class="custom-control-input indeterminate-box" id="checkbox10">
<label class="custom-control-label" for="checkbox10">不確定</label>
</div>
</form>
カスタムのチェックボックスとラジオボタンを無効にする
<form>
<!-- チェックボックスを無効にする -->
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="checkbox11" disabled>
<label class="custom-control-label" for="checkbox11">
チェック(無効)
</label>
</div>
<!-- ラジオボタンを無効にする -->
<div class="custom-control custom-radio">
<input type="radio" name="radioDisabled" id="checkbox12" class="custom-control-input" disabled>
<label class="custom-control-label" for="checkbox12">
オプション(無効)
</label>
</div>
</form>
カスタムのチェックボックスとラジオボタンを作成する:custom-checkboxとcustom-radio
<form>
<!-- カスタムフォームのチェックボックス -->
<div class="custom-control custom-checkbox mb-3">
<input type="checkbox" class="custom-control-input" id="checkbox13">
<label class="custom-control-label" for="checkbox13">チェックする</label>
</div>
<!-- カスタムフォームのラジオボタン -->
<div class="custom-control custom-radio">
<input type="radio" id="option1" name="option" class="custom-control-input">
<label class="custom-control-label" for="option1">オプション1</label>
</div>
<div class="custom-control custom-radio">
<input type="radio" id="option2" name="option" class="custom-control-input">
<label class="custom-control-label" for="option2">オプション2</label>
</div>
</form>