Skip to content

Button

Stable

A rounded button with a text label. It comes in five styles and three sizes, and can hold an icon.

Also known as btn, call to action, cta

Install with npm install @tattva/ui (setup), or copy the code from the kit in Downloads.

Variants

Primary is the default. Use it once per screen. Lime is a small bright highlight with dark text. Ghost suits quiet actions in toolbars.

When to use it

The main way to take an action. Its style shows how much the action matters, so one strong button can lead a screen while quieter ones sit beside it.

Made of: Icon before · Label · Icon after

Use it for

  • An action with a short verb label, like Send, Save or Regenerate.
  • The one main action on a screen: use the primary or lime style.
  • A second, quieter action next to the main one: use secondary or ghost.
  • Deleting something, or anything that cannot be undone: use danger.

Not for

  • An action shown by an icon alone: use IconButton.
  • A setting that turns on or off right away: use Switch.
  • Picking one option from a small set: use SegmentedControl.

Do and avoid

Do. One main button per area. The other choice stays quiet.
Avoid. Two main buttons compete, so nobody knows the best choice.

Do

  • Use one primary button per screen, for the action you most want people to take.
  • Use lime for one positive highlight, with dark text. Lime is only ever a background.
  • Use secondary for the second action beside a primary one. Use ghost for quiet toolbar actions.
  • Start labels with a verb that says what happens, like "Regenerate" or "Delete chat".
  • Use busy, not disabled, while a press is being handled, so focus stays on the button.

Avoid

  • Do not use the danger style unless something is deleted or cannot be undone.
  • Do not put two primary buttons side by side.
  • Do not make a button amber. Amber is only for when a person has to act.
  • Do not use an icon alone in a Button. For icon-only buttons, use IconButton with a label.

On a phone

  • On a touch screen every button keeps the size it is drawn at and has an invisible tap area at least 44px tall and wide, so sm and md stay small but are easy to tap.
  • The label never wraps, so a long label can run past a narrow container. Keep labels short or shorten them on a phone.
  • Hover colours do nothing on a phone, so the pressed state is the only feedback: the button sinks a little under the finger and comes back when it lifts.

Build your next AI screen with Tattva.

Free and open, with the code. Start in one line.

Get started