Button
Displays a button or a component that looks like a button.
Button — le bouton shadcn universel. 6 variants (default, secondary, destructive, outline, ghost, link) × 4 sizes (default, sm, lg, icon). Peut rendre <button> ou <a> selon la présence de href.
Base des DropdownMenuTrigger, DialogTrigger, PopoverTrigger, AlertDialogAction… bref, la fondation de la moitié du kit.
Installation
$ bext ui add button
Copy and paste the following into src/components/ui/button.tsx.
Usage
Anatomy
<Button variant="default|secondary|destructive|outline|ghost|link" size="default|sm|lg|icon" href?>
├── {loading ? <Spinner /> : icon && <Icon />}
└── {children}API Reference
Button
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "secondary" | "destructive" | "outline" | "ghost" | "link" | "default" | Style visuel du bouton. |
| size | "default" | "sm" | "lg" | "icon" | "default" | Taille : sm=h-8, default=h-9, lg=h-10, icon=h-9 w-9 square. |
| href | string | — | Si présent, rend un au lieu de |
| target | string | — | Ex "_blank" pour ouvrir dans un nouveau tab. |
| type | "button" | "submit" | "reset" | "button" | Type HTML pour les vrais boutons (dans un form). |
| icon | string | — | Slug lucide-like pour ajouter une icône à gauche du label. |
| loading | boolean | — | Affiche un spinner à la place de l'icône. Désactive le bouton (aria-busy). |
| disabled | boolean | — | Standard HTML. |
Keyboard
| Key | Action |
|---|---|
| Enter / Space | Active le bouton (comportement natif). |
| Tab | Focus / défocus. |
Accessibility
Toujours mettre un texte explicite ou un aria-label quand le bouton n'a qu'une icône (size="icon"). Sinon les AT annoncent "bouton" sans contexte.
loading=true ajoute aria-busy="true" et désactive le bouton.
Examples
Sizes (sm / default / lg / icon)
Loading state
<Button loading>Saving...</Button>
Edit this component live in the bext playground. The PRISM + signals version is the bext-native idiom — fine-grained reactivity, no virtual DOM.
On This Page