Buttons allow an application to communicate action and direct user intent.

Three different types

Solid buttons look heavy on purpose. They direct the user’s attention to the primary action the application is suggesting that the user take.

Outline buttons provide a lighter weight button style. They are used to indicate a secondary action that compliments a primary action or to reduce visual noise when there are many action of equal importance on the page.

Flat buttons are used in multiple scenarios. They are used as tertiary buttons. They can also be used inline because they are different from content in style and recognizable as buttons alongside content.

Use flat buttons when a user is expected to take an action.

vs

Link

Use a link when a user is expected to be taken to a different page.

Placement

There are two distinct patterns when it comes to the placement of a button.

Z pattern
Z Pattern

The Z-pattern is a natural way for the user to go through content within a constrained container and when tasks are oriented from the top-left and ending with a primary call to action on the right bottom side of the container. This pattern is reversed for right to left languages.

Modals and Wizards follow the Z Pattern

F pattern
F Pattern

The F-pattern is a natural way to go through content in an unconstrained container, such as a form on the page itself. The user will go through the content line-by-line, arriving at a call to action at the end.

Forms and Cards follow the F Pattern

Modals and Wizards follow the Z Pattern

Forms and Cards follow the F Pattern

Style

Consistent button styles make it easier for a user to recognize areas to take action across an application.

Typography

The text inside of buttons is always uppercase. This indicates action by differentiating button text from links and other content on the page. Use descriptive language on buttons relating to the user’s intent.

Don't use generic language not related to the action'
Don't

Use generic language not related to the action and not relating to the intent of the user.

Use a call to action on buttons
Do

Use a call to action on buttons.

Visual Style
Border Radius

Clarity buttons have a border radius of 3px.

Size

Clarity offers two button sizes:

  • Default height of 36px
  • Compact height of 24px

Compact is used in content areas where smaller buttons are needed to de-emphasize calls to action. This is especially true when multiple actions of equal importance are available.

Use compact buttons in content areas
Primary Color

A primary color provides consistency across an application. It trains the user to look for that color when trying to find an action. Clarity defaults to blue. This “action blue” can be found across all types of buttons, tabs, and other action-related components.

 
Action-based Color

Different colors may be used based on the severity of an action’s result. For example, using a red button when “deleting” files indicates high severity.

Action colors can indicate severity
Icons

Icon buttons are useful where interface space may be limited. If an icon represents the action well, users can sometimes recognize them quicker than reading text. Lastly, using icon buttons can help in the situation where the use of long labels may be challenging.

We recommend you choose an icon that best describes the action that the user will be doing. Users may avoid unknown or abstract icon buttons.

Types & Sizes

Icon buttons are available in the solid, outline, and flat types. It’s also best to use the normal (36px) sized ones. This makes them easier to recognize and to click.

Don't

Use small icon buttons in most cases. They are difficult to see and distinguish what the icon is or represents. They also create smaller click targets, making them harder to click.

With Text

If you have the space, adding text helps users understand the action. Start icon buttons with icons and follow with text.

Don't

Start icon buttons with text and follow with icon. This makes them more difficult to scan quickly.

Title Attribute

If your icon button is has no text, we recommend adding the title=“” attribute to your icon buttons. This adds some additional context for users unfamiliar with what action your icon button might produce. Hovering over the icon button for a moment will show a tooltip that has the title text. The text should reflect the action being completed.

Icon Button Title Attribute

Code & Examples

Clarity defines three button styles:

  • Solid. A solid background with light text. These buttons are prominent on the page.
  • Outline. A transparent background with colored border and text. On hover, the button fills with color.
  • Flat. Text in Action Blue, used to indicate an action.

Solid Buttons

<button class="btn btn-primary">Primary</button>
<button class="btn btn-success">Success</button>
<button class="btn btn-warning">Warning</button>
<button class="btn btn-danger">Danger</button>
<button class="btn btn-danger" disabled>Disabled</button>

Outline Buttons

<button class="btn btn-outline">Regular</button>
<button class="btn btn-success-outline">Success-Outline</button>
<button class="btn btn-info-outline">Info</button>
<button class="btn btn-warning-outline">Warning</button>
<button class="btn btn-danger-outline">Danger</button>
<button class="btn btn-outline" disabled>Disabled</button>

