Represents a clickable button, used to submit forms or anywhere in a document for accessible, standard button functionality.
The button has several visual variants. It renders as an anchor (<a>)
element when the href attribute is set. It is form-associated and can
act as a native submit or reset control.
- Element
-
igc-button
- Slots
-
default— Renders the label of the button. -
prefix— Renders content before the label of the button. -
suffix— Renders content after the label of the button.
- CSS Parts
-
base— The native button or anchor element.
Properties
Section titled "Properties"Optional command
Section titled "command"Inherited from: IgcButtonBaseComponent
The command to invoke on the target element specified by commandfor.
Part of the Invoker Commands API.
Custom commands must start with two dashes (e.g. '--my-command').
command: string Defined in src/components/button/button-base.ts:164
Optional download
Section titled "download"Inherited from: IgcButtonBaseComponent
Prompts the browser to download the linked resource rather than navigating
to it. The optional value is used as the suggested file name.
Only effective when href is set.
download: string Defined in src/components/button/button-base.ts:118
Optional href
Section titled "href"Inherited from: IgcButtonBaseComponent
The URL the button points to. When set, the component renders as an
<a> element instead of a <button>, enabling navigation on click.
Use together with target, download, and rel for full anchor semantics.
A disabled link renders a disabled <button> with the link role, because an
anchor has no disabled state.
href: string Defined in src/components/button/button-base.ts:109
Optional rel
Section titled "rel"Inherited from: IgcButtonBaseComponent
The relationship between the current document and the linked URL.
Accepts a space-separated list of link types (e.g. 'noopener noreferrer').
Only effective when href is set. When target="_blank" is used,
setting rel="noopener noreferrer" is strongly recommended for security.
rel: string Defined in src/components/button/button-base.ts:139
Optional target
Section titled "target"Inherited from: IgcButtonBaseComponent
Where to open the linked document. Only effective when href is set.
'_self'– current browsing context (default browser behavior).'_blank'– new tab or window.'_parent'– parent browsing context; falls back to_selfif none.'_top'– top-level browsing context; falls back to_selfif none.
target: "_parent" | "_top" | "_self" | "_blank" Defined in src/components/button/button-base.ts:129
Inherited from: IgcButtonBaseComponent
The type of the button, which determines its behavior and semantics.
'button'– no default action; useful for custom JavaScript handlers.'submit'– submits the associated form when clicked.'reset'– resets the associated form fields to their initial values.
Ignored when the button is rendered as a link (i.e. href is set).
type: "button" | "reset" | "submit" = 'button' Defined in src/components/button/button-base.ts:98
variant
Section titled "variant"The variant of the button which determines its visual appearance.
contained– filled background; highest visual emphasis (default).outlined– transparent background with a visible border.flat– no background or border; lowest visual emphasis.fab– floating action button shape; typically used for primary actions.
variant: ButtonVariant = 'contained' Defined in src/components/button/button.ts:47
styles
Section titled "styles"Array of styles to apply to the element. The styles should be defined using the css tag function, via constructible stylesheets, or imported from native CSS module scripts.
Note on Content Security Policy:
Element styles are implemented with <style> tags when the browser doesn't
support adopted StyleSheets. To use such <style> tags with the style-src
CSP directive, the style-src value must either include 'unsafe-inline' or
nonce-<base64-value> with <base64-value> replaced be a server-generated
nonce.
To provide a nonce to use on generated <style> elements, set
window.litNonce to a server-generated nonce in your page's HTML, before
loading application code:
``
styles: CSSResult[] Defined in src/components/button/button.ts:30
Accessors
Section titled "Accessors"commandfor
Section titled "commandfor"Inherited from: IgcButtonBaseComponent
get commandfor(): any Defined in src/components/button/button-base.ts:172
The ID of the target element for the invoker command. Part of the Invoker Commands API.
set commandfor(value: string | null): void Defined in src/components/button/button-base.ts:172
Parameters
- value:
string | null
Returns void
commandForElement
Section titled "commandForElement"Inherited from: IgcButtonBaseComponent
The target element for the invoker command. Resolved from the commandfor ID.
get commandForElement(): Element | null Defined in src/components/button/button-base.ts:191
Returns Element | null
disabled
Section titled "disabled"Inherited from: IgcButtonBaseComponent
get disabled(): any Defined in src/components/button/button-base.ts:148
Whether the button is disabled. A disabled button ignores user interaction.
set disabled(value: boolean): void Defined in src/components/button/button-base.ts:148
Parameters
- value:
boolean
Returns void
Inherited from: IgcButtonBaseComponent
The <form> element the button is associated with.
Resolved through the standard form-association mechanism - either the
closest ancestor <form> or the form referenced by the button's form
attribute. Returns null when no form is associated.
Relevant only when type is 'submit' or 'reset'.
get form(): HTMLFormElement | null Defined in src/components/button/button-base.ts:211
Returns HTMLFormElement | null
Methods
Section titled "Methods"Inherited from: IgcButtonBaseComponent
Removes focus from the button.
blur(): void Defined in src/components/button/button-base.ts:268
Returns void
click
Section titled "click"Inherited from: IgcButtonBaseComponent
Simulates a mouse click on the button, triggering its click handler and any associated form action.
click(): void Defined in src/components/button/button-base.ts:274
Returns void
focus
Section titled "focus"Inherited from: IgcButtonBaseComponent
Sets focus on the button.
focus(options: FocusOptions): void Defined in src/components/button/button-base.ts:261
Parameters
- options:
FocusOptions