Contenu
Table
Voir la source de cette pageTableaux de données aérés : séparateurs discrets, en-tête sur une surface relevée et variantes survol, zébrée, bordée ou sans bordure.
Exemple
| Nom | Rôle | |
|---|---|---|
| Alice Martin | alice@example.com | Administratrice |
| Bruno Petit | bruno@example.com | Éditeur |
| Chloé Durand | chloe@example.com | Lectrice |
HTML
<table class="table">
<thead>
<tr>
<th scope="col">Nom</th>
<th scope="col">Email</th>
<th scope="col">Rôle</th>
</tr>
</thead>
<tbody>
<tr>
<td>Alice Martin</td>
<td>alice@example.com</td>
<td>Administratrice</td>
</tr>
<tr>
<td>Bruno Petit</td>
<td>bruno@example.com</td>
<td>Éditeur</td>
</tr>
<tr>
<td>Chloé Durand</td>
<td>chloe@example.com</td>
<td>Lectrice</td>
</tr>
</tbody>
</table>
En-tête clair
.table-light sur le <thead> : fond relevé et intitulés en petites capitales.
| Nom | Rôle |
|---|---|
| Alice Martin | Administratrice |
| Bruno Petit | Éditeur |
| Chloé Durand | Lectrice |
HTML
<table class="table">
<thead class="table-light">
<tr>
<th scope="col">Nom</th>
<th scope="col">Rôle</th>
</tr>
</thead>
<tbody>
<tr>
<td>Alice Martin</td>
<td>Administratrice</td>
</tr>
<tr>
<td>Bruno Petit</td>
<td>Éditeur</td>
</tr>
<tr>
<td>Chloé Durand</td>
<td>Lectrice</td>
</tr>
</tbody>
</table>
Survol
.table-hover ajoute un calque d'état sur la ligne survolée.
| Alice Martin | alice@example.com |
| Bruno Petit | bruno@example.com |
| Chloé Durand | chloe@example.com |
HTML
<table class="table table-hover">
<tbody>
<tr>
<td>Alice Martin</td>
<td>alice@example.com</td>
</tr>
<tr>
<td>Bruno Petit</td>
<td>bruno@example.com</td>
</tr>
<tr>
<td>Chloé Durand</td>
<td>chloe@example.com</td>
</tr>
</tbody>
</table>
Lignes zébrées
| Alice Martin | Administratrice |
| Bruno Petit | Éditeur |
| Chloé Durand | Lectrice |
HTML
<table class="table table-striped">
<tbody>
<tr>
<td>Alice Martin</td>
<td>Administratrice</td>
</tr>
<tr>
<td>Bruno Petit</td>
<td>Éditeur</td>
</tr>
<tr>
<td>Chloé Durand</td>
<td>Lectrice</td>
</tr>
</tbody>
</table>
Bordures
.table-bordered encadre chaque cellule ; .table-borderless retire tous les séparateurs.
| Alice Martin | Administratrice |
| Bruno Petit | Éditeur |
| Alice Martin | Administratrice |
| Bruno Petit | Éditeur |
HTML
<table class="table table-bordered">
<tbody>
<tr>
<td>Alice Martin</td>
<td>Administratrice</td>
</tr>
<tr>
<td>Bruno Petit</td>
<td>Éditeur</td>
</tr>
</tbody>
</table>
<table class="table table-borderless">
<tbody>
<tr>
<td>Alice Martin</td>
<td>Administratrice</td>
</tr>
<tr>
<td>Bruno Petit</td>
<td>Éditeur</td>
</tr>
</tbody>
</table>
Alignement vertical
Les cellules sont alignées en haut ; .align-middle sur la table les centre verticalement.
|
A
Alice Martin
alice@example.com
|
Actif | |
|
B
Bruno Petit
bruno@example.com
|
Actif |
HTML
<table class="table align-middle">
<tbody>
<tr>
<td>
<div class="d-flex align-items-center gap-3">
<div class="avatar avatar-sm">A</div>
<div>
<div class="fw-semibold">Alice Martin</div>
<small class="text-muted">alice@example.com</small>
</div>
</div>
</td>
<td><span class="badge badge-success">Actif</span></td>
<td class="text-end">
<button type="button" class="btn btn-icon btn-sm btn-ghost-secondary" aria-label="Modifier"><i class="ri-edit-line"></i></button>
<button type="button" class="btn btn-icon btn-sm btn-ghost-danger" aria-label="Supprimer"><i class="ri-delete-bin-line"></i></button>
</td>
</tr>
<tr>
<td>
<div class="d-flex align-items-center gap-3">
<div class="avatar avatar-sm">B</div>
<div>
<div class="fw-semibold">Bruno Petit</div>
<small class="text-muted">bruno@example.com</small>
</div>
</div>
</td>
<td><span class="badge badge-success">Actif</span></td>
<td class="text-end">
<button type="button" class="btn btn-icon btn-sm btn-ghost-secondary" aria-label="Modifier"><i class="ri-edit-line"></i></button>
<button type="button" class="btn btn-icon btn-sm btn-ghost-danger" aria-label="Supprimer"><i class="ri-delete-bin-line"></i></button>
</td>
</tr>
</tbody>
</table>
Défilement horizontal
Enveloppez la table dans .table-responsive : elle défile au lieu de déborder sur petit écran.
| Colonne 1 | Colonne 2 | Colonne 3 | Colonne 4 | Colonne 5 | Colonne 6 | Colonne 7 | Colonne 8 | Colonne 9 | Colonne 10 |
|---|---|---|---|---|---|---|---|---|---|
| Valeur 1 | Valeur 2 | Valeur 3 | Valeur 4 | Valeur 5 | Valeur 6 | Valeur 7 | Valeur 8 | Valeur 9 | Valeur 10 |
HTML
<div class="table-responsive">
<table class="table text-nowrap">
<thead class="table-light">
<tr>
<th scope="col">Colonne 1</th>
<th scope="col">Colonne 2</th>
<th scope="col">Colonne 3</th>
<th scope="col">Colonne 4</th>
<th scope="col">Colonne 5</th>
<th scope="col">Colonne 6</th>
<th scope="col">Colonne 7</th>
<th scope="col">Colonne 8</th>
<th scope="col">Colonne 9</th>
<th scope="col">Colonne 10</th>
</tr>
</thead>
<tbody>
<tr>
<td>Valeur 1</td>
<td>Valeur 2</td>
<td>Valeur 3</td>
<td>Valeur 4</td>
<td>Valeur 5</td>
<td>Valeur 6</td>
<td>Valeur 7</td>
<td>Valeur 8</td>
<td>Valeur 9</td>
<td>Valeur 10</td>
</tr>
</tbody>
</table>
</div>
Personnalisation
Pour une table compacte, réduisez le padding des cellules :
| Alice Martin | Administratrice |
| Bruno Petit | Éditeur |
| Chloé Durand | Lectrice |
HTML
<table class="table" style="--table-cell-py: var(--ds-space-2); --table-cell-px: var(--ds-space-3);">
<tbody>
<tr>
<td>Alice Martin</td>
<td>Administratrice</td>
</tr>
<tr>
<td>Bruno Petit</td>
<td>Éditeur</td>
</tr>
<tr>
<td>Chloé Durand</td>
<td>Lectrice</td>
</tr>
</tbody>
</table>
| Token | Défaut | Rôle |
|---|---|---|
--table-color |
--ds-color-on-surface |
Texte |
--table-border-color |
--ds-color-outline-variant |
Séparateurs |
--table-cell-py |
--ds-space-4 |
Padding vertical des cellules |
--table-cell-px |
--ds-space-5 |
Padding horizontal des cellules |
Classes
| Classe | Description |
|---|---|
.table |
Table de base |
.table-light |
En-tête ou ligne sur fond relevé |
.table-hover |
Calque au survol des lignes |
.table-striped |
Lignes impaires teintées |
.table-bordered, .table-borderless |
Toutes les bordures, aucune bordure |
.align-middle |
Cellules centrées verticalement (sur .table) |
.table-responsive |
Conteneur à défilement horizontal |