Skip to main content
Neural UIv2.0.0Documentation
View v1 GitHub

Button

Native action button with signal inputs, loading and a semantic activation event.

Category
Actions
Import
@neural-ui/core/button
Selector
button[neu-button]
import { NeuButtonComponent } from '@neural-ui/core/button';

Overview

Use a native button for an immediate action. NeuButton adds signal inputs for tone, visual variant, size, loading and icon placement while retaining native button semantics. Use a link for navigation and a selection control for persistent choices; this component does not own form or selection state.

Basic interaction

Import Button and handle neuClick to run an action. Try the button, then open Source to copy the complete example.

Basic interaction
Activations: 0

States and variants

Use tone for semantic color: neutral, success, info, warning or danger. brand remains available for the primary action. All six tones support solid, outline and ghost variants. size changes the control dimensions. Loading disables activation and announces busy state.

States and variants
Activations: 0

Sizes and widths

size chooses sm, md or lg control dimensions; it is not a width input. A normal Button fits its content. fullWidth=true makes it occupy the containing surface.

For a fixed or responsive application width, use CSS such as inline-size: min(100%, 240px). There is no width input to bind. iconOnly uses square dimensions based on size; keep that mode separate from a full-width text action.

template.html
<button neu-button>Fit content</button>
<button neu-button [fullWidth]="true">Fill container</button>
<button neu-button style="inline-size: min(100%, 240px)">CSS width</button>

Icons

Choose one of two integration paths: set the icon input to an application key resolved by provideNeuIconResolver, or place an icon component or SVG directly inside the button. Projection needs neither the icon input nor a Core resolver. Neural Icons is one option, not a requirement; Core remains independent of the icon library.

For the icon input, iconPosition selects start or end. For projected content, put the icon before or after the text in the template. The add key also has a minimal Button fallback that works without a resolver; other application keys need a resolver and do not automatically load an icon catalog.

For an icon-only action, use iconOnly with either integration path, omit visible text and provide ariaLabel. iconOnly sets square dimensions; it does not remove projected content. The demo covers these options, and its TypeScript, HTML and provider tabs contain the code that runs them.

Icons

Minimal Core icon

The add key has a fallback drawing in Button and works without a resolver. This does not mean Core includes an icon catalog.

The icon input and application resolver

icon="save" is a key resolved by the application. iconPosition places that icon at the start or end. The provider tab includes the required registration.

An icon component inside the button

Here Neural Icons is projected directly. You can also project your own component or one from another library: no icon input or Core resolver is needed. Content order determines the position.

An inline SVG, without an icon library

The SVG is part of the button content. Use currentColor to inherit its color and aria-hidden="true" when the text already names the action.

Icon only: input or projected content

iconOnly applies square dimensions; it does not remove content. Omit visible text and provide ariaLabel. These three buttons use the input, projected Neural Icons and a projected SVG, respectively.

Activations: 0

Icon contract

Configure Button

Change appearance, text, icon, width and interaction state, then copy the component code. The result uses the same values as the generated template. Click the enabled button to see its neuClick event count.

Width choices distinguish the Core fullWidth input from a CSS inline-size. Application icons also show the provider setup they need; Add can use the built-in fallback without that setup.

Result

neuClick events: 0

Generated code

The result and code update as you change the options.

template.html
<button neu-button>Save changes</button>
Appearance
Content and icon

Text is placed inside the button. Add uses Coreโ€™s minimal icon; Save, Download and Delete use Neural Icons through this applicationโ€™s resolver.

Width

fullWidth fills the container. A custom width is CSS, not a width input. iconOnly keeps the square dimensions defined by size.

State and accessibility

An icon-only button needs an accessible name. disabled and loading prevent neuClick.

Accessibility and keyboard

Core handles native keyboard activation, disabled/loading behavior and the busy-state attribute.

Your application supplies a clear action label. For an icon-only button, set ariaLabel. Keep decorative projected icons hidden from assistive technology.

Key
Action
Enter Activate the focused native button.
Space Activate the focused native button.
Tab Move focus to or from an enabled button in document order.

API

Inputs configure applied state: use [property]="value" for a dynamic value or a literal attribute for a fixed string. Button has ten inputs and no editable value model. Its visible text is projected between the opening and closing button tags; there is no label input.

