Class SideNav

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

@Tag("vaadin-side-nav") @NpmPackage(value="@vaadin/side-nav", version="24.8.2") @JsModule("@vaadin/side-nav/src/vaadin-side-nav.js") public class SideNav extends Component implements HasSideNavItems, HasSize, 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:
  • 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