Button

API for button

API reference for Angular Material button

import {MatButtonModule} from '@angular/material/button';

Material design button.

Selector: button[mat-button] button[mat-raised-button] button[mat-icon-button] button[mat-fab] button[mat-mini-fab] button[mat-stroked-button] button[mat-flat-button]

Exported as: matButton
Properties
Name Description
@Input()

color: ThemePalette

Theme color palette for the component.

@Input()

disableRipple: boolean

Whether ripples are disabled.

@Input()

disabled: boolean

Whether the component is disabled.

defaultColor: ThemePalette | undefined

Default color to fall back to if no value is set.

isIconButton: boolean

Whether the button is icon button.

isRoundButton: boolean

Whether the button is round.

ripple: MatRipple

Reference to the MatRipple instance of the button.

Methods
focus

Focuses the button.

Parameters

origin

FocusOrigin = 'program'

options?

FocusOptions

Material design anchor button.

Selector: a[mat-button] a[mat-raised-button] a[mat-icon-button] a[mat-fab] a[mat-mini-fab] a[mat-stroked-button] a[mat-flat-button]

Exported as: matButton, matAnchor
Properties
Name Description
@Input()

color: ThemePalette

Theme color palette for the component.

@Input()

disableRipple: boolean

Whether ripples are disabled.

@Input()

disabled: boolean

Whether the component is disabled.

defaultColor: ThemePalette | undefined

Default color to fall back to if no value is set.

isIconButton: boolean

Whether the button is icon button.

isRoundButton: boolean

Whether the button is round.

ripple: MatRipple

Reference to the MatRipple instance of the button.

Methods
focus

Focuses the button.

Parameters

origin

FocusOrigin = 'program'

options?

FocusOptions

API reference for Angular Material button-testing

import {MatButtonHarness} from '@angular/material/button/testing';

Harness for interacting with a standard mat-button in tests.

Methods
async
blur

Blurs the button.

Returns
Promise<void>

Promise that resolves when the action completes.

async
click

Clicks the button.

Returns
Promise<void>

Promise that resolves when the action completes.

async
focus

Focuses the button.

Returns
Promise<void>

Promise that resolves when the action completes.

async
getText

Gets the button's label text.

Returns
Promise<string>

async
host

Gets a Promise for the TestElement representing the host element of the component.

Returns
Promise<TestElement>

async
isDisabled

Whether the button is disabled.

Returns
Promise<boolean>

async
isFocused

Whether the button is focused.

Returns
Promise<boolean>

A set of criteria that can be used to filter a list of MatButtonHarness instances.

Properties
Name Description

text: string | RegExp

Only find instances whose text matches the given value.