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

Checkbox

Cases à cocher personnalisées

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

Usage

Le composant Checkbox permet de créer des cases à cocher accessibles et personnalisées. Il supporte les labels, hints, erreurs et plusieurs tailles.

{% verbatim %}{# Checkbox simple #}
{% include '_atoms/form/checkbox.html.twig' with {
    label: 'Se souvenir de moi',
    name: 'remember_me'
} %}

{# Avec hint #}
{% include '_atoms/form/checkbox.html.twig' with {
    label: 'Recevoir la newsletter',
    hint: 'Un email par semaine maximum',
    checked: true
} %}{% endverbatim %}
Fichier : templates/_atoms/form/checkbox.html.twig
{# ===== BASIQUE ===== #}

Exemples de base

{% include '_atoms/form/checkbox.html.twig' with { label: 'Option non cochée' } %} {% include '_atoms/form/checkbox.html.twig' with { label: 'Option cochée', checked: true } %} {% include '_atoms/form/checkbox.html.twig' with { label: 'Avec description', hint: 'Texte explicatif pour aider l\'utilisateur' } %}
{# ===== TAILLES ===== #}

Tailles

Paramètre : size

{% include '_atoms/form/checkbox.html.twig' with { label: 'Small (sm)', size: 'sm', checked: true } %} {% include '_atoms/form/checkbox.html.twig' with { label: 'Medium (md) - défaut', size: 'md', checked: true } %} {% include '_atoms/form/checkbox.html.twig' with { label: 'Large (lg)', size: 'lg', checked: true } %}
Taille Checkbox Label
sm16px14px
md20px16px
lg24px18px
{# ===== VARIANTES ===== #}

Variantes

Paramètre : variant

Default

{% include '_atoms/form/checkbox.html.twig' with { label: 'Checkbox par défaut', variant: 'default' } %} {% include '_atoms/form/checkbox.html.twig' with { label: 'Avec description', variant: 'default', hint: 'Description additionnelle' } %}

Card

{% include '_atoms/form/checkbox.html.twig' with { label: 'Option premium', variant: 'card', hint: 'Accès à toutes les fonctionnalités avancées' } %} {% include '_atoms/form/checkbox.html.twig' with { label: 'Notifications email', variant: 'card', hint: 'Recevez les mises à jour par email', checked: true } %}
{% verbatim %}{% include '_atoms/form/checkbox.html.twig' with {
    label: 'Option premium',
    variant: 'card',
    hint: 'Accès à toutes les fonctionnalités'
} %}{% endverbatim %}
{# ===== ÉTATS ===== #}

États

{% include '_atoms/form/checkbox.html.twig' with { label: 'Non coché' } %} {% include '_atoms/form/checkbox.html.twig' with { label: 'Coché', checked: true } %} {% include '_atoms/form/checkbox.html.twig' with { label: 'Obligatoire', required: true } %} {% include '_atoms/form/checkbox.html.twig' with { label: 'Avec erreur', error: 'Vous devez accepter les conditions' } %} {% include '_atoms/form/checkbox.html.twig' with { label: 'Désactivé', disabled: true } %} {% include '_atoms/form/checkbox.html.twig' with { label: 'Désactivé et coché', disabled: true, checked: true } %}
{# ===== GROUPES ===== #}

Groupes de checkboxes

{# Groupe vertical #}

Notifications

{% include '_atoms/form/checkbox.html.twig' with { label: 'Email', name: 'notif[]', value: 'email', checked: true } %} {% include '_atoms/form/checkbox.html.twig' with { label: 'SMS', name: 'notif[]', value: 'sms' } %} {% include '_atoms/form/checkbox.html.twig' with { label: 'Push mobile', name: 'notif[]', value: 'push', checked: true } %} {% include '_atoms/form/checkbox.html.twig' with { label: 'In-app', name: 'notif[]', value: 'inapp' } %}
{# Groupe avec cards #}

Fonctionnalités

{% include '_atoms/form/checkbox.html.twig' with { label: 'Analytics', variant: 'card', hint: 'Statistiques avancées', checked: true } %} {% include '_atoms/form/checkbox.html.twig' with { label: 'Export PDF', variant: 'card', hint: 'Téléchargez vos rapports' } %} {% include '_atoms/form/checkbox.html.twig' with { label: 'API Access', variant: 'card', hint: 'Intégrations tierces' } %}
{# ===== EXEMPLE FORMULAIRE ===== #}

Exemple dans un formulaire

{% include '_atoms/form/input.html.twig' with { label: 'Nom', type: 'text', placeholder: 'Votre nom', required: true } %} {% include '_atoms/form/input.html.twig' with { label: 'Email', type: 'email', placeholder: 'votre@email.com', required: true } %}
{% include '_atoms/form/checkbox.html.twig' with { label: 'Se souvenir de moi', name: 'remember' } %} {% include '_atoms/form/checkbox.html.twig' with { label: 'J\'accepte les conditions d\'utilisation', name: 'terms', required: true, hint: 'Vous devez accepter pour continuer' } %} {% include '_atoms/form/checkbox.html.twig' with { label: 'Recevoir la newsletter', name: 'newsletter', hint: 'Un email par semaine maximum' } %}
{% include '_atoms/button/button.html.twig' with { label: 'Créer mon compte', variant: 'primary', type: 'submit' } %}
{# ===== PARAMÈTRES ===== #}

Référence des paramètres

Paramètre Type Défaut Description
label string null Texte du label
checked bool false État coché
name string null Attribut name
value string '1' Valeur quand coché
size string 'md' sm, md, lg
variant string 'default' default, card
disabled bool false Désactivé
required bool false Obligatoire
error string null Message d'erreur
hint string null Texte d'aide
{% endblock %}