Icon Container4.0
A container component that wraps icons with consistent sizing, theming, and interactive behavior.
Ads by Tryg Careers
Installation
npm i @tryg/vue-ui-libraryUsage
Install the component library as a Vue plugin. This globally registers all Anchor components.
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');<template>
<anchor-icon-container button-title="Close">
<anchor-icon name="x" size="small"></anchor-icon>
</anchor-icon-container>
</template>Import only the components you need for optimal bundle size.
<script setup>
import { AnchorIconContainer, AnchorIcon } from '@tryg/vue-ui-library';
</script>
<template>
<anchor-icon-container button-title="Close">
<anchor-icon name="x" size="small"></anchor-icon>
</anchor-icon-container>
</template>Disabled
<template>
<anchor-icon-container button-title="Close" disabled>
<anchor-icon name="x" size="small"></anchor-icon>
</anchor-icon-container>
</template>On Dark
<template>
<anchor-icon-container button-title="Close" theme="on-dark">
<anchor-icon name="x" size="small"></anchor-icon>
</anchor-icon-container>
</template>Slot
Example of using Icon with Icon Container:
<template>
<anchor-icon-container button-title="Close">
<anchor-icon name="x" size="small"></anchor-icon>
</anchor-icon-container>
</template>Notice that the Icon Container 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 Container is placed on a dark background.
- button-title: 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
- The icon container renders as a native
<button>element, providing inherent keyboard support and focus management. - Use the
ariaLabelprop to provide an accessible name for screen readers. This is especially important when the icon conveys an action that isn't otherwise described in visible text. - The
titleprop provides hover text for mouse users but does not replaceariaLabelfor screen reader users. Use both for the best experience. - Keyboard event support for Tab to focus, and Enter / Space to activate.
- When
disabledis set, the button removes itself from the tab order and ignores keyboard and mouse events, consistent with native disabled button behavior.
API
anchor-icon-container
Properties
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
ariaLabel | aria-label | aria-label attribute for the icon container - used for accessibility. | string | undefined |
disabled | disabled | Set whether or not the icon container should be disabled | boolean | false |
size | size | The size of the icon container. Can be "md". | "normal" | 'normal' |
theme | theme | The theme of the icon container. Can be "default" or "on-dark". | "default" | "on-dark" | 'default' |
title | title | The title text that appears on hover. | string | undefined |
variant | variant | The theme of the icon container. Can be "default" or "brand". | "brand" | "default" | 'default' |
Dependencies
Used by
Graph
graph TD;
anchor-navigation-card --> anchor-icon-container
style anchor-icon-container fill:#f9f,stroke:#333,stroke-width:4pxBuilt with StencilJS
Icon
The Anchor Icons help maintain visual consistency across our applications and platforms by providing a unified language for conveying information.
Select Item
AnchorSelectItem is used inside an AnchorSelect component to define individual dropdown options with support for icons, descriptions, disabled state, and selection tracking.
