icon the icon to be displayed on the left side of the menu item. The icon prop accepts either an object imported from the FontAwesome icon packs, or a string specifying one of the preloaded, core icons
** Note: If no href or to value is provided, the menu item will be plain text and will emit a click event for you to hook into
With Icons Using Default Slot
With Icons Using Items Prop
<template><divclass="flex gap-8"><div><AisMenulabel="With Icons Using Default Slot"><AisMenuItemlabel="Search"icon="search"href="/search"></AisMenuItem><AisMenuItemlabel="Save"icon="save"href="/save"></AisMenuItem><AisMenuItemlabel="Delete"icon="delete"to="/delete"></AisMenuItem><AisMenuItemlabel="Using a non-core icon":icon="faApple"to="/apple"></AisMenuItem><AisMenuItemlabel="Cancel"icon="cancel"@click="handleCancel"></AisMenuItem></AisMenu></div><div><AisMenulabel="With Icons Using Items Prop":items="iconItems"></AisMenu></div></div></template><scriptsetup>import{ ref }from'vue'import AisMenu from"@/components/menu/AisMenu.vue";import AisMenuItem from"@/components/menu/AisMenuItem.vue";import{ faApple }from"@fortawesome/free-brands-svg-icons";import{ library }from'@fortawesome/fontawesome-svg-core'
library.add(faApple)const iconItems =ref([{key:'search',label:'Search',icon:'search',href:'/search'},{key:'save',label:'Save',icon:'save',href:'/save'},{key:'delete',label:'Delete',icon:'save',to:'/delete'},{key:'apple',label:'Using a non-core icon',icon: faApple,to:'/apple'},{key:'close',label:'Close',icon:"cancel"},])consthandleCancel=(e)=>{
console.log(`handleCancel: ${e}`)}</script><script>exportdefault{name:"AisMenuIcons",}</script>
Use the AisDivider component for adding a divider to a menu. When using the items prop for generating your menu, just add an item with type: 'divider'. The divider color is set to bg-ui-gray-100
To build the menu using the default slot, just pass any combination of AisMenuItem, AisMenuGroup, or AisMenuDivider components into the default slot of the AisMenu component
The items prop allows you to define your menu structure in a JavaScript Array instead of using the default slot. In the background the AisMenu component will iterate through your array of items and define the menu contents using the menu subcomponents.
buttonClass prop is for adding classes to the menu button
icon prop is for specifying the icon to be displayed on the left side of the menu button. It accepts either an object imported from the FontAwesome icon packs, or a string specifying one of the preloaded, core icons
The menu you can align on the left or right side of the menu button. The default is for the menu to align with the left side. Use the right prop to have the menu align with the right side of the menu button. This prop is a boolean prop, so it does not require a value. The buttons are styled here to make it easier to see the effect.
Align Left (default)
Align to the Right
<template><divclass="flex gap-12"><div><AisMenulabel="Align Left (default)"button-class="p-2 gap-2 border border-blue-400":items="items"></AisMenu></div><div><AisMenulabel="Align to the Right"button-class="p-2 gap-2 border border-blue-400":items="items"right></AisMenu></div></div></template><scriptsetup>import AisMenu from"@/components/menu/AisMenu.vue";import{ items }from"@/components/menu/examples/example-items.js"</script><script>exportdefault{name:"AisMenuAlignment",}</script>