{% extends 'base.html.twig' %} {% block title %}Badge - Design System - Bubul{% endblock %} {% block body %}
{# ===== HEADER ===== #}
Atomes /

Badge

Indicateurs visuels pour statuts et compteurs

{# ===== NAVIGATION RAPIDE ===== #} {# ===== USAGE ===== #}

Usage

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 %}
Fichier : templates/_atoms/badge/badge.html.twig
{# ===== VARIANTES ===== #}

Variantes

Paramètre : variant

{% include '_atoms/badge/badge.html.twig' with { label: 'Primary', variant: 'primary' } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Success', variant: 'success' } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Warning', variant: 'warning' } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Error', variant: 'error' } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Info', variant: 'info' } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Cohorts', variant: 'cohorts' } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Neutral', variant: 'neutral' } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Dark', variant: 'dark' } %}
{% include '_atoms/badge/badge.html.twig' with { label: 'White', variant: 'white' } %} Sur fond sombre
Variante Utilisation
primaryActions principales, liens
successActif, validé, terminé
warningEn attente, attention requise
errorErreur, inactif, bloqué
infoInformation, note
cohortsCohortes, groupes, tags
neutralDéfaut, catégorie générique
darkEmphase forte
whiteSur fonds sombres ou colores
{# ===== TAILLES ===== #}

Tailles

Paramètre : size

{% include '_atoms/badge/badge.html.twig' with { label: 'XS', variant: 'primary', size: 'xs' } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Small', variant: 'primary', size: 'sm' } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Medium', variant: 'primary', size: 'md' } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Large', variant: 'primary', size: 'lg' } %}
Taille Hauteur Font
xs20px12px
sm24px12px
md28px14px
lg32px14px
{# ===== DOTS ===== #}

Avec dot de statut

Paramètre : dot: true

{% include '_atoms/badge/badge.html.twig' with { label: 'En ligne', variant: 'success', dot: true } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Absent', variant: 'neutral', dot: true } %} {% include '_atoms/badge/badge.html.twig' with { label: 'En attente', variant: 'warning', dot: true } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Hors ligne', variant: 'error', dot: true } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Cohorte A', variant: 'cohorts', 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 %}
{# ===== ICÔNES ===== #}

Avec icônes

Paramètre : icon

{% include '_atoms/badge/badge.html.twig' with { label: 'Validé', variant: 'success', icon: 'check' } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Attention', variant: 'warning', icon: 'alert-triangle' } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Erreur', variant: 'error', icon: 'x' } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Info', variant: 'info', icon: 'info' } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Favori', variant: 'primary', icon: 'star' } %}
{% verbatim %}{% include '_atoms/badge/badge.html.twig' with {
    label: 'Validé',
    variant: 'success',
    icon: 'check'
} %}{% endverbatim %}
{# ===== COMPTEURS ===== #}

Avec compteur

Paramètre : count

{% include '_atoms/badge/badge.html.twig' with { label: 'Messages', variant: 'primary', count: 5 } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Notifications', variant: 'error', count: 12 } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Tâches', variant: 'warning', count: 3 } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Utilisateurs', variant: 'success', icon: 'users', count: 42 } %}
{% verbatim %}{% include '_atoms/badge/badge.html.twig' with {
    label: 'Messages',
    variant: 'primary',
    count: 5
} %}{% endverbatim %}
{# ===== OUTLINE ===== #}

Variantes Outline

Paramètre : outline: true

{% include '_atoms/badge/badge.html.twig' with { label: 'Primary', variant: 'primary', outline: true } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Success', variant: 'success', outline: true } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Warning', variant: 'warning', outline: true } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Error', variant: 'error', outline: true } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Info', variant: 'info', outline: true } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Cohorts', variant: 'cohorts', outline: true } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Neutral', variant: 'neutral', outline: true } %}

Version plus légère, idéale quand le badge ne doit pas trop attirer l'attention.

{# ===== VARIANTE WHITE ===== #}

Variante White

Paramètre : variant: 'white'

{% include '_atoms/badge/badge.html.twig' with { label: 'White badge', variant: 'white' } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Avec dot', variant: 'white', dot: true } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Avec icone', variant: 'white', icon: 'star' } %}

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 %}
{# ===== PULSE DOT ===== #}

Dot animé (pulse)

Paramètres : dot: true, pulse: true

{% include '_atoms/badge/badge.html.twig' with { label: 'En ligne', variant: 'success', dot: true, pulse: true } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Live', variant: 'error', dot: true, pulse: true } %} {% include '_atoms/badge/badge.html.twig' with { label: 'En attente', variant: 'warning', dot: true, pulse: true } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Actif', variant: 'primary', 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 %}
{# ===== DOT VARIANT ===== #}

dotVariant — Override couleur du dot

Paramètre : dotVariant

{% include '_atoms/badge/badge.html.twig' with { label: 'En cours', variant: 'neutral', dot: true, dotVariant: 'warning' } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Actif', variant: 'neutral', dot: true, dotVariant: 'success' } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Erreur', variant: 'neutral', dot: true, dotVariant: 'error' } %}

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 %}
{# ===== CUSTOM COLOR ===== #}

customColor — Couleur dynamique

Paramètre : customColor: '#309344'

{% include '_atoms/badge/badge.html.twig' with { label: 'Vert Castia', customColor: '#309344' } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Rose Slidia', customColor: '#E91E8C' } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Orange Monalisia', customColor: '#ED8600' } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Avec dot', customColor: '#0C81E4', dot: true } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Avec pulse', customColor: '#309344', dot: true, pulse: true } %}

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 %}
{# ===== EXEMPLES CONCRETS ===== #}

Exemples concrets

{# Exemple tableau #}

Dans un tableau

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' } %}
{# Exemple carte #}

Dans une carte

Formation React

{% include '_atoms/badge/badge.html.twig' with { label: 'Nouveau', variant: 'primary', size: 'xs' } %}

Apprenez React de A à Z avec ce cours complet.

{% include '_atoms/badge/badge.html.twig' with { label: 'JavaScript', variant: 'neutral', size: 'xs' } %} {% include '_atoms/badge/badge.html.twig' with { label: 'Frontend', variant: 'neutral', size: 'xs' } %} {% include '_atoms/badge/badge.html.twig' with { label: '12h', variant: 'info', size: 'xs' } %}
{# ===== PARAMÈTRES ===== #}

Référence des paramètres

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
{% endblock %}