Button component is used to trigger an action or event, such as submitting a
form, opening a Dialog, canceling an action, or performing a delete
operation.
Import
import{Button}from'@sajari-ui/core';
Usage
Editable Example
<Buttonappearance="primary">Button</Button>
Sizes
Use the size prop to change the size of the button. You can set the value to
xs, sm, md, lg or xl.
Editable Example
<ButtonGroup>
<Buttonappearance="primary"size="xs">
Button
</Button>
<Buttonappearance="primary"size="sm">
Button
</Button>
<Buttonappearance="primary"size="md">
Button
</Button>
<Buttonappearance="primary"size="lg">
Button
</Button>
<Buttonappearance="primary"size="xl">
Button
</Button>
</ButtonGroup>
Appearance
Use the appearance prop to change the visual style of the Button. You can set the
value to default, primary, secondary, success, warning, danger, ghost, link, or subtle-link.
Editable Example
<ButtonGroup>
<Button>Button</Button>
<Buttonappearance="primary">Button</Button>
<Buttonappearance="secondary">Button</Button>
<Buttonappearance="success">Button</Button>
<Buttonappearance="warning">Button</Button>
<Buttonappearance="danger">Button</Button>
<Buttonappearance="ghost">Button</Button>
<Buttonappearance="link">Button</Button>
<Buttonappearance="subtle-link">Button</Button>
</ButtonGroup>
With Icon
You can add left and right icons to the Button components.
See how to add icons.
Pass loading prop to the Button component to show it's loading state. You
can optionally pass loadingText prop, if you do, the button will show a
spinner and the loading text. Otherwise, the button will take the width of the
text label and show only the spinner.
When Button has focus, Space and Enter activates it.
Composition
Button composes Box and all props you pass (appearance,
size, etc.) are converted to style props. This means you can override
any style of the Button via props.
Editable Example
// The size prop affects the height of the button
// but I can still override it by passing a custom height
<Button
appearance="primary"
width="w-32"
borderColor="border-blue-200"
backgroundColor="bg-blue-100"
textColor="text-blue-500"
fontWeight="font-semibold"
>
Button
</Button>
Custom Button
In event you need to make your own custom button, you can leverage the
Box component.