Rate this page:

Button

Buttons are used as triggers for actions. A row of buttons is displayed in a ButtonSet.

Usage

1
import ForgeUI, { Button } from '@forge/ui';

Props

NameTypeRequiredDescription
onClick() => void | Promise<void>YesAn event handler that can be asynchronous. You can execute state updates inside this function.
textstringYesThe button's label text.
appearancestringThe appearance of the button. Valid values are danger, default, link, subtle, subtle-link, and warning. Defaults to default.
disabledbooleanWhether the user interaction is disabled. Defaults to false.
iconstringAn icon to display with the button's text. Valid values are icons from @atlaskit/icon. For example, "add-circle" or "graph-line".
iconPosition"before" | "after"Where to render the icon relative to the text. Defaults to "before".

Example

A button with an asynchronous handler.

1
2
3
4
5
6
<Button
     text="Sign up"
     onClick={async () => {
       await postSignup(data);
     }}
/>

Preview

Screenshot of what the rendered button should look like

Rate this page: