Icon Button
Icon-buttons are compact components that enable users to perform actions with a single tap, using only icons to visually communicate their purpose.
Importing
To use the icon button component, first you need to register the component inside the page. You can register the component manually by importing the register function:
ts
import { register } from "@tapsioss/web-components/button/icon-button";
register(); // Now the icon button component is ready to use!
ts
import { registerIconButton } from "@tapsioss/web-components";
registerIconButton(); // Now the icon button component is ready to use!
Also you can automatically register the component by importing it with the following approach:
ts
import "@tapsioss/web-components/button/icon-button/element";
TIP
If you want to use all the component in your app, you can call registerAll
at the root of your project.
ts
import { registerAll } from "@tapsioss/web-components";
registerAll(); // All the components are now available
In the React package, you can easily add the component using the following code:
ts
import { IconButton } from "@tapsioss/react-components";
Component Usage
html
<tapsi-icon-button></tapsi-icon-button>
tsx
<IconButton />
Properties
Name | Attribute Name | Description | Type | Default Value |
---|---|---|---|---|
disabled | disabled | Whether the button is disabled. | boolean | false |
type | type | The type of the button. | FormSubmitterType | "submit" |
label | label | The accessible label for the button. | string | "" |
loading | loading | Whether the button is in a loading state. | boolean | false |
size | size | The size of the button. | | "sm" | "md" | "lg" | "md" |
href | href | The URL that the link button points to. | string | "" |
download | download | The filename to use when downloading the linked resource. If not specified, the browser will determine a filename. This is only applicable when the button is used as a link ( href is set). | string | "" |
target | target | Where to display the linked href URL for a link button. Common options include_blank to open in a new tab. When the target is set to _blank , the rel attributeof the anchor tag will automatically be set to "noopener noreferrer" to enhancesecurity and prevent potential tab exploitation. | | "_blank" | "_parent" | "_self" | "_top" | "" | "" |
autofocus | autofocus | Indicates that the element should be focused on page load. https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus | boolean | false |
variant | variant | The variant style of the button. | | "primary" | "ghost" | "naked" | "elevated" | "destructive" | "brand" | "primary" |
Slots
Name | Value | Description |
---|---|---|
DEFAULT | - | The default slot to use for the content, which must exclusively consist of an icon. |
TIP
The value of slots are available for developer as JavaScript Variables:
ts
// Option 1
import { IconButtonSlots } from "@tapsioss/web-components";
// Option 2
import { Slots } from "@tapsioss/web-components/button/icon-button";
ts
// Option 1
import { IconButtonSlots } from "@tapsioss/react-components";
// Option 2
import { Slots } from "@tapsioss/react-components/IconButton";