Anchor Design System

Menu item3.0

Menu item 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 } from '@tryg/ui-library/dist/components/anchor-link-item';
  defineCustomElement();
</script>
<anchor-menu-item url="/dashboard">
  <span slot="text">Dashboard</span>
</anchor-menu-item>

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-menu-item url="/dashboard">
  <span slot="text">Dashboard</span>
</anchor-menu-item>

Icon slot

Here's an example of how to use the Menu-Item component with an icon on the left

<anchor-menu-item url="/dashboard">
  <anchor-icon slot="icon" name="alert-circle" size="medium"></anchor-icon>
  <span slot="text">Dashboard</span>
</anchor-menu-item>

Compact

If using the "compact" version of Menu-Item, you should use a "small" size on icon component

<anchor-menu-item compact="true">
  <anchor-icon slot="icon" size="small"></anchor-icon>
  <span slot="text">Compact size</span>
</anchor-menu-item>

API

anchor-menu-item

Properties

PropertyAttributeDescriptionTypeDefault
boxboxWhether to display the link with a border.booleanfalse
compactcompactWhether to display the link in compact mode.booleanfalse
tabitab-indextabindex is a reserved name so we use tabi which will apply the tabindex attribute Default value should work fine so don't change this unless you have a really good reason to. Set to -1 to disable tabbing.number0
urlurlWhere should the user go, when clicking on the menu-item.anyundefined
uuiduuidGive this instance of menu-item a custom ID, or keep the default.stringuuidv4()

Events

EventDescriptionType
clickedEvent dispatched when link-item is clicked {querySelecter}.addEventListener('clicked', ({event}) => {console.log('clicked:', event)})CustomEvent<{ url: string; }>

CSS Custom Properties

NameDescription
--background-colorDEPRECATED: kept for backwards compatibility, but will be removed by April 2024
--borderDEPRECATED: kept for backwards compatibility, but will be removed by April 2024
--border-colorDEPRECATED: kept for backwards compatibility, but will be removed by April 2024
--border-sizeDEPRECATED: kept for backwards compatibility, but will be removed by April 2024
--border-styleDEPRECATED: kept for backwards compatibility, but will be removed by April 2024
--font-sizeDEPRECATED: kept for backwards compatibility, but will be removed by April 2024
--gapDEPRECATED: kept for backwards compatibility, but will be removed by April 2024
--menu-item-background-colorSet the background color of the menu item.
--menu-item-borderSet the shorthand for the menu item border.
--menu-item-border-colorSet the color of the menu item border.
--menu-item-border-sizeSet the size of the menu item border.
--menu-item-border-styleSet the style of the menu item border.
--menu-item-font-sizeSet the font size of the menu item.
--menu-item-gapSet the gap property of the menu item.
--menu-item-line-heightSet the line height of the menu item.
--menu-item-paddingSet the padding of the menu item.
--menu-item-radius-bottom-leftSet the bottom-left border radius of the menu item.
--menu-item-radius-bottom-rightSet the bottom-right border radius of the menu item.
--menu-item-radius-top-leftSet the top-left border radius of the menu item.
--menu-item-radius-top-rightSet the top-right border radius of the menu item.
--menu-item-text-colorSet the text color of the menu item.
--menu-item-widthSet the width of the menu item.
--paddingDEPRECATED: kept for backwards compatibility, but will be removed by April 2024
--radius-bottom-leftDEPRECATED: kept for backwards compatibility, but will be removed by April 2024
--radius-bottom-rightDEPRECATED: kept for backwards compatibility, but will be removed by April 2024
--radius-top-leftDEPRECATED: kept for backwards compatibility, but will be removed by April 2024
--radius-top-rightDEPRECATED: kept for backwards compatibility, but will be removed by April 2024
--text-colorDEPRECATED: kept for backwards compatibility, but will be removed by April 2024
--widthDEPRECATED: kept for backwards compatibility, but will be removed by April 2024

Dependencies

Depends on

Graph


Built with StencilJS

On this page