Button

Runs an action. Built on ui-sdk's Button: Enter and Space press it, a returned Promise keeps it busy, and render turns it into a link. Four intents and four sizes, from the Refined UI Components page.

BetaReady to use. Its API can still change in a minor release; the changelog says when.

import { Button, IconButton } from "@leap-crm/design-system";

Playground

Change a prop and the component follows. Its code is under Props.

Button

Props

children
intent
size
loading
showResult
result
icon
disabled
render

IconButton

Props

intent
size
loading
disabled

Best practices

When to use it, and the rules that apply in particular places.

GuidancePractice
DoUse primary for the main action and outline for the actions beside it, like Save and Cancel. Use ghost in toolbars and rows, and destructive for deleting.
DoReturn a Promise from onClick, so the button stays busy until the work settles. Use loading only for busy state that comes from outside, like a mutation.
DoPass showResult with labels, like { done: "Saved", error: "Couldn't save" }, when the outcome should be announced. The button's own name never changes.
DoPass an <a> or a router link to render when the button navigates, like Download agreement, so it keeps link semantics.
Don'tUse xs (28 px) for a primary action or anything used on touch. Those need a 44 px hit target; keep xs for dense rows and toolbars.
Don'tPut a Button inside a sentence or a paragraph. Use TextLink for an action that reads as part of the text.

Props

Both also take every prop of ui-sdk's Button: onClick, disabled, focusableWhenDisabled, type, pendingAnnouncement and render.

Button

PropTypeDefaultDescription
childrenReactNode—What it shows inside.
intent"primary" | "outline" | "ghost" | "destructive""primary"primary for the main action, outline beside it, ghost in toolbars and rows, destructive for deleting.
size"xs" | "sm" | "md" | "lg"—xs 28 · sm 32 · md 36 (the default) · lg 40.
iconReactNode—Leading icon. It turns into the spinner while the button is busy, and back.
loadingbooleanfalseBusy from outside state, like a mutation. Prefer returning a Promise from onClick.
showResultboolean | ButtonResultLabelsfalseWhen onClick's Promise settles, the spinner turns into a tick (resolved) or a cross (rejected) for a moment before the icon returns. Pass labels to have the outcome announced.
result"done" | "error"—Holds a result mark in place of the icon, like the option a lawyer already picked on a card. A showResult tick settles into it without redrawing.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

IconButton

PropTypeDefaultDescription
icon *ReactNode—The only content. It turns into the spinner while the button is busy, and back.
aria-label *string—An icon-only button has no visible text, so its name is required.
intent"primary" | "outline" | "ghost" | "destructive""ghost"primary for the main action, outline beside it, ghost in toolbars and rows, destructive for deleting.

Code

What the playground shows, ready to copy.

Button

import { Button } from "@leap-crm/design-system";

<Button>Add contact</Button>

IconButton

import { IconButton, PlusIcon } from "@leap-crm/design-system";

<IconButton icon={<PlusIcon />} aria-label="Add contact" />

Keyboard

The keys it answers to. Tab moves between components, arrows move within them.

KeysWhat they do
EnterSpacePresses the focused button.
TabReaches it. A disabled button is skipped.