{% extends 'base.html.twig' %} {% block title %}Badge - Design System - Bubul{% endblock %} {% block body %}
Le composant Badge est utilisé pour afficher des statuts, des catégories ou des compteurs. Idéal pour les tableaux, les cartes et les listes.
{% verbatim %}{# Utilisation basique #}
{% include '_atoms/badge/badge.html.twig' with {
label: 'Nouveau'
} %}
{# Avec variante et dot #}
{% include '_atoms/badge/badge.html.twig' with {
label: 'Actif',
variant: 'success',
dot: true
} %}{% endverbatim %}
templates/_atoms/badge/badge.html.twig
Paramètre : variant
| Variante | Utilisation |
|---|---|
primary | Actions principales, liens |
success | Actif, validé, terminé |
warning | En attente, attention requise |
error | Erreur, inactif, bloqué |
info | Information, note |
cohorts | Cohortes, groupes, tags |
neutral | Défaut, catégorie générique |
dark | Emphase forte |
white | Sur fonds sombres ou colores |
Paramètre : size
| Taille | Hauteur | Font |
|---|---|---|
xs | 20px | 12px |
sm | 24px | 12px |
md | 28px | 14px |
lg | 32px | 14px |
Paramètre : dot: true
Idéal pour les statuts de connexion, états de publication, disponibilité.
{% verbatim %}{% include '_atoms/badge/badge.html.twig' with {
label: 'En ligne',
variant: 'success',
dot: true
} %}{% endverbatim %}
Paramètre : icon
{% verbatim %}{% include '_atoms/badge/badge.html.twig' with {
label: 'Validé',
variant: 'success',
icon: 'check'
} %}{% endverbatim %}
Paramètre : count
{% verbatim %}{% include '_atoms/badge/badge.html.twig' with {
label: 'Messages',
variant: 'primary',
count: 5
} %}{% endverbatim %}
Paramètre : outline: true
Version plus légère, idéale quand le badge ne doit pas trop attirer l'attention.
Paramètre : variant: 'white'
Ideal sur les fonds sombres ou colores. Fond blanc, bordure grise, texte gris fonce.
{% verbatim %}{% include '_atoms/badge/badge.html.twig' with {
label: 'White badge',
variant: 'white'
} %}{% endverbatim %}
Paramètres : dot: true, pulse: true
Le dot pulse en utilisant animate-ping de Tailwind. Nécessite dot: true.
{% verbatim %}{% include '_atoms/badge/badge.html.twig' with {
label: 'En ligne',
variant: 'success',
dot: true,
pulse: true
} %}{% endverbatim %}
Paramètre : dotVariant
Utile quand le badge est neutre mais que le statut doit avoir une couleur specifique.
{% verbatim %}{% include '_atoms/badge/badge.html.twig' with {
label: 'En cours',
variant: 'neutral',
dot: true,
dotVariant: 'warning'
} %}{% endverbatim %}
Paramètre : customColor: '#309344'
Override complet de la variante. Le fond est la couleur a 6% d'opacite (color + '0f'),
la bordure a 16% (color + '28'), et le texte a la couleur pleine.
Utile pour les couleurs provenant de la base de donnees (tool_color_details).
{% verbatim %}{% include '_atoms/badge/badge.html.twig' with {
label: 'Feature label',
customColor: '#309344'
} %}
{# Avec couleur dynamique depuis DB #}
{% set toolColor = tool_color_details['castia'].primary ?? '#309344' %}
{% include '_atoms/badge/badge.html.twig' with {
label: 'Creation flexible',
customColor: toolColor
} %}{% endverbatim %}
| Utilisateur | Rôle | Statut |
|---|---|---|
| Jean Dupont | {% include '_atoms/badge/badge.html.twig' with { label: 'Admin', variant: 'primary', size: 'sm' } %} | {% include '_atoms/badge/badge.html.twig' with { label: 'Actif', variant: 'success', dot: true, size: 'sm' } %} |
| Marie Martin | {% include '_atoms/badge/badge.html.twig' with { label: 'Utilisateur', variant: 'neutral', size: 'sm' } %} | {% include '_atoms/badge/badge.html.twig' with { label: 'En attente', variant: 'warning', dot: true, size: 'sm' } %} |
| Pierre Durand | {% include '_atoms/badge/badge.html.twig' with { label: 'Manager', variant: 'info', size: 'sm' } %} | {% include '_atoms/badge/badge.html.twig' with { label: 'Inactif', variant: 'error', dot: true, size: 'sm' } %} |
Apprenez React de A à Z avec ce cours complet.
| Paramètre | Type | Défaut | Options |
|---|---|---|---|
label |
string | '' |
Texte du badge |
variant |
string | 'neutral' |
primary, success, warning, error, info, cohorts, neutral, dark, white |
size |
string | 'md' |
xs, sm, md, lg |
dot |
bool | false |
Affiche un point de statut |
icon |
string | null |
Nom de l'icône (check, alert, etc.) |
count |
number | null |
Compteur affiché à droite |
outline |
bool | false |
Version bordure sans fond |
rounded |
string | 'full' |
sm, md, lg, full |
pulse |
bool | false |
Anime le dot avec animate-ping. Nécessite dot: true |
dotVariant |
string | null |
Override de la couleur du dot (primary, success, warning, error, info...) |
customColor |
string | null |
Couleur hex dynamique (ex: '#309344'). Override variant avec bg 6%, border 16% |
class |
string | '' |
Classes Tailwind additionnelles |