suiss/ui · Component
Button
A pill-shaped button that triggers an action, with variants for every level of emphasis.
Button is an open-source component from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
Button renders a native button by default. It supports eight visual variants, five text sizes and five icon-only sizes, and an optional block mode that fills the container width.
Use the default variant for the primary action in a view, secondary, tinted or outline for supporting actions, ghost and plain for low-emphasis actions, and destructive for actions that delete or remove. To join several buttons into one control, use Button Group.
Installation
CLI
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
Manual
- Install the dependencies and add the
cnhelper:
- Copy the source into
components/ui/button.tsx:
- Update the import paths to match your project.
Usage
Mark icons with data-icon="inline-start" or data-icon="inline-end" to tighten the padding on that side. Icons without a size class are sized automatically.
Use an icon size, such as icon or icon-sm, for buttons that contain only an icon, and give them an aria-label.
To render a link or a router component with button styling, use the render prop from Base UI. buttonVariants is also exported if you need the classes on another element.
To render a link or a router component with button styling, set asChild and pass it as the child. buttonVariants is also exported if you need the classes on another element.
Button always renders a button. To give a link or a router component button styling, apply the classes from buttonVariants to it.
Examples
Variants
Shows all eight variants side by side.
Sizes
Compares the xs, sm, default and lg sizes.
With icon
Adds leading and trailing icons, and an icon-only button.
Disabled
A disabled button that is skipped in the tab order.
Block
Full-width buttons at each size, whose corner radius scales with size.
API Reference
Button
The interactive button element.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "outline" | "secondary" | "tinted" | "ghost" | "plain" | "destructive" | "link" | "default" | Visual style: default, outline, secondary, tinted, ghost, plain, destructive or link. |
size | "default" | "xs" | "sm" | "lg" | "xl" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | "icon-xl" | "default" | Height and padding. xs to xl for text buttons; icon-xs to icon-xl for square icon-only buttons. |
block | true | - | When true, the button fills the container width and uses rounded corners instead of a pill shape. |
Also accepts the props of the primitive part it wraps.
Accessibility
- Renders a native
button, soEnterandSpaceactivate it. - A disabled button is removed from the tab order.
- Icon-only buttons need an
aria-label. - Keyboard focus shows a 3px ring in
--ring; thedestructivevariant tints it withring-destructive/20. aria-invalidadds a destructive border and ring, andaria-expandedshows a selected background onoutline,ghostandplainbuttons that open menus or popovers.
Notes
- Styling hook:
data-slot="button". - Colors come from the
primary,secondary,accentanddestructivevariables. Hover uses the same color with an opacity, such ashover:bg-primary/80, and disabled buttons useopacity-50. - Buttons in a group raise the focused one above its neighbors so the whole ring stays visible.
Web preview
Button is a Pressable with the button role. It supports eight visual variants, five text sizes and five icon-only sizes, and an optional block mode that fills the width of its container.
Use the default variant for the primary action on a screen, secondary, tinted or outline for supporting actions, ghost and plain for low-emphasis actions, and destructive for actions that delete or remove. To join several buttons into one control, use Button Group.
Installation
The CLI also adds what it builds on: Icon, Text.
Manual
-
Target iOS 17 or later.
-
Copy the theme files every view uses:
- Copy the source and every file it uses:
- Add the files to your app target.
- Set
minSdkto 24 or higher and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.
Usage
Put the label in a Text and icons in an Icon. The button passes its text color and icon size down through context, so children pick them up without extra classes.
Use an icon size, such as icon or icon-sm, for buttons that contain only an icon, and give them an accessibilityLabel.
buttonVariants and buttonTextVariants are also exported if you need the classes on another element.
Examples
Variants
All eight variants, plus an icon-only button.
Web preview
Sizes
Compares the text and icon-only sizes.
Web preview
With icon
Leading and trailing icons, and an icon-only button.
Web preview
Disabled
Disabled buttons in every variant.
Web preview
Block
Full-width buttons at each size, whose corner radius scales with size.
Web preview
API Reference
Button
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "outline" | "secondary" | "tinted" | "ghost" | "plain" | "destructive" | "link" | "default" | Visual style. |
size | "xs" | "sm" | "default" | "lg" | "xl" | "icon-xs" | "icon-sm" | "icon" | "icon-lg" | "icon-xl" | "default" | Height and padding; icon sizes are square. |
block | boolean | - | Stretches the button to the full width of its container. |
Also accepts the props of ButtonProps.
Accessibility
- Renders a
Pressablewithrole="button", so VoiceOver and TalkBack announce it as a button. disabledis announced and blocks presses.- Icon-only buttons need an
accessibilityLabel.
Notes
- Colors come from semantic tokens such as
bg-primary,bg-secondary,bg-primary/10 dark:bg-primary/20andbg-destructive/10 dark:bg-destructive/20, withopacity-80while pressed andopacity-50when disabled. - Light and dark colors follow the system appearance.