com.vaadin.flow.component.sidenav.
Class SideNav
All Implemented Interfaces:
AttachNotifier
, DetachNotifier
, HasElement
, HasSize
, HasStyle
, Serializable
A side navigation menu with support for hierarchical and flat menus.
Items can be added using 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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addItem
(SideNavItem... items) Adds navigation menu item(s) to the menu.
void
addItemAsFirst
(SideNavItem item) Adds the given navigation item as the first child of this navigation item.
void
addItemAtIndex
(int index, SideNavItem item) Adds the given item as child of this navigation item at the specific index.
getI18n()
Gets the internationalization object previously set for this component.
getItems()
Gets the items added to this navigation item (the children of this component that are instances of
SideNavItem
).getLabel()
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
remove
(SideNavItem... items) Removes the menu item(s) from the menu.
void
Removes all navigation menu items from this item.
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
setI18n
(SideNav.SideNavI18n i18n) Updates the i18n settings in the web component.
void
Set a textual label for this side navigation menu.
protected void
setupSideNavItem
(SideNavItem item) Implement this method to set up/modify the SideNavItem right before it's added to the list of the navigation items.
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.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
Creates a new menu with the given label.
Parameters:
label
- the label to use
-
-
Method Details
-
getLabel
Gets the label of this side navigation menu.
Returns:
the label or null if no label has been set
-
setLabel
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
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
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 -
getItems
Gets the items added to this navigation item (the children of this component that are instances of
SideNavItem
). This doesn't include the items added to the children of this navigation item.Returns:
the child
SideNavItem
instances in this navigation menuSee Also:
-
removeAll
public void removeAll()Removes all navigation menu items from this item.
-