Button

Starts an action. Every button is a pill; exactly one per view is ink.

View source
import { Button } from "@logicplanes/kaeso-ui";

Props

  • children
    ReactNode

    The button's label: a verb first, in sentence case. A label wider than its container is cut with an ellipsis and shown whole in a tooltip.

  • count
    number

    A count after the label.

  • disabledReason
    string

    Why the button is disabled, shown as a tooltip and read out as the button's description. The button stays focusable so people can reach it.

  • download
    string

    With href, saves the file the link points to under this name instead of opening it, such as a generated image (blob: and data: links included).

  • fullWidth
    boolean

    Fills the width of its container.

  • href
    string

    Renders a link that looks like the button.

  • icon
    IconSvgElement

    Makes it an icon-only circle with this icon. Give it an aria-label: the name screen readers read and the tooltip shows.

  • leadingIcon
    IconSvgElement

    An icon before the text.

  • loading
    boolean

    Work is underway: the button is busy and ignores clicks at once; the spinner shows only once the work has taken 300ms, then for at least 400ms (useDelayedLoading). It replaces the leading icon, or covers the label; the width never changes.

  • onPressedChange
    ((pressed: boolean) => void)

    Called with the new state when a toggle button is pressed.

  • pressed
    boolean

    Makes it a toggle button that is on or off (aria-pressed); with variant="selector", a check shows while it is on.

  • rel
    string

    The link's relationship, as on an a element.

  • reserveLabels
    ReactNode[]

    Every label this button can show ("Copy key", "Copied"). The button keeps the width of the widest, so a state change never resizes it.

  • shortcut
    string[] | string[][]

    A shortcut hint: after the label (lg and xl, and in menus), or in the tooltip of an icon-only button.

  • size
    "md" | "xs" | "sm" | "lg" | "xl"

    The height, from xs (24px) to xl (48px).

  • static
    boolean

    Keeps the button still when pressed, for a control whose 0.96 press would distract; it still darkens.

  • target
    string

    Where the link opens, as on an a element.

  • tooltip
    boolean

    Turns off an icon-only button's tooltip, for when a visible label sits next to it or the button has a tooltip of its own.

  • tooltipSide
    "top" | "bottom" | "left" | "right"

    Where an icon-only button's tooltip appears.

  • trailingIcon
    IconSvgElement

    An icon after the text.

  • variant
    "danger" | "link" | "secondary" | "primary" | "ghost" | "quiet" | "soft" | "selector" | "danger-secondary"

    primary for the one main action of a view, secondary for others, ghost and quiet for toolbars and rows, danger for destructive actions. A ghost or quiet button at the end of a settings row's control pulls its padding past the row's edge, so its label ends where an outlined button's ring does.