Web Components Icon Button Overview

    The Ignite UI for Web Components Icon Button component allows developers to use registered icons as buttons in their application. It carries all features of the icon component but adds features from the button component as well.

    Web Components Icon Button Example

    EXAMPLE
    TS
    HTML
    IconButtonSize.css
    index.css

    Like this sample? Get access to our complete Ignite UI for Web Components toolkit and start building your own apps in minutes. Download it for free.

    Usage

    First, you need to install the Ignite UI for Web Components by running the following command:

    npm install igniteui-webcomponents
    cmd

    Before using the IgcIconButtonComponent, you need to register it as follows:

    import { defineComponents, IgcIconButtonComponent } from "igniteui-webcomponents";
    import 'igniteui-webcomponents/themes/light/bootstrap.css';
    
    defineComponents(IgcIconButtonComponent);
    ts

    For a complete introduction to the Ignite UI for Web Components, read the Getting Started topic.

    The simplest way to start using the IgcIconButtonComponent is as follows:

    <igc-icon-button name="thumb-up" collection="material"></igc-icon-button>
    html
    Ignite UI for Web Components | CTA Banner

    Examples

    Variant

    Similar to the regular button components, the icon button supports several variants - flat (default), contained, and outlined; To change the icon button type set the variant attribute of the icon button.

    EXAMPLE
    TS
    HTML
    CSS

    <igc-icon-button name="search" variant="contained"></igc-icon-button>
    html

    Size

    The size of the button can be changed by utilizing the --ig-size CSS variable to any of the three supported sizes: --ig-size-small, --ig-size-medium, --ig-size-large(default).

    EXAMPLE
    TS
    HTML
    IconButtonSize.css
    index.css

    igc-icon-button {
        --ig-size: var(--ig-size-medium);
    }
    css

    Type

    The icon button component will change its internal structure from <button> to an <a> type element when the href attribute is set. In that case the icon button can be thought of as a regular link. Setting the href attribute will allow you to also set the rel, target, and download attributes of the icon button.

    <igc-icon-button
      name="thumb-up"
      collection="material"
      href="https://duckduckgo.com"
      target="_blank">
    </igc-icon-button>
    html

    Mirrored

    Some icons need to look a little different when used in Right-to-Left(RTL) mode. For that reason we provide a mirrored attribute that, when set, flips the icon button horizontally.

    <igc-icon-button name="thumb-up" mirrored></igc-icon-button>
    html

    Styling

    The IgcIconButtonComponent component exposes two CSS parts - base and icon that allow you to style the wrapping element (<button> or <a>) and the wrapped <igc-icon> element.

    igc-icon-button[variant="contained"]:not([disabled])::part(base) {
      padding: 12px;
      background-color: var(--ig-success-500);
    }
    
    igc-icon-button::part(icon) {
      --size: 22px;
      color: var(--ig-success-500-contrast);
    }
    css

    EXAMPLE
    TS
    HTML
    IconButtonStyling.css
    index.css

    API References

    Additional Resources