{% extends 'base.html.twig' %} {% block title %}Button - Design System - Bubul{% endblock %} {% block body %}
Le composant Button est utilisé pour les actions principales et secondaires de l'interface. Il est 100% paramétrable via les attributs Twig.
{% verbatim %}{# Utilisation basique #}
{% include '_atoms/button/button.html.twig' with {
label: 'Mon bouton'
} %}
{# Avec options #}
{% include '_atoms/button/button.html.twig' with {
label: 'Enregistrer',
variant: 'success',
icon: 'check',
size: 'lg'
} %}{% endverbatim %}
templates/_atoms/button/button.html.twig
Paramètre : variant
variant: 'primary'
variant: 'secondary'
variant: 'success'
variant: 'error'
variant: 'warning'
variant: 'dark'
variant: 'outline'
variant: 'outline-dark'
variant: 'ghost'
variant: 'link'
Boutons avec fond léger, idéaux pour les colonnes d'actions.
variant: 'soft-primary'
variant: 'soft-success'
variant: 'soft-warning'
variant: 'soft-error'
| Nom | Actions | |
|---|---|---|
| Jean Dupont | jean@example.com |
{% include '_atoms/button/button.html.twig' with { icon: 'eye', iconOnly: true, variant: 'soft-primary', size: 'sm' } %}
{% include '_atoms/button/button.html.twig' with { icon: 'edit', iconOnly: true, variant: 'soft-warning', size: 'sm' } %}
{% include '_atoms/button/button.html.twig' with { icon: 'trash', iconOnly: true, variant: 'soft-error', size: 'sm' } %}
|
| Marie Martin | marie@example.com |
{% include '_atoms/button/button.html.twig' with { icon: 'eye', iconOnly: true, variant: 'soft-primary', size: 'sm' } %}
{% include '_atoms/button/button.html.twig' with { icon: 'edit', iconOnly: true, variant: 'soft-warning', size: 'sm' } %}
{% include '_atoms/button/button.html.twig' with { icon: 'trash', iconOnly: true, variant: 'soft-error', size: 'sm' } %}
|
Paramètre : size
| Taille | Hauteur | Padding | Font |
|---|---|---|---|
xs | 24px | 8px | 12px |
sm | 32px | 16px | 14px |
md | 40px | 24px | 16px |
lg | 48px | 32px | 18px |
xl | 56px | 40px | 20px |
Paramètre : radius
Paramètres : icon, iconPosition, iconOnly
{% verbatim %}{# Icône à gauche #}
{% include '_atoms/button/button.html.twig' with {
label: 'Ajouter',
icon: 'plus'
} %}
{# Icône à droite #}
{% include '_atoms/button/button.html.twig' with {
label: 'Suivant',
icon: 'chevron-right',
iconPosition: 'right'
} %}
{# Icône seule #}
{% include '_atoms/button/button.html.twig' with {
icon: 'trash',
iconOnly: true,
variant: 'ghost'
} %}{% endverbatim %}
Paramètres : disabled, loading
Paramètre : width: 'full'
| Paramètre | Type | Défaut | Options |
|---|---|---|---|
label |
string | '' |
Texte du bouton |
variant |
string | 'primary' |
primary, secondary, success, error, warning, dark, outline, outline-dark, ghost, link |
size |
string | 'md' |
xs, sm, md, lg, xl |
radius |
string | 'lg' |
none, sm, md, lg, xl, full |
width |
string | 'auto' |
auto, full |
type |
string | 'button' |
button, submit, reset |
href |
string | null |
URL (rend un <a>) |
target |
string | null |
_blank, _self, etc. |
icon |
string | null |
Nom de l'icône (ex: 'check', 'plus') |
iconPosition |
string | 'left' |
left, right |
iconOnly |
bool | false |
true, false |
loading |
bool | false |
true, false |
disabled |
bool | false |
true, false |
class |
string | '' |
Classes Tailwind additionnelles |
attr |
object | {} |
Attributs HTML (data-*, aria-*, etc.) |