components / Actions and Inputs

Button

Hierarchy

Strict order of buttons is not necessary. Visual hierarchy between Buttons is the important goal.

Primary Actions

As a rule, only a single primary action should be present at a time to draw the user through a flow.

Destructive primary actions use a negative color. Clicking this should trigger a confirmation (usually as a Dialog) before proceeding with the action.

Secondary Actions

When multiple actions surface information or start a workflow, the secondary variant can be used. It also pairs well with a primary action.

A negative equivalent also exists. It is used when a destructive action is less prominent, usually paired with other buttons.

Tertiary Actions

For less pronounced, common actions throughout a page.

An alternative tertiary style also exists. It's used when solid gray is unable to visually work, such as on non-white backgrounds, or pairing with a secondary action.

Subtle Actions

On data-heavy UIs, the subtle style can be used in large quantities without adding heavy visuals.

Text-based Subtle Actions

When the button is Text, the blue variant is preferred over gray to preserve the Button's signifier to the user.

Icon-based Subtle Actions

For Icons, the gray variant is preferred if the icon is understandable to end users.

Pairing Guidelines

See the Button Group component guidelines on applying button hierarchy to multiple buttons.

Alignment

Left Aligned

Left-aligned buttons are recommended for single page forms and focused tasks. The buttons are ordered from left to right by importance.

Right Aligned

Buttons in page headers and footers prompt a user to move through a sequence of screens are right aligned to visually support navigation. The buttons are ordered from right to left by importance.

Within Overlays, like Modals, actions are right-aligned as well to encourage forward progress through a workflow.

Centered

Centered buttons are used when the content is shown in a small, isolated view. These should be used sparingly and are most commonly within overlay-based components such as Modals.

Variations

Colors

There are three color variations for buttons. Blues and reds tend to be more prominent in a neutral-dominant UI, while grays allow for deemphasized actions.

Fills

There are three fills a button can have. A solid fill is useful for bold and important actions. An outline fill can be used for secondary actions and looks good next to a solid button and stand out on colored backgrounds. A subtle fill is useful for actions that don't need to call a lot of attention to.

Disabled

We have two separate ways of disabling buttons. A disabled attribute will prevent clicks and change the button to a grey style. An inactive attribute will prevent clicks but keeps the button looking the same. This is useful for preventing stray clicks while an API call is running or showing an outlined-to-active state change.

Sizes

We support three sizes of buttons that can be set using the size prop. Small buttons are useful for secondary or ancillary actions. Large buttons are great for important call-to-actions and helping unstick a user in a setup flow.

Widths

The default width of buttons has a consistent amount of padding between the text and the ends of the button. This can be overridden with the width property, either setting it to a specific size or making the button full width. Specific sized buttons should only be used when buttons are next to each other or in a column and have variable text lengths. Keeping them the same width will make the buttons feel intentional. Setting a width for every button is not recommended.

with Icon

Buttons can have an icon to the left or right of the action label.

Button Icons

When pairing an Icon and an action, an Icon-only Button is used to control the interaction. To add clarity to the action, Button Icons should be paired with Tooltips.

Loading

Add the loading prop to the button and it disables and gives a loading animation. Useful for preventing double submissions on forms. The button width will not change.

Selected

Use the selected state when a Button needs to visually appear active, such as when an Action Menu associated with the Button is open.

Content Guidelines

Button name should describe what it does

A user should be able to use the button name to predict what will happen when they click it.

Buttons should action-oriented, pairing a verb and a supporting noun, and be 2 to 3 words long. Common actions like “Save,” “Close,” “Cancel,” or “OK” don’t require a supporting noun.

Be concise and consistent

Avoid unnecessary words and articles such as the, an, or a. Never include punctuation in button text and avoid button text that requires punctuation. Always write button text in title case. Capitalize the first word, the last word, and all major words in between. Never use emoji or exclamation points.

Button name should match destination

When a button opens a modal or takeover, the destination’s title should match the button text.

Button labeled Add Transaction opens a modal titled “Add transaction”

Button labeled Add Transaction opens a modal titled “Create new invoice”.

Technical Examples

Click Action

Use the onClick prop to pass a function to the button.

Linked

The standard button component uses a span element because most buttons will be passed a function. If you pass the button a href prop, it will become an a element and click through to the url.

Action Menu (Dropdown)

You can pass Button through the trigger prop of the ActionMenu.


Best Practices

  • Use the same button sizes within an action area
  • Prioritize the most important actions. Too many calls to action can cause confusion and make users unsure of what to do next.
  • Using several styles on one page may be confusing to user. Try to avoid using more than 3 styles on a screen.

  • For a text button inline in a paragraph, use a Link.
  • To group Buttons together, use a Button Group.

Importing

import { Button } from '@servicetitan/design-system';