Button

Déclenche une action utilisateur. Quatre variantes, chacune avec une hiérarchie et un usage précis. La variante critical porte des règles comportementales spéciales pour les actions irréversibles. Triggers a user action. Four variants, each with a precise hierarchy and use case. The critical variant carries special behavioral rules for irreversible actions.

VariantesVariants

Primary — action principale, 1 maximum par sectionPrimary — main action, 1 maximum per section
Secondary — action alternativeSecondary — alternative action
Ghost — action tertiaire, faible emphaseGhost — tertiary action, low emphasis
Critical — action irréversible (confirmation obligatoire)Critical — irreversible action (confirmation required)

Règles absoluesAbsolute rules

Tokens de composantComponent tokens

Token CSSRéférence sémantiqueSemantic referenceValeur résolueResolved value
--sda-component-button-primary-backgroundsemantic.color.action.primary#12a594
--sda-component-button-primary-background-hoversemantic.color.action.primary-hover#0d9b8a
--sda-component-button-primary-background-disabledsemantic.color.action.primary-disabled#d9d9d9
--sda-component-button-primary-textsemantic.color.text.on-action#ffffff
--sda-component-button-primary-padding-xsemantic.space.control.padding-x16px
--sda-component-button-primary-padding-ysemantic.space.control.padding-y8px
--sda-component-button-primary-radiussemantic.radius.control6px
--sda-component-button-critical-backgroundsemantic.color.feedback.danger#ce2c31
--sda-component-button-secondary-textsemantic.color.action.primary#12a594
--sda-component-button-secondary-bordersemantic.color.action.primary#12a594
--sda-component-button-ghost-textsemantic.color.action.primary#12a594

AccessibilitéAccessibility

Règles spéciales — variante criticalSpecial rules — critical variant

Token component.button.critical.$metadata.requires-confirmation = true. Avant d'utiliser cette variante, vérifier :Before using this variant, verify:

  1. Le pattern de confirmation existe dans l'interface (modale, popconfirm)The confirmation pattern exists in the UI (modal, popconfirm)
  2. Le libellé décrit l'action — ex: "Supprimer définitivement le dossier"The label describes the action — e.g. "Delete folder permanently"
  3. Le contraste est ≥ 4.5:1 sur fond blancContrast is ≥ 4.5:1 on white background
  4. L'agent escalade à un humain si le caractère irréversible de l'action n'est pas certainThe agent escalates to a human if the irreversibility of the action is uncertain

Implémentation — Lit Web ComponentImplementation — Lit Web Component

import { LitElement, html, css } from 'lit';

class DsButton extends LitElement {
  static properties = {
    variant: { type: String }, // 'primary' | 'secondary' | 'critical' | 'ghost'
    disabled: { type: Boolean },
    loading:  { type: Boolean },
  };

  static styles = css`
    button {
      background: var(--sda-component-button-primary-background);
      color:      var(--sda-component-button-primary-text);
      padding:    var(--sda-component-button-primary-padding-y) var(--sda-component-button-primary-padding-x);
      border-radius: var(--sda-component-button-primary-radius);
      font-size:  var(--sda-semantic-typography-label-size);
      font-weight:var(--sda-semantic-typography-label-weight);
      border: none; cursor: pointer;
    }
    button:focus-visible {
      outline: 2px solid var(--sda-semantic-color-border-focus);
      outline-offset: 2px;
    }
  `;
}
customElements.define('ds-button', DsButton);

DOs et DON'Ts

À faireDo

  • Libellé explicite décrivant l'action (« Supprimer définitivement le dossier »)Explicit label describing the action ("Delete folder permanently")
  • Maximum 1 bouton primary par section ou formulaireMaximum 1 primary button per section or form
  • Toujours un :focus-visible visible pour la navigation clavierAlways a visible :focus-visible for keyboard navigation
  • État loading avec aria-busy="true" pour les actions asynchronesloading state with aria-busy="true" for async actions
  • Pattern de confirmation obligatoire avant chaque action criticalMandatory confirmation pattern before each critical action

À éviterDon't

  • Libellé vague : « OK », « Confirmer », « Valider » seulVague label: "OK", "Confirm", "Submit" alone
  • Deux boutons primary côte à côte dans le même formulaireTwo primary buttons side by side in the same form
  • Couleurs ou espacements en dur (style="background:red")Hardcoded colors or spacing (style="background:red")
  • Variantes inventées hors de tokens/component.jsonInvented variants outside tokens/component.json
  • Bouton critical sans pattern de confirmationcritical button without a confirmation pattern

Anti-patternsAnti-patterns

MauvaisBadPourquoiWhy
<button style="background:red">Supprimer</button>Valeur en dur, variante non reconnue, pas de tokenHardcoded value, unrecognized variant, no token
<sda-button variant="critical">OK</sda-button>Libellé non explicite pour une action critiqueNon-explicit label for a critical action
Deux variant="primary" dans le même formulaireTwo variant="primary" in the same formHiérarchie cassée — perte de clarté UXBroken hierarchy — loss of UX clarity
<sda-button variant="danger">Variante inexistante — escalader, demander la variante correcteNon-existent variant — escalate, ask for the correct variant
Contribuer à ce projetContribute to this project Ce système est ouvert aux contributions — tokens, composants, décisions architecturales, corrections d'accessibilité ou documentation. Toute amélioration est bienvenue. This system welcomes contributions — tokens, components, architectural decisions, accessibility fixes, or documentation. Every improvement counts.
Voir sur GitHub → View on GitHub →