Class AppNavItem

java.lang.Object
com.vaadin.flow.component.Component
com.gruppox.pissir23.components.appnav.AppNavItem
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasStyle, Serializable

@JsModule("@vaadin-component-factory/vcf-nav") @Tag("vcf-nav-item") public class AppNavItem extends com.vaadin.flow.component.Component
A menu item for the AppNav component.

Can contain a label and/or an icon and links to a given path.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a menu item which does not link to any view but only shows the given label.
    AppNavItem(String label, Class<? extends com.vaadin.flow.component.Component> view)
    Creates a new menu item using the given label that links to the given view.
    AppNavItem(String label, Class<? extends com.vaadin.flow.component.Component> view, com.vaadin.flow.component.Component icon)
    Creates a new menu item using the given label that links to the given view.
    AppNavItem(String label, String path)
    Creates a new menu item using the given label that links to the given path.
    AppNavItem(String label, String path, com.vaadin.flow.component.Component icon)
    Creates a new menu item using the given label and icon that links to the given path.
  • Method Summary

    Modifier and Type
    Method
    Description
    addItem(AppNavItem... appNavItems)
    Adds menu item(s) inside this item, creating a hierarchy.
    Gets the label for the item.
     
    Removes all menu items from this item.
    removeItem(AppNavItem appNavItem)
    Removes the given menu item from this item.
    setExpanded(boolean value)
    Sets the expanded status of the item.
    setIcon(com.vaadin.flow.component.Component icon)
    Sets the icon for the item.
    Set a textual label for the item.
    setPath(Class<? extends com.vaadin.flow.component.Component> view)
    Sets the view this item links to.
    Sets the path this item links to.

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
  • Constructor Details

    • AppNavItem

      public AppNavItem(String label)
      Creates a menu item which does not link to any view but only shows the given label.
      Parameters:
      label - the label for the item
    • AppNavItem

      public AppNavItem(String label, String path)
      Creates a new menu item using the given label that links to the given path.
      Parameters:
      label - the label for the item
      path - the path to link to
    • AppNavItem

      public AppNavItem(String label, Class<? extends com.vaadin.flow.component.Component> view)
      Creates a new menu item using the given label that links to the given view.
      Parameters:
      label - the label for the item
      view - the view to link to
    • AppNavItem

      public AppNavItem(String label, String path, com.vaadin.flow.component.Component icon)
      Creates a new menu item using the given label and icon that links to the given path.
      Parameters:
      label - the label for the item
      path - the path to link to
      icon - the icon for the item
    • AppNavItem

      public AppNavItem(String label, Class<? extends com.vaadin.flow.component.Component> view, com.vaadin.flow.component.Component icon)
      Creates a new menu item using the given label that links to the given view.
      Parameters:
      label - the label for the item
      view - the view to link to
      icon - the icon for the item
  • Method Details

    • addItem

      public AppNavItem addItem(AppNavItem... appNavItems)
      Adds menu item(s) inside this item, creating a hierarchy.
      Parameters:
      appNavItems - the menu item(s) to add
      Returns:
      this item for chaining
    • removeItem

      public AppNavItem removeItem(AppNavItem appNavItem)
      Removes the given menu item from this item.

      If the given menu item is not a child of this menu item, does nothing.

      Parameters:
      appNavItem - the menu item to remove
      Returns:
      this item for chaining
    • removeAllItems

      public AppNavItem removeAllItems()
      Removes all menu items from this item.
      Returns:
      this item for chaining
    • getLabel

      public String getLabel()
      Gets the label for the item.
      Returns:
      the label or null if no label has been set
    • setLabel

      public AppNavItem setLabel(String label)
      Set a textual label for the item.

      The label is also available for screen rader users.

      Parameters:
      label - the label to set
      Returns:
      this instance for chaining
    • setPath

      public AppNavItem setPath(String path)
      Sets the path this item links to.
      Parameters:
      path - the path to link to
      Returns:
      this instance for chaining
    • setPath

      public AppNavItem setPath(Class<? extends com.vaadin.flow.component.Component> view)
      Sets the view this item links to.
      Parameters:
      view - the view to link to
      Returns:
      this instance for chaining
    • getPath

      public String getPath()
    • setIcon

      public AppNavItem setIcon(com.vaadin.flow.component.Component icon)
      Sets the icon for the item.

      Can also be used to set a custom component to be shown in front of the label.

      Parameters:
      icon - the icon to show
      Returns:
      this instance for chaining
    • setExpanded

      public AppNavItem setExpanded(boolean value)
      Sets the expanded status of the item.
      Parameters:
      value - true to expand the item, false to collapse it