Anchor Design System

Icon button2.0

Icon button description

Installation

npm i @tryg/ui-library

Usage

Individual only imports the desired component, and only needs to be included once within the application. Which is beneficial to keep the application size small.

Webcomponent
<script type="module">
  import { defineCustomElement as defineCustomIconButtonElement } from '@tryg/ui-library/dist/components/anchor-icon-button';
  import { defineCustomElement as defineCustomIconElement } from '@tryg/ui-library/dist/components/anchor-icon';
  defineCustomIconButtonElement();
  defineCustomIconElement();
</script>
<anchor-icon-button buttonTitle="Close" style="color:black;">
  <anchor-icon slot="icon" name="x" size="small" />
</anchor-icon-button>

Global only needs to be defined once in the application, but it will import all components even the ones that are not in use..

Webcomponent
<script type="module">
  import { defineCustomElements } from '@tryg/ui-library/dist/loader';
  defineCustomElements();
</script>
<anchor-icon-button buttonTitle="Close" style="color:black;">
  <anchor-icon slot="icon" name="x" size="small" />
</anchor-icon-button>

Disabled

<anchor-icon-button buttonTitle="Close" disabled>
  <anchor-icon slot="icon" name="x" size="small" />
</anchor-icon-button>

On dark

<anchor-icon-button buttonTitle="Close" theme="on-dark">
  <anchor-icon slot="icon" name="x" size="small" />
</anchor-icon-button>

Slot

  • icon: The icon to display inside the button.

The Icon Button does not display an Icon on it's own. The Icon is implemented as a slot to allow total freedom.

Use the attribute slot=icon to show an Icon in Icon Button.

Example of using Icon with Icon Button:

<anchor-icon-button buttonTitle="Close">
  <anchor-icon slot="icon" name="x" size="small" />
</anchor-icon-button>

Notice that the Icon Button is designed to use an Icon in size=small.

Props

  • theme: The theme of the button. Can be "default" or "on-dark". Defaults to "default". Use "on-dark" when the Icon Button is placed on a dark background.
  • buttonTitle: The text to display when the user hovers over the button.

States

  • default: The default state of the button.
  • hover: The state of the button when the user hovers over it.
  • pressed: The state of the button when the user clicks on it.
  • focus: The state of the button when it has focus.

API

anchor-icon-button

Properties

PropertyAttributeDescriptionTypeDefault
ariaLabelaria-labelaria-label attribute for the button - used for accessibility.stringundefined
buttonTitlebutton-titleThe title text that appears on hover.stringundefined
disableddisabledSet whether or not the icon button should be disabledbooleanfalse
themethemeThe theme of the button. Can be "default" or "on"."default" | "on-dark"'default'

CSS Custom Properties

NameDescription
--focus-ring-colorChanges the color of the outline for the component
--focus-ring-offsetChanges the offset of the outline for the component
--focus-ring-styleChanges the style of the outline for the component
--focus-ring-widthChanges the size of the outline for the component
--icon-button-border-radiusSet the border radius of the
--icon-button-colorThis is the color of the icon itself
--icon-button-color-on-darkSet the color on-dark of the
--icon-button-paddingSet the padding for
--icon-button-sizeSet the size of the
--outline-overrideShorthand for changing the outline for the component

Dependencies

Used by

Graph


Built with StencilJS

On this page