Button
Documentation of the <Button />
component. Learn how to use it and its available props.
Installation
To get started, install @exponentialeducation/betomic
via yarn:
# Yarnyarn add @exponentialeducation/betomic
Use of Button
Button is used by users to trigger action and operations when clicked.
import { Button } from "@exponentialeducation/betomic";
function IndexPage() {
return ( <main> {/* ... */}
<Button> Click me! </Button>
{/* ... */} </main> )}
The previous example describes the simplest way of using the Button component, it uses default props
and renders a button like the following:
Sizes & variants
Betomic comes with three different sizes as well as variants for buttons.
Primary and secondary button variants indicate main and secondary actions respectivelly.
Tertiary variant also handles dark mode. Disabled buttons are non-interactive.
Small
Primary | Secondary | Tertiary | Disabled |
---|---|---|---|
Medium
Primary | Secondary | Tertiary | Disabled |
---|---|---|---|
Large
Primary | Secondary | Tertiary | Disabled |
---|---|---|---|
Some examples of button sizes, variants and props:
import { Button } from "@exponentialeducation/betomic";
function IndexPage() { return ( <main> {/* ... */}
<Button size="sm" variant="primary"> Small primary button </Button>
<Button variant="secondary"> Secondary button </Button>
<Button variant="tertiary" disabled> Tertiary button disabled </Button>
{/* ... */} </main> )}
Wrapping styles
Buttons handle two different wrapping styles, also known as constraints: Fill container and Hug contents.
Hug contents
Hug contents constraint keeps the size of the button bounded to its content. It means that the button will adapt its size according to the elements that it holds.
Text | Text + icon fixed | Text + icon extended |
---|---|---|
Fill container
Fill container constraint resizes the button to fill the width of its direct container.
Text | Text + icon fixed |
---|---|
Icon
Icon style adjusts button paddings to keep a 1:1 square aspect ratio.
Small | Medium | Large |
---|---|---|
Loading
Icon style adjusts button paddings to keep a 1:1 square aspect ratio.
Small | Medium | Large |
---|---|---|
Some examples of button wrapping styles and props:
import { Button } from "@exponentialeducation/betomic";
function IndexPage() { return ( <main> {/* ... */}
<Button> Hug contents button </Button>
<Button block className="justify-between"> Fill container button <ArrowRightIcon /> </Button>
<Button icon size="lg"> <ArrowRightIcon /> </Button>
<Button icon loading> <ArrowRightIcon /> </Button>
{/* ... */} </main> )}
Props
Extends ButtonHTMLAttributes
props
prop | description |
---|---|
| boolean = false |
| string |
| boolean = false |
| boolean = false |
| "sm" | "md" | "lg" = "md" |
| "button" | "reset" | "submit" = "button" |
| "primary" | "secondary" | "tertiary" = "primary" |
| CSSProperties |
| boolean? default=false |
| (event: MouseEvent<HTMLElement>) => void |