NG Kit

Buttons

Custom button components built on top of Angular Material buttons. ng-kit adds ready-made button types — primary, success, edit, delete, export and more — each with additional styling, icons and loading state on top of the shared BaseButtonDirective. Pick a button from the navigation to see its live demo and source.

A BaseButtonDirective provides common functionality and styling for all button types; every ng-kit button extends this base. Buttons can be consumed in two ways:

  • Directives (preferred) — apply button styling and behaviour to any existing HTML element for cleaner markup and more flexibility.
  • Components (legacy) — dedicated Angular components that wrap Angular Material buttons. Still supported, but the directive approach is preferred for new implementations.

The two styles are interchangeable:

html
<!-- Directive (preferred) -->
<button ariaLabel="Submit" (click)="onSubmit()" primaryButton mat-raised-button>Submit</button>

<!-- Component -->
<primary-button ariaLabel="Submit" (click)="onSubmit()">Submit</primary-button>

API

All buttons share the inputs and outputs of the base button. Directive selectors are attribute-based (e.g. primaryButton); component selectors are elements (e.g. <primary-button>).

Common inputs

NameTypeDefaultDescription
labelstring'Save'Text shown on the button (per-button defaults vary)
iconstringper buttonMaterial icon name rendered before the label
showIconbooleantrueWhether the leading icon is rendered
disabledbooleanfalseDisables the button
loadingbooleanfalseShows a spinner and the loading label; disables the button
loadingLabelstring'Saving...'Text shown while loading is true
type'button' | 'submit''button'Native button type

The base directive exposes icon, label, loading and loadingLabel. Component buttons additionally provide style, classes and dataCy inputs.

Outputs

NamePayloadDescription
onClickMouseEventButton was clicked
onFocus / onBlurFocusEventButton gained / lost focus
onKeyDown / onKeyUpKeyboardEventKey pressed / released while focused