Sajari UI

Button

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

Usage

Editable Example

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

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

With Icon

You can add left and right icons to the Button components. See how to add icons.

Editable Example

Buttons can be used as links.

Editable Example

Loading state

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.

Editable Example

Disabled state

Pass disabled prop to the Button component to disable it's functionality. This will disable the buttons default functionality and dim it's appearance.

Editable Example

Accessibility

  • Button has role button.
  • 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

Custom Button

In event you need to make your own custom button, you can leverage the Box component.

Editable Example

Props

The Button composes the Box component so you can pass props for Box. These are props related to the Button component.

NameTypeDefaultDescription
aria-labelstringThe label of the button
appearancedefault, primary, secondary, success, warning, danger, ghost, link, subtle-link, nonedefaultThe variant of the button style to use.
disabledbooleanIf true, the button will be disabled.
loadingbooleanIf true, the button will show a spinner.
loadingTextstringThe label to show in the button when loading is true. If no text is passed, it only shows the spinner
sizexs, sm, md, lg , xlmdThe size of the button.
iconBeforeIconProps['name']An icon to display before any children.
iconAfterIconProps['name']An icon to display after any children.
iconBeforeSizeIconProps['size']The size of the icon to display before any children.
iconAfterSizeIconProps['size']The size of the icon to display after any children.
iconSizeIconProps['size']Shorthand to set both iconBeforeSize and iconAfterSize.
externalbooleanIf true, the link will open in new tab.
hrefstringa link for the button.
targetstringThe target for the link to open.