Formulaires
Choices
Voir la source de cette pageCases à cocher, boutons radio et listes déroulantes natives, redessinés en CSS. Les cases s'animent à la sélection.
Cases à cocher
Le label suit l'input dans .form-check. Les états cochée, vide et désactivée sont natifs
(checked, disabled).
HTML
<div class="form-check">
<input class="form-check-input" type="checkbox" id="check-1" checked>
<label class="form-check-label" for="check-1">Option cochée</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="check-2">
<label class="form-check-label" for="check-2">Option non cochée</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="check-3" disabled>
<label class="form-check-label" for="check-3">Option désactivée</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="check-4" checked disabled>
<label class="form-check-label" for="check-4">Option cochée et désactivée</label>
</div>
Boutons radio
HTML
<div class="form-check">
<input class="form-check-input" type="radio" name="radio-demo" id="radio-1" checked>
<label class="form-check-label" for="radio-1">Livraison standard</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="radio-demo" id="radio-2">
<label class="form-check-label" for="radio-2">Livraison express</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="radio-demo" id="radio-3" disabled>
<label class="form-check-label" for="radio-3">Retrait en magasin (indisponible)</label>
</div>
Avec description
Un .text-muted dans le label s'affiche en sous-texte, sous l'intitulé.
HTML
<div class="form-check">
<input class="form-check-input" type="checkbox" id="check-notify" checked>
<label class="form-check-label" for="check-notify">
Notifications par email
<span class="text-muted">Recevez un récapitulatif chaque lundi matin.</span>
</label>
</div>
En ligne
Placez les .form-check dans un conteneur flex : l'espacement passe par gap.
HTML
<div class="d-flex flex-wrap gap-4">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="inline-1" checked>
<label class="form-check-label" for="inline-1">HTML</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="inline-2">
<label class="form-check-label" for="inline-2">CSS</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="inline-3">
<label class="form-check-label" for="inline-3">TypeScript</label>
</div>
</div>
Liste déroulante
.form-select remplace la flèche native par un chevron qui suit la couleur du thème.
HTML
<div>
<label for="select-country" class="form-label">Pays</label>
<select class="form-select" id="select-country">
<option selected>Choisissez un pays…</option>
<option value="fr">France</option>
<option value="be">Belgique</option>
<option value="ch">Suisse</option>
</select>
</div>
Tailles et état désactivé
HTML
<select class="form-select form-select-sm" aria-label="Petite liste">
<option>.form-select-sm</option>
</select>
<select class="form-select" aria-label="Liste">
<option>Taille par défaut</option>
</select>
<select class="form-select form-select-lg" aria-label="Grande liste">
<option>.form-select-lg</option>
</select>
<select class="form-select" aria-label="Liste désactivée" disabled>
<option>Liste désactivée</option>
</select>
Personnalisation
| Token | Défaut | Rôle |
|---|---|---|
--check-size |
1.25em |
Taille de la case |
--check-bg |
transparent (--ds-color-primary cochée) |
Fond |
--check-border-color |
--ds-color-outline |
Bordure |
--check-mark-color |
--ds-color-on-primary |
Coche et point |
--select-indicator-color |
--ds-color-on-surface-variant |
Chevron du select |
Classes
| Classe | Description |
|---|---|
.form-check |
Ligne input + label |
.form-check-input |
Case à cocher ou radio |
.form-check-label |
Label (sous-texte avec .text-muted) |
.form-select |
Liste déroulante |
.form-select-sm, .form-select-lg |
Tailles 32px et 48px |