Primitives
A button is a clickable element that can be used to trigger an action. This primitive enhances the native button element with improved accessibility and interaction handling for hover, press and focus.
Import the Button primitives from ng-primitives/button
.
import { NgpButton } from 'ng-primitives/button';
Assemble the button directives in your template.
<button ngpButton>Button</button>
Generate a button component with the NgpButton
primitive preconfigured.
ng g ng-primitives:button
name
: The name of the component.prefix
: The prefix to apply to the generated component selector.directory
: The directory at which to create the component file.style
: The file extension or preprocessor to use for style files.inlineStyle
: Include styles inline in the component.ts file. Only CSS styles can be included inline.inlineTemplate
: Include template inline in the component.ts fileThe following directives are available to import from the ng-primitives/button
package:
A directive that can be used to create a button.
[ngpButton]
ngpButton
Attribute | Description |
---|---|
data-hover |
Added to the button when hovered. |
data-focus-visible |
Added to the button when focused. |
data-press |
Added to the button when pressed. |
data-disabled |
Added to the button when disabled. |
Copyright © 2024 Angular Primitives