Anchor Design System

Icon button2.0

Icon button description

Installation

npm i @tryg/vue-ui-library

Usage

Install the component library as a Vue plugin. This globally registers all Anchor components.

main.js
import { createApp } from 'vue';
import { ComponentLibrary } from '@tryg/vue-ui-library';
import App from './App.vue';

const app = createApp(App);
app.use(ComponentLibrary);
app.mount('#app');
YourComponent.vue
<template>
  <anchor-icon-button button-title="Close">
    <anchor-icon slot="icon" name="x" size="small" />
  </anchor-icon-button>
</template>

Import only the components you need for optimal bundle size.

YourComponent.vue
<script setup>
import { AnchorIconButton, AnchorIcon } from '@tryg/vue-ui-library';
</script>
<template>
  <anchor-icon-button button-title="Close">
    <anchor-icon slot="icon" name="x" size="small" />
  </anchor-icon-button>
</template>

Disabled

Vue component
<script setup>
import { AnchorIconButton, AnchorIcon } from '@tryg/vue-ui-library';
</script>
<template>
  <anchor-icon-button button-title="Close" disabled>
    <anchor-icon slot="icon" name="x" size="small" />
  </anchor-icon-button>
</template>

On dark

Vue component
<script setup>
import { AnchorIconButton, AnchorIcon } from '@tryg/vue-ui-library';
</script>
<template>
  <anchor-icon-button button-title="Close" theme="on-dark">
    <anchor-icon slot="icon" name="x" size="small" />
  </anchor-icon-button>
</template>

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:

Vue component
<script setup>
import { AnchorIconButton, AnchorIcon } from '@tryg/vue-ui-library';
</script>
<template>
  <anchor-icon-button button-title="Close">
    <anchor-icon slot="icon" name="x" size="small" />
  </anchor-icon-button>
</template>

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.

Accessibility

  • Renders as a native <button> element by default, inheriting standard button semantics including role and keyboard behavior.
  • Keyboard support: Enter and Space activate the button when it has focus.
  • Always provide an ariaLabel prop to give screen readers a meaningful description, since icon-only buttons lack visible text.
  • The buttonTitle prop sets the title attribute on the button, providing a tooltip on hover for visual users.
  • When disabled, the button receives the native disabled attribute, making it both non-interactive and skipped by keyboard navigation.

CSS variables

The following CSS custom properties are exposed:

VariableDescription
--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-backgroundSet the background color of the <anchor-icon-button>
--icon-button-background-hoverSet the hover background color of the <anchor-icon-button>
--icon-button-background-on-darkSet the background color on-dark of the <anchor-icon-button>
--icon-button-background-on-dark-hoverSet the hover background color on-dark of the <anchor-icon-button>
--icon-button-background-on-dark-pressedSet the pressed background color on-dark of the <anchor-icon-button>
--icon-button-background-ressedSet the pressed background color of the <anchor-icon-button>
--icon-button-border-radiusSet the border radius of the <anchor-icon-button>
--icon-button-colorThis is the color of the icon itself
--icon-button-color-activeThis is the hover color of the icon itself
--icon-button-color-hoverThis is the hover color of the icon itself
--icon-button-color-on-darkSet the color on-dark of the <anchor-icon-button>
--icon-button-color-on-dark-hoverSet the hover color on-dark of the <anchor-icon-button>
--icon-button-color-on-dark-pressedSet the pressed color on-dark of the <anchor-icon-button>
--icon-button-paddingSet the padding for <anchor-icon-button>
--icon-button-sizeSet the size of the <anchor-icon-button>
--outline-overrideShorthand for changing the outline for the component

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
tagtagOverrides the root tag element of the component.stringundefined
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-backgroundSet the background color of the
--icon-button-background-hoverSet the hover background color of the
--icon-button-background-on-darkSet the background color on-dark of the
--icon-button-background-on-dark-hoverSet the hover background color on-dark of the
--icon-button-background-on-dark-pressedSet the pressed background color on-dark of the
--icon-button-background-ressedSet the pressed background color of the
--icon-button-border-radiusSet the border radius of the
--icon-button-colorThis is the color of the icon itself
--icon-button-color-activeThis is the hover color of the icon itself
--icon-button-color-hoverThis is the hover color of the icon itself
--icon-button-color-on-darkSet the color on-dark of the
--icon-button-color-on-dark-hoverSet the hover color on-dark of the
--icon-button-color-on-dark-pressedSet the pressed 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

graph TD;
  anchor-help-box --> anchor-icon-button
  anchor-navigation-card --> anchor-icon-button
  anchor-notification-banner --> anchor-icon-button
  anchor-quantity --> anchor-icon-button
  style anchor-icon-button fill:#f9f,stroke:#333,stroke-width:4px

Built with StencilJS

On this page