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

Select

Menus déroulants personnalisés

{# ===== USAGE ===== #}

Usage

{% verbatim %}{% include '_atoms/form/select.html.twig' with {
    label: 'Pays',
    placeholder: 'Sélectionnez un pays',
    options: [
        {value: 'fr', label: 'France'},
        {value: 'be', label: 'Belgique'}
    ],
    value: 'fr'
} %}{% endverbatim %}

Fichier : templates/_atoms/form/select.html.twig

{# ===== EXEMPLES ===== #}

Exemples

{% include '_atoms/form/select.html.twig' with { label: 'Pays', placeholder: 'Sélectionnez un pays', options: [ {value: 'fr', label: 'France'}, {value: 'be', label: 'Belgique'}, {value: 'ch', label: 'Suisse'}, {value: 'ca', label: 'Canada'} ] } %} {% include '_atoms/form/select.html.twig' with { label: 'Statut', value: 'active', options: [ {value: 'active', label: 'Actif'}, {value: 'pending', label: 'En attente'}, {value: 'inactive', label: 'Inactif'} ] } %} {% include '_atoms/form/select.html.twig' with { label: 'Rôle', required: true, placeholder: 'Choisir un rôle', options: [ {value: 'admin', label: 'Administrateur'}, {value: 'user', label: 'Utilisateur'}, {value: 'guest', label: 'Invité', disabled: true} ], hint: 'Le rôle détermine les permissions' } %} {% include '_atoms/form/select.html.twig' with { label: 'Avec erreur', placeholder: 'Sélectionnez...', options: [ {value: '1', label: 'Option 1'}, {value: '2', label: 'Option 2'} ], error: 'Ce champ est obligatoire' } %}
{# ===== TAILLES ===== #}

Tailles

{% set demoOptions = [{value: '1', label: 'Option 1'}, {value: '2', label: 'Option 2'}] %} {% include '_atoms/form/select.html.twig' with { label: 'Small (sm)', size: 'sm', options: demoOptions, value: '1' } %} {% include '_atoms/form/select.html.twig' with { label: 'Medium (md)', size: 'md', options: demoOptions, value: '1' } %} {% include '_atoms/form/select.html.twig' with { label: 'Large (lg)', size: 'lg', options: demoOptions, value: '1' } %}
{# ===== ÉTATS ===== #}

États

{% set demoOptions = [{value: '1', label: 'Option 1'}, {value: '2', label: 'Option 2'}] %} {% include '_atoms/form/select.html.twig' with { label: 'Normal', options: demoOptions } %} {% include '_atoms/form/select.html.twig' with { label: 'Désactivé', options: demoOptions, value: '1', disabled: true } %} {% include '_atoms/form/select.html.twig' with { label: 'Avec erreur', options: demoOptions, error: 'Sélection invalide' } %}
{# ===== PARAMÈTRES ===== #}

Paramètres

Paramètre Type Description
optionsarray[{value, label, disabled?}]
valuestringValeur sélectionnée
placeholderstringOption placeholder
labelstringLabel du select
sizestringsm, md, lg
disabledboolDésactivé
errorstringMessage d'erreur
hintstringTexte d'aide
{% endblock %}