Close Button

The × that closes a panel, dialog, toast or chip. A ghost square like the ⋯ icon button: a muted × that turns dark on hover, #f5f5f5 behind it on hover and #e9ebef pressed.

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

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

Playground

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

Props

size
aria-label
disabled

Best practices

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

GuidancePractice
DoUse it for the × on a panel, dialog, toast or chip, so every close looks and behaves the same: muted until hovered, named Close by default.
DoSet aria-label to say what closing does when Close isn't enough, like Remove Jane Citizen on a chip. In a list of chips each name must be unique.
DoUse size="inline" in toasts and chips. The × is 16 px but its hit area still reaches the 24 px minimum.
DoMatch the size to the icon buttons beside it in the same header (xs 28, sm 32, md 36, lg 40), so the × lines up with them.
Don'tBuild a close with an IconButton and an X icon. Use CloseButton, which keeps the muted colour and the default name.
Don'tUse it to delete a record, like a contact or a matter. Use a Button with intent="destructive" behind a confirmation.

Props

Also takes every prop of ui-sdk's Button: onClick, disabled, focusableWhenDisabled and render.

PropTypeDefaultDescription
size"xs" | "sm" | "md" | "lg" | "inline""xs"xs 28, sm 32, md 36 and lg 40 are ghost squares. Inline is a bare 16 px × for toasts and chips, with a 24 px hit area.
aria-labelstring"Close"What closing does, when "Close" isn't enough, like "Remove Jane Citizen".
classNamestring—Classes added to the root element, merged with its own. Tokens only.

Code

What the playground shows, ready to copy.

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

<CloseButton />

Labelled

It's named Close by default. Say what closing does when that's clearer, like removing a person from a list.

Jane Citizen

What the examples share

The imports and the scaffolding the examples above call. The scaffolding lives in this page, not in the library.

import { Fragment } from "react";

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

const sizes = ["xs", "sm", "md", "lg", "inline"] as const;

Keyboard

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

KeysWhat they do
EnterSpacePresses the focused button.