My Design System

Button

The Button component allows users to perform actions. It comes in several different style variants, and supports icons in addition to text labels.

Open in a
new tab
<vaadin-horizontal-layout theme="spacing" style="align-items: baseline">
  <vaadin-button @click="${() => this.counter++}">Button</vaadin-button>
  <p>Clicked ${this.counter} times</p>
</vaadin-horizontal-layout>

Styles

The following variants can be used to distinguish between actions of different importance in the UI:

Open in a
new tab
<vaadin-button theme="primary">Primary</vaadin-button>
<vaadin-button theme="secondary">Secondary</vaadin-button>
<vaadin-button theme="tertiary">Tertiary</vaadin-button>
VariantUsage recommendations

Primary

  • The most important action in a view or part of a view.

  • The main closure or continuation action (such as Save) in a form or dialog.

  • Avoid presenting the user with more than one at any time.

Secondary

  • Default style recommended for most actions.

  • Alternate or negative closure actions (for example: Cancel) in a form or dialog.

Tertiary

  • Lower importance actions

  • Especially in parts of the UI with less space, such as cards, or for repeated actions for items in lists, tables, etc.

  • Caution: can be mistaken for non-interactive text

Danger / Error Variants

A style for distinguishing actions related to dangers, warnings, or errors.

Open in a
new tab
<vaadin-button theme="primary error">Primary</vaadin-button>
<vaadin-button theme="secondary error">Secondary</vaadin-button>
<vaadin-button theme="tertiary error">Tertiary</vaadin-button>

Use this style for:

  • Dangerous actions, such as those that will lose or destroy data.

  • Primary danger buttons should only be used when the dangerous action is the most likely action, such as the affirmative Delete action in a deletion confirmation dialog.

  • Secondary and Tertiary variants can also be used for actions related to current errors (such as resolving them or viewing their details).

Size Variants

The following size variants are available for Button instances whose size needs to be different from the default:

Open in a
new tab
<vaadin-button theme="large">Large</vaadin-button>
<vaadin-button theme="normal">Normal</vaadin-button>
<vaadin-button theme="small">Small</vaadin-button>
VariantUsage recommendations

Large

For especially important call-to-action buttons, where extra emphasis is needed.

Normal

Default size.

Small

Compact option for cramped parts of the UI, if a Tertiary variant is not deemed appropriate.

Tip
Default button size can be customized
Size variants should only be used in special cases. See Size and Space for details on how to change the default button size.

Miscellaneous Style Variants

The Tertiary Inline variant omits all white-space around the label, which is useful for embedding a Button as part of text content or another component. It should not be confused with a Link, however.

Open in a
new tab
<vaadin-button theme="tertiary-inline">Tertiary inline</vaadin-button>

The Success and Contrast variants should provide additional color options for buttons.

Open in a
new tab
<vaadin-button theme="primary success">Primary</vaadin-button>
<vaadin-button theme="secondary success">Secondary</vaadin-button>
<vaadin-button theme="tertiary success">Tertiary</vaadin-button>
Open in a
new tab
<vaadin-button theme="primary contrast">Primary</vaadin-button>
<vaadin-button theme="secondary contrast">Secondary</vaadin-button>
<vaadin-button theme="tertiary contrast">Tertiary (avoid)</vaadin-button>

The Tertiary + Contrast combination should be avoided due to its similarity to non-interactive text elements.

Tip
Default button colors can be customized
Note that the standard Button colors can be adjusted using theme features, show these variants should not be used to replace standard buttons just to achieve a different color.

Buttons With Icons

Buttons can have icons instead of text, or on either side in addition to text:

Open in a
new tab
<vaadin-button theme="icon" aria-label="Add item">
  <vaadin-icon icon="vaadin:plus"></vaadin-icon>
</vaadin-button>

<vaadin-button theme="icon" aria-label="Close">
  <vaadin-icon icon="vaadin:close-small"></vaadin-icon>
</vaadin-button>

<vaadin-button>
  <vaadin-icon icon="vaadin:arrow-left" slot="prefix"></vaadin-icon>
  Left
</vaadin-button>

<vaadin-button>
  Right
  <vaadin-icon icon="vaadin:arrow-right" slot="suffix"></vaadin-icon>
</vaadin-button>

Usage recommendations:

  • Use icons sparingly. Most actions are difficult to reliably represent with icons, and the benefit of icons in addition to text should be weighed against the additional visual noise this creates.

  • Icon-only buttons should be primarily used for extremely common recurring actions with highly standardized, universally understood icons (for example: a cross for close), and for actions that are repeated (for example: in lists and tables).

  • Icon-only buttons should provide a textual alternative for screen readers using the aria-label attribute.

