Components General

Button

Starts an action. One primary button per view; the rest secondary or ghost.

import { Button, ButtonLink } from '@kition/tessera-ui'
Playground

Props

What is shown
import { Button } from '@kition/tessera-ui'

<Button variant="primary" size="md">Save changes</Button>

When to use

  • The main action of a dialog or panel (primary).
  • Other actions beside it (secondary, ghost).
  • Destructive actions after a choice (danger).

When not to

  • Navigation to another page: use a link.
  • Toolbar commands: use IconButton or a ribbon button.

Examples

Variants

Secondary is outlined; subtle is a quiet filled button; a disabled filled button turns muted, not faint.

button-variants.tsx
import { Button } from '@kition/tessera-ui'

export default function Demo() {
  return (
    <div className="demo-row">
      <Button variant="primary" size="md">Save</Button>
      <Button variant="secondary" size="md">Cancel</Button>
      <Button variant="subtle" size="md">Duplicate</Button>
      <Button variant="ghost" size="md">More</Button>
      <Button variant="danger" size="md">Delete</Button>
      <Button variant="danger-outline" size="md">Disable</Button>
      <Button variant="primary" size="md" disabled>Disabled</Button>
    </div>
  )
}
Sizes

Without a size the button keeps the 30px of editor chrome.

button-sizes.tsx
import { Button } from '@kition/tessera-ui'

export default function Demo() {
  return (
    <div className="demo-row">
      <Button variant="primary" size="sm">Small (32)</Button>
      <Button variant="primary" size="md">Medium (36)</Button>
      <Button variant="primary" size="lg">Large (40)</Button>
      <Button>Editor chrome (30)</Button>
    </div>
  )
}
Loading, icons, icon only

Icons inside a button draw at 16px; an icon-only button is square and needs an aria-label.

button-states.tsx
import { useState } from 'react'
import { Button } from '@kition/tessera-ui'
import { PlusIcon, SettingsIcon } from '@kition/tessera-icons/react'

export default function Demo() {
  const [saving, setSaving] = useState(false)
  return (
    <div className="demo-row">
      <Button
        variant="primary"
        size="md"
        loading={saving}
        onClick={() => {
          setSaving(true)
          setTimeout(() => setSaving(false), 1500)
        }}
      >
        {saving ? 'Saving…' : 'Save'}
      </Button>
      <Button variant="secondary" size="md">
        <PlusIcon /> New record
      </Button>
      <Button variant="ghost" size="md" iconOnly aria-label="Settings">
        <SettingsIcon />
      </Button>
      <Button variant="secondary" size="sm" iconOnly aria-label="Add">
        <PlusIcon />
      </Button>
    </div>
  )
}

Props

Button

A button. Its className adds to Tessera's, so a host can adjust one button's layout.

PropTypeDefaultDescription
variantButtonVariant—
sizeControlSize—Without size a button keeps the editor chrome's 30px.
iconOnlyboolean—A square button holding only an icon; give it an aria-label.
loadingboolean—Shows a spinner before the label and marks the button busy, while its action runs.

Also takes the attributes of its HTML element (`className`, `aria-*`, events…).

Used in

14 of Kition's 16 kits use these components.

  • Board
  • Cube
  • Design
  • Doc
  • Effect
  • Film
  • Html
  • Note
  • Pdf
  • Photo
  • Sheet
  • Slide
  • Table
  • Vector