Button
The action primitive. Extends Text with theme-driven variants and sizes.
Button extends Text, so it accepts every Text and Box prop. It adds a variant prop mapped to theme.skins.button and a $size prop mapped to theme.skins.button.sizes. Use it for actions; pass as="button" for a native button.
Import#
import { Button } from "@reactberry/system/elements";
Usage#
import { Button } from "@reactberry/system/elements";
export default function SaveButton({ onSave }: { onSave: () => void }) {
return (
<Button as="button" type="button" variant="primary" onClick={onSave}>
Save
</Button>
);
}
Examples#
Variants#
variant picks a style from theme.skins.button. Nested entries use a dot path, such as ghost.danger.
Sizes#
$size picks a size from theme.skins.button.sizes, which sets height, padding, font size and weight.
With icons#
Compose icons as children. Use gap for spacing and an icon.* size with shape="circle" for square icon buttons.
Disabled#
disabled dims the button and blocks pointer events. With as="button" the native disabled attribute is also set.
API#
Button#
| Prop | Type | Default | Description |
|---|---|---|---|
as | ElementType | "span" | Element or component to render. Use |
variant | string | "default" | Dot path into |
$size | string | "medium" | Dot path into |
disabled | boolean | — | Sets |
shape | string | "rounded" | Key in |
role | string | "button" | ARIA role. |
tabIndex | number | 0 | Tab order. |
Button also accepts every Text and Box prop. These defaults are applied before your props, so any of them can be overridden: border="none", display="inline-flex", alignItems="center", justifyContent="center" and cursor="pointer". A 0.2s ease transition is always applied.
Variant reference#
Variants resolve by dot path, so nested entries are used as ghost.dim or outline.dark. The default light theme defines:
default— withdefault.surface,default.danger,default.success,default.info,default.warning,default.accentprimaryaccentactiveoutline— withoutline.danger,outline.dark,outline.dark.success,outline.dark.activesolidghost— withghost.danger,ghost.subtle,ghost.dim,ghost.lightensubtle— withsubtle.darkerclean— no border, background, or radiuscta— withcta.subtle,cta.contrasttab— top indicator bar, active whendata-active="true"segment— withsegment.subtletranslucent— withtranslucent.light,translucent.darksuccess,warning,danger— each with.light
The dark theme defines default, primary, outline, subtle, solid, ghost, clean, cta, danger, and bubble.
Size reference#
Light theme (font-weight: 600 throughout):
xxxsmall— height 1.5rem, font 0.875remxxsmall— height 1.75rem, font 0.875remxsmall— height 2rem, font 0.875remsmall— height 2.25rem, font 0.875remmedium— height 2.5rem, font 1rem;medium.condenseduses 0.5rem horizontal paddinglarge— height 3rem, font 1.125rem
Square icon sizes: icon (2.5rem), icon.large (3rem), icon.small (2.25rem), icon.xsmall (2rem), icon.xxsmall (1.5rem).
The dark theme provides xxsmall to large with different font sizes and weights, adds xlarge (height 4rem), and has no xxxsmall. Padding for each size comes from theme.controlSizes (see Box).
Accessibility#
role="button"andtabIndex={0}are set by default, so the defaultspanis announced as a button and can be focused.Buttonadds no keyboard handling. Aspanwithrole="button"does not activate on Enter or Space; useas="button"for native keyboard and form behaviour.- With
as="a", the defaultrole="button"overrides the link role. Passrole={undefined}to keep link semantics. disabledon a non-native element only blocks pointer events; the element stays focusable throughtabIndex={0}.- Give icon-only buttons an
aria-label.
Notes#
- There are no built-in
loading,icon,iconPosition, orfullWidthprops. Compose children and usewidth="100%"instead. - Set
typeexplicitly on native buttons inside forms.