Note
Icon-only button style variant
Use the icon / LUMO_ICON theme variant on icon-only buttons to reduce the white space on either side of the icon.

Buttons With Images

Images can be used similarly to icons. See icon usage recommendations.

Open in a
new tab
<vaadin-button theme="icon">
  <img src="${img}" width="100" alt="Vaadin logo" />
</vaadin-button>

Disabled

Buttons representing actions that are not currently available to the user should be either hidden or disabled. A disabled button is rendered as "dimmed", and is excluded from the focus order (such as when interactive UI elements are focused using the tab key).

Open in a
new tab
<vaadin-button theme="primary" disabled>Primary</vaadin-button>
<vaadin-button theme="secondary" disabled>Secondary</vaadin-button>
<vaadin-button theme="tertiary" disabled>Tertiary</vaadin-button>

Hidden vs Disabled

Hiding an unavailable action entirely is often preferable to a disabled button, as this reduces UI clutter. However, in certain situations this can be problematic:

  • If the user expects a button to be present, such as at the end of a form, hiding the button can cause confusion, even if the form clearly indicates the presence of one or more invalid fields.

  • As a hidden button doesn’t occupy any space in the UI, toggling its visibility can cause unwanted changes in the layout of other elements.

Showing an Error on Click

As an alternative to hiding or disabling buttons, unavailable actions can instead be configured to show an error message when the button is clicked (using a Notification or an adjacent inline text element). This approach is the most accessible option, but may cause frustration in users who expect unavailable actions to be somehow distinguished from available actions.

Prevent Multiple Clicks

Buttons can be configured to become disabled automatically when clicked.

This can be especially useful for actions that take a bit longer to perform. Not only does this avoid the need for special handling of clicks while the action is in progress, but it also communicates to the user that the action was successfully received and is being processed.

Open in a
new tab
<vaadin-horizontal-layout theme="spacing" style="align-items: center;">
  <vaadin-button
    ?disabled=${this.isDisabled}
    @click=${() => {
      this.isDisabled = true;
      this.fakeProgressBar.simulateProgress();
    }}
    style="flex: none;"
    >Perform Action</vaadin-button
  >
  <fake-progress-bar
    @progress-end=${() => {
      this.isDisabled = false;
    }}
  ></fake-progress-bar>
</vaadin-horizontal-layout>

Focus

Similarly to input fields, the focus ring is only rendered when the button is focused by keyboard or programmatically.

Open in a
new tab
<vaadin-button focus-ring>Keyboard focus</vaadin-button>

Auto Focus

Buttons can automatically receive keyboard focus when the UI they’re in is rendered.

<vaadin-button autofocus>Button</vaadin-button>

Keyboard Usage

A focused button can be triggered with Enter or Space.

Best Practices

Button Labels

  • The label should describe the action, preferably using active verbs, such as "View details" rather than just "Details".

  • In cases where there is a risk for ambiguity, also specify the object of the verb, such as "Save changes" instead of "Save".

  • Button groups representing options, such as the buttons of a Confirm Dialog, should state what each option represents, such as "Save changes" instead of "Yes", as the latter forces the user to read the question being asked, and increases the risk of selecting the wrong option.

  • Keep labels short, ideally less than three words or 25 characters.

  • Use ellipsis (…) when an action is not immediate but requires more steps to complete. This is useful, for example, for destructive actions like "Delete…​" when a Confirm Dialog is used to confirm the action before it’s executed.

ARIA Labels

The aria-label attribute can be used to provide a separate label for accessibility technologies (AT) like screen readers. This is important, for example, for icon-only buttons that lack a visible label.

Buttons with regular, visible labels can also benefit from separate aria-label s to provide more context that may otherwise be difficult for the AT user to perceive. In the example below, the buttons aria-label specify which email address will be removed.

Open in a
new tab
<vaadin-vertical-layout>
  <vaadin-horizontal-layout theme="spacing">
    <vaadin-text-field
      id="primary-email"
      label="Primary email address"
      .value="${this.primaryEmail}"
      @value-changed="${(e: TextFieldValueChangedEvent) =>
        (this.primaryEmail = e.detail.value)}"
    ></vaadin-text-field>
    <vaadin-button
      arial-label="Remove primary email address"
      @click="${() => (this.primaryEmail = '')}"
      >Remove</vaadin-button
    >
  </vaadin-horizontal-layout>

  <vaadin-horizontal-layout theme="spacing">
    <vaadin-text-field
      id="secondary-email"
      label="Secondary email address"
      .value="${this.secondaryEmail}"
      @value-changed="${(e: TextFieldValueChangedEvent) =>
        (this.secondaryEmail = e.detail.value)}"
    ></vaadin-text-field>
    <vaadin-button
      arial-label="Remove secondary email address"
      @click="${() => (this.secondaryEmail = '')}"
      >Remove</vaadin-button
    >
  </vaadin-horizontal-layout>