The neuClick output emits a MouseEvent when an enabled button is activated. Listen with (neuClick)="save($event)". Neither disabled nor loading is managed by that event; your application owns the operation and passes the current state back to Button.

Inputs

Configure the component with [property]="value". Your application supplies these values; the component does not replace the state you pass in.

Name
Type
Default
Template binding
Description
ariaLabelstring''[ariaLabel]Accessible name override, required for an icon-only action.
disabledbooleanfalse[disabled]Blocks native activation and neuClick.
fullWidthbooleanfalse[fullWidth]Sets the button to 100% of its container. For another width, use CSS; there is no width input.
iconstring | nullnull[icon]Application key (string), not an icon definition or built-in catalog name. Resolve custom keys with provideNeuIconResolver; add has a minimal Button fallback.
iconOnlybooleanfalse[iconOnly]Uses square dimensions with an input icon or a projected icon. It does not remove projected content: omit visible text and provide an accessible ariaLabel.
iconPositionNeuButtonIconPosition'start'[iconPosition]Places the icon supplied by the icon input before or after content. It does not reorder icons projected inside the button.
loadingbooleanfalse[loading]Shows a spinner, marks the button busy and disables activation.
sizeNeuButtonSize'md'[size]sm, md or lg sets padding, text and icon dimensions. It does not set the container width.
toneNeuButtonTone'brand'[tone]Selects neutral, brand or danger semantic intent.
variantNeuButtonVariant'solid'[variant]Selects solid, outline or ghost visual treatment.

Outputs

Listen to an event with (event)="handler($event)". The table explains the data your handler receives and how to use it.

Name
Payload
Template binding
Description
neuClickMouseEvent(neuClick)="onNeuClick($event)"Emits MouseEvent for an enabled activation. Listen with (neuClick); disabled or loading suppresses it. Your application handles the action.

Templates

ng-content projects content into the component. TemplateRef inputs receive a template; ng-template directives identify templates with a typed context. A directive shared by an entrypoint is not necessarily a slot of this component.

Name
Mechanism
Contract
*

Button content

Content projection

Text and SVG are projected inside the button; no icon provider is required.

<ng-content />

Context used: โ€”

Usage example

Content between the button tags is projected content. You can supply text, an icon component or an SVG; the Icons section demonstrates these variants. For iconOnly, omit visible text and provide ariaLabel: projected content is not automatically removed.

Customize content
Activations: 0

Public Types

Open a type to inspect its definition and interface fields.

Theming

Use the public --neu-button-* component tokens below, or a reusable preset from the Themes guide. Scope overrides to the application surface you want to customize.

Theming
Inherited theme
Local override

Specific tokens

Token
Purpose
State / variant
Default / source
Fallback
--neu-button-background Background of a solid, brand Button. solid / brand var(--neu-primary-solid)Component fallback--neu-primary-solid
--neu-button-background-hover Hover background of a solid, brand Button. solid / brand / hover var(--neu-primary-solid-hover)Component fallback--neu-primary-solid-hover
--neu-button-border Border color of a solid, brand Button. solid / brand var(--neu-primary-solid)Component fallback--neu-primary-solid
--neu-button-foreground Text and inherited icon color of a solid, brand Button. solid / brand var(--neu-primary-solid-fg)Component fallback--neu-primary-solid-fg

Shared tokens used

Override these on a local wrapper to affect this example. An override on :root affects other components that use the same token.

Token
Purpose here
Other impact
Default / fallback
--neu-error Invalid field or danger-action color Shared by other Core consumers; scope the override. #dc2626
--neu-error-bg Background of invalid or danger states Shared by other Core consumers; scope the override. #fee2e2
--neu-error-text Error text and danger outline/ghost Button text in both themes Shared by other Core consumers; scope the override. #991b1b
--neu-focus-ring-strong Emphasized focus treatment Shared by other Core consumers; scope the override. 0 0 0 var(--neu-focus-ring-width) rgba(0, 122, 255, 0.35)
--neu-primary Brand color for active controls and emphasis Shared by other Core consumers; scope the override. #007aff
--neu-primary-50 Subtle brand surface for hover and focus states Shared by other Core consumers; scope the override. #eff6ff
--neu-primary-dark Dark brand shade; outline and ghost Button text in the light theme Shared by other Core consumers; scope the override. #005fcc
--neu-primary-fg Foreground drawn over the primary background Shared by other Core consumers; scope the override. #ffffff