Class SideNav

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.sidenav.SideNav
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, HasSideNavItems, Serializable

@Tag("vaadin-side-nav") @NpmPackage(value="@vaadin/side-nav", version="25.0.0-alpha16") @JsModule("@vaadin/side-nav/src/vaadin-side-nav.js") public class SideNav extends com.vaadin.flow.component.Component implements HasSideNavItems, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle
A side navigation menu with support for hierarchical and flat menus.

Items can be added using HasSideNavItems.addItem(SideNavItem...) and hierarchy can be created by adding SideNavItem instances to other SideNavItem instances.

Author:
Vaadin Ltd
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    The internationalization properties for SideNav.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new menu without any label.
    SideNav(String label)
    Creates a new menu with the given label.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the internationalization object previously set for this component.
    Gets the label of this side navigation menu.
    boolean
    Check if the end user is allowed to collapse/hide and expand/show the navigation items.
    boolean
    Returns whether the side navigation menu is expanded or collapsed.
    void
    setCollapsible(boolean collapsible)
    Allow the end user to collapse/hide and expand/show the navigation items.
    void
    setExpanded(boolean expanded)
    Expands the side navigation menu.
    void
    Updates the i18n settings in the web component.
    void
    Set a textual label for this side navigation menu.

    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.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.sidenav.HasSideNavItems

    addItem, addItemAsFirst, addItemAtIndex, getItems, remove, removeAll

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

    getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull

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

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

    • SideNav

      public SideNav()
      Creates a new menu without any label.
    • SideNav

      public SideNav(String label)
      Creates a new menu with the given label.
      Parameters:
      label - the label to use
  • Method Details

    • getLabel

      public String getLabel()
      Gets the label of this side navigation menu.
      Returns:
      the label or null if no label has been set
    • setLabel

      public void setLabel(String label)
      Set a textual label for this side navigation menu.

      This label can help the end user to distinguish groups of navigation items. The label is also available for screen reader users.

      Parameters:
      label - the label text to set; or null to remove the label
    • isCollapsible

      public boolean isCollapsible()
      Check if the end user is allowed to collapse/hide and expand/show the navigation items.

      NOTE: The navigation has to have a label for it to be collapsible.

      Returns:
      true if the menu is collapsible, false otherwise
    • setCollapsible

      public void setCollapsible(boolean collapsible)
      Allow the end user to collapse/hide and expand/show the navigation items.

      NOTE: The navigation has to have a label for it to be collapsible.

      Parameters:
      collapsible - true to make the whole navigation component collapsible, false otherwise
    • isExpanded

      @Synchronize(property="collapsed", value="collapsed-changed", allowInert=true) public boolean isExpanded()
      Returns whether the side navigation menu is expanded or collapsed.
      Returns:
      true if the side navigation menu is expanded, false if collapsed
    • setExpanded

      public void setExpanded(boolean expanded)
      Expands the side navigation menu.

      If the side navigation menu does not have a label, does nothing.

    • getI18n

      public SideNav.SideNavI18n getI18n()
      Gets the internationalization object previously set for this component.

      NOTE: Updating the instance that is returned from this method will not update the component if not set again using setI18n(SideNavI18n)

      Returns:
      the i18n object or null if no i18n object has been set
    • setI18n

      public void setI18n(SideNav.SideNavI18n i18n)
      Updates the i18n settings in the web component. Merges the SideNav.SideNavI18n settings with the current / default settings of the web component.
      Parameters:
      i18n - the i18n object, not null