laravel-menu icon indicating copy to clipboard operation
laravel-menu copied to clipboard

how to make menu with icon

Open NguyenDucTruong123 opened this issue 1 year ago • 1 comments

Hi everybody . I want to build a menu and have an icon. So how should I do it? I don't know how to pass pictures in I have the code

private function createMenus($menu, $aMenus, $parent_id) { foreach ($aMenus as $oMenu) { if ($oMenu->parent_id == $parent_id) { $submenu = $menu->add($oMenu->name, "danh-muc-san-pham/" . $oMenu->path); $this->createMenus($submenu, $aMenus, $oMenu->id); } } }

NguyenDucTruong123 avatar Jul 21 '23 03:07 NguyenDucTruong123

You should use prepend() to add icon before link or append() to add icon after link. For example using FontAwaresome Icons: $menu->add($oMenu->name, "danh-muc-san-pham/" . $oMenu->path)->prepend('<i class="fa-solid fa-briefcase"></i>');

Or another way, you can use only icon without text, replace $oMenu->name with the icons tag:
$menu->add('<i class="fa-solid fa-briefcase"></i>', "danh-muc-san-pham/" . $oMenu->path); Hope this help.

nkhoangvu avatar May 31 '24 08:05 nkhoangvu