Skip to main content

Button

<Button /> Component

The Button component renders a HTML <button /> element. It supports various states and styles, including loading indicators, icons, and secondary styling. This component also integrates with tooltips to provide additional help text. The Button manages its own internal state to determine if it should be disabled or if certain elements like icons should be displayed. It also supports various button types and sizes, and can handle click events and setup actions.

Usage

<Button @type="primary" @text="Click Me" @onClick={{this.doSomething}} @helpText="This button does something..." />

Events

The button has two built in events, but also supports all HTML <button /> events through the use of the {{on}} modifier.

EventDescription
onInsert

Fired when the Button is rendered and inserted into view.

Example Usage
<Button @text="Click Me" @onInsert={{this.doSomething}} />
onClick

Fired when a user clicks the button.

Example Usage
<Button @text="Click Me" @onClick={{this.doSomething}} />
<Button @text="Click Me" {{on "hover" this.doSomething}} />

Properties

PropertyTypeDescription
isLoadingBooleanIndicates whether the button is in a loading state. If true, shows a spinner and disables interactions.
disabledBooleanDetermines if the button should be disabled. If true, the button is not clickable.
typeStringSpecifies the button type. Defaults to 'default'. If set to 'secondary', the button has secondary styling.
iconStringThe icon to display within the button, shown if isLoading is false.
iconPrefixStringThe prefix for the icon, useful for specifying icon sets.
iconSizeNumberThe size of the icon.
iconRotationStringRotation angle for the icon.
iconFlipStringFlip orientation for the icon.
iconSpinBooleanWhether the icon should spin.
textStringThe text to display inside the button.
textClassStringCSS class to apply to the text element within the button.
helpTextStringText to display in a tooltip when hovering over the button.
exampleTextStringExample text to display alongside helpText in the tooltip.
tooltipPlacementStringPlacement of the tooltip relative to the button.
wrapperClassStringAdditional CSS class for the button wrapper.
outlineBooleanIf true, the button uses an outline style.
sizeStringSize of the button. Defaults to 'sm' if not specified.
buttonTypeStringThe type attribute for the button element, defaults to "button".
responsiveBooleanIf true, hides the text on smaller screens.

Types

TypeDescription
secondaryStyling for a secondary interaction.
primaryStyling for a primary interaction.
successStyling for a successful interaction.
warningStyling for a warning interaction.
dangerStyling for a dangerous interaction.
magicStyling for a "magical" interaction.
blackStyling for a dark styled button.
transparentStyling for a transparent styled button.
linkStyling to render the button as a link (no margin, padding, borders, shadow, or background).