Flat Buttons

<button class="btn btn-link">Regular</button>
<button class="btn btn-link" disabled>Disabled</button>
<button class="btn btn-sm btn-link">Regular</button>
<button class="btn btn-sm btn-link" disabled>Disabled</button>

Types

Primary Button

<button class="btn btn-primary">Primary</button>

Secondary Button

<button class="btn">Secondary</button>

Tertiary Button

<button class="btn btn-link">Tertiary</button>
<button class="btn btn-link" disabled>Disabled</button>

States

Info, Success and Danger Outline Buttons

Success and Danger Solid Buttons

<button class="btn btn-info-outline">Info</button>
<button class="btn btn-success-outline">Success</button>
<button class="btn btn-danger-outline">Danger</button>

<button class="btn btn-success">Success</button>
<button class="btn btn-danger">Danger</button>

Sizes

Normal

<button class="btn">Regular</button>
<button class="btn btn-primary">Primary</button>
<button class="btn btn-success">Success</button>
<button class="btn btn-info">Info</button>
<button class="btn btn-warning">Warning</button>
<button class="btn btn-danger">Danger</button>
<button class="btn" disabled>Disabled</button>

Small

<button class="btn btn-sm">Regular</button>
<button class="btn btn-primary btn-sm">Primary</button>
<button class="btn btn-success btn-sm">Success</button>
<button class="btn btn-info btn-sm">Info</button>
<button class="btn btn-warning btn-sm">Warning</button>
<button class="btn btn-danger btn-sm">Danger</button>
<button class="btn btn-sm" disabled>Disabled</button>

Normal Flat Buttons

<button class="btn btn-link">Flat Regular</button>
<button class="btn btn-link" disabled>Flat Disabled</button>

Small Flat Buttons

<button class="btn btn-link btn-sm">Flat Regular</button>
<button class="btn btn-link btn-sm" disabled>Flat Disabled</button>

Block

<button class="btn btn-primary btn-block">Primary</button>
<button class="btn btn-success btn-block">Success</button>

Inverse

Inverse Button

<button class="btn btn-inverse">Inverse</button>
<button class="btn btn-inverse" disabled>Disabled Inverse</button>

Icon Buttons

Use the .btn-icon class to create Icon Buttons

<button type="button" class="btn btn-icon">
    <clr-icon shape="home"></clr-icon>
</button>
<button type="button" class="btn btn-icon btn-primary">
    <clr-icon shape="cog"></clr-icon>
</button>
<button type="button" class="btn btn-icon btn-warning">
    <clr-icon shape="warning-standard"></clr-icon>
</button>
<button type="button" class="btn btn-icon btn-danger">
    <clr-icon shape="error-standard"></clr-icon>
</button>
<button type="button" class="btn btn-icon btn-success">
    <clr-icon shape="check"></clr-icon>
</button>
<button type="button" class="btn btn-icon" disabled>
    <clr-icon shape="home"></clr-icon>
</button>

Loading Buttons

Use the clrLoading directive to change the state of the spinner button. The directive can be set to one of the following values:


  • ClrLoadingState.DEFAULT: the default state of the button.
  • ClrLoadingState.LOADING: replaces the button text with a spinner.
  • ClrLoadingState.SUCCESS: briefly shows a check mark, and automatically transition back to the ClrLoadingState.DEFAULT state.

<button [clrLoading]="validateBtnState" class="btn btn-info-outline" (click)="validateDemo()">Validate</button>
<button [clrLoading]="submitBtnState" type="submit" class="btn btn-success-outline" (click)="submitDemo()">Submit</button>
import { ClrLoadingState } from '@clr/angular';

export class ButtonLoadingDemo {
  validateBtnState: ClrLoadingState = ClrLoadingState.DEFAULT;
  submitBtnState: ClrLoadingState = ClrLoadingState.DEFAULT;

  validateDemo() {
    this.validateBtnState = ClrLoadingState.LOADING;
    //Validating Logic
    this.validateBtnState = ClrLoadingState.SUCCESS;
  }

  submitDemo() {
    this.submitBtnState = ClrLoadingState.LOADING;
    //Submit Logic
    this.submitBtnState = ClrLoadingState.DEFAULT;
  }
}