Skip to content

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

NameAttribute NameDescriptionTypeDefault Value
disableddisabledWhether the button is disabled.booleanfalse
typetypeThe type of the button.FormSubmitterType"submit"
labellabelThe accessible label for the button.string""
loadingloadingWhether the button is in a loading state.booleanfalse
sizesizeThe size of the button.| "sm"
| "md"
| "lg"
"md"
hrefhrefThe URL that the link button points to.string""
downloaddownloadThe 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""
targettargetWhere 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 attribute
of the anchor tag will automatically be set to "noopener noreferrer" to enhance
security and prevent potential tab exploitation.
| "_blank"
| "_parent"
| "_self"
| "_top"
| ""
""
autofocusautofocusIndicates that the element should be focused on page load.

https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus
booleanfalse
variantvariantThe variant style of the button.| "primary"
| "ghost"
| "naked"
| "elevated"
| "destructive"
| "brand"
"primary"

Slots

NameValueDescription
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";

Created with 🧡