Usage
To create a basic button, wrap text in a <Button>
.
Colors
Buttons come in five variants: primary
(default), secondary
, danger
, ghost
, and link
.
Dark mode
When setting a button on a dark background, enable darkMode
to maintain a high color contrast between the button and the background.
Icons
Import any icons from Font Awesome and pass them to the icon
prop. Icons can be positioned on the left
(default) or right
.
Icon-only buttons
Icons can be displayed with or without text.
Links
Links can be styled as buttons by passing in an href
. When href
is defined, Button
inherits properties from HTMLAnchorElement
so you can set properties like rel
and target
.
Loading
An icon can be put into a loading state with the loading
prop. It’s good practice to also disable
loading buttons to prevent duplicate submissions.
Sizing
Buttons can be small
, default
, large
, or huge
.
API Reference
Button
Inherits properties from HTMLAnchorElement
(when href
is defined) or HTMLButtonElement
(when href
is not defined).
Prop | Type | Default |
---|---|---|
asChild | boolean | false |
children | ReactNode | |
darkMode | boolean | false |
disabled | boolean | false |
href | string | |
icon | IconProp | |
iconPosition | "left" "right" | "left" |
iconProps | Omit<FontAwesomeIconProps, 'icon'> | |
loading | boolean | false |
screenReaderLabel | string | |
size | "small" "default" "large" "huge" | "default" |
variant | "primary" "secondary" "danger" "ghost" "link" | "primary" |