</vaadin-vertical-layout>

Buttons in Forms

Open in a
new tab
<vaadin-vertical-layout theme="spacing">
  <vaadin-form-layout .responsiveSteps="${[{ columns: 2 }]}">
    <vaadin-text-field label="First name" value="John"></vaadin-text-field>
    <vaadin-text-field label="Last name" value="Smith"></vaadin-text-field>
    <vaadin-text-field
      label="Email address"
      value="john.smith@example.com"
      colspan="2"
    ></vaadin-text-field>
  </vaadin-form-layout>

  <vaadin-horizontal-layout theme="spacing">
    <vaadin-button theme="primary">Create account</vaadin-button>
    <vaadin-button theme="secondary">Cancel</vaadin-button>
  </vaadin-horizontal-layout>
</vaadin-vertical-layout>
  • Buttons should be placed below the form they’re associated with.

  • Buttons should be aligned left.

  • Primary action first, followed by other actions, in order of importance.

Buttons in Dialogs

Open in a
new tab
<vaadin-vertical-layout theme="spacing" style="align-items: stretch;">
  <vaadin-form-layout .responsiveSteps="${[{ columns: 2 }]}">
    <vaadin-text-field label="First name" value="John"></vaadin-text-field>
    <vaadin-text-field label="Last name" value="Smith"></vaadin-text-field>
    <vaadin-text-field
      label="Email address"
      value="john.smith@example.com"
      colspan="2"
    ></vaadin-text-field>
  </vaadin-form-layout>

  <vaadin-horizontal-layout
    theme="spacing"
    style="flex-wrap: wrap; justify-content: flex-end;"
  >
    <vaadin-button theme="secondary error" style="margin-inline-end: auto;">
      Delete
    </vaadin-button>
    <vaadin-button theme="secondary">Cancel</vaadin-button>
    <vaadin-button theme="primary">Create account</vaadin-button>
  </vaadin-horizontal-layout>
</vaadin-vertical-layout>
  • Buttons should be placed at the bottom of the dialog.

  • Buttons should be aligned right.

  • Primary action last, preceded by other actions.

  • Dangerous actions should be aligned left, to avoid accidental clicks, especially if no confirmation step is included.

Global vs Selection-Specific Actions

In lists of selectable items (such as in a Grid) that provide actions applicable to the selected item, buttons for selection-specific actions should be placed separately from "global" non-selection-specific actions, preferably below the list of selectable items. In the example below, the global "Add user" action is separated from the selection-specific actions below the Grid.

Open in a
new tab
<vaadin-vertical-layout theme="spacing" style="align-items: stretch;">
  <vaadin-horizontal-layout style="align-items: center;">
    <h2 style="margin: 0 auto 0 0;">Users</h2>
    <vaadin-button>Add user</vaadin-button>
  </vaadin-horizontal-layout>

  <vaadin-grid
    .items="${this.items}"
    @selected-items-changed="${(ev: any) =>
      (this.selectedItems = ev.target ? [...ev.target.selectedItems] : this.selectedItems)}"
  >
    <vaadin-grid-selection-column
      auto-select
      @select-all-changed="${(ev: CustomEvent) =>
        (this.selectedItems = ev.detail.value ? this.items : this.selectedItems)}"
    ></vaadin-grid-selection-column>
    <vaadin-grid-column path="firstName"></vaadin-grid-column>
    <vaadin-grid-column path="lastName"></vaadin-grid-column>
    <vaadin-grid-column path="email"></vaadin-grid-column>
  </vaadin-grid>

  <vaadin-horizontal-layout theme="spacing" style="flex-wrap: wrap;">
    <vaadin-button ?disabled="${this.selectedItems.length !== 1}">Edit profile</vaadin-button>
    <vaadin-button ?disabled="${this.selectedItems.length !== 1}">
      Manage permissions
    </vaadin-button>
    <vaadin-button ?disabled="${this.selectedItems.length !== 1}">
      Reset password
    </vaadin-button>
    <vaadin-button
      theme="error"
      ?disabled="${this.selectedItems.length === 0}"
      style="margin-inline-start: auto;"
    >
      Delete
    </vaadin-button>
  </vaadin-horizontal-layout>
</vaadin-vertical-layout>
ComponentUsage recommendations

Menu Bar

Overlay menus with items that trigger actions. Can also be used for single "menu buttons" and "button groups" without overlay menus.