Class AppLayout
- All Implemented Interfaces:
AttachNotifier,DetachNotifier,HasElement,HasStyle,RouterLayout,Serializable
The layout consists of three sections: a horizontal navigation bar (navbar), a collapsible navigation drawer (drawer) and a content area. An application?s main navigation blocks should be positioned in the navbar and/or drawer while views are rendered in the content area.
App Layout is responsive and adjusts automatically to fit desktop, tablet, and mobile screen sizes.
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe internationalization properties forAppLayoutstatic enumSections in the component that can be used as primary. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToDrawer(Component... components) Adds the components to the drawer slot of this AppLayout.voidaddToNavbar(boolean touchOptimized, Component... components) Adds the components to the navbar slot of this AppLayout.voidaddToNavbar(Component... components) Adds the components to the navbar slot of this AppLayout.protected voidCalled after a navigation event.getI18n()Gets the internationalization object previously set for this component.booleanWhether the drawer is opened (visible) or not.booleanNote: This property is controlled via CSS and can not be changed directly.protected voidonAttach(AttachEvent attachEvent) Called when the component is attached to a UI.voidRemoves the child components from the parent.voidsetContent(Component content) Sets the displayed content.voidsetDrawerOpened(boolean drawerOpened) Server-side API for showing and hiding the drawer.voidSets the internationalization object for this component.voidsetPrimarySection(AppLayout.Section primarySection) Defines whether navbar or drawer will come first visually.voidshowRouterLayoutContent(HasElement content) Shows the content of the layout which is the router target component annotated with a@Route.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, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.router.RouterLayout
removeRouterLayoutContent
-
Constructor Details
-
AppLayout
public AppLayout()
-
-
Method Details
-
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(AppLayoutI18n)- Returns:
- the i18n object or
nullif no i18n object has been set
-
setI18n
Sets the internationalization object for this component.- Parameters:
i18n- the i18n object, notnull
-
onAttach
Description copied from class:ComponentCalled when the component is attached to a UI.This method is invoked before the
Make sure to callAttachEventis fired for the component.super.onAttachwhen overriding this method. -
getPrimarySection
- Returns:
- value for the primarySection property. Default is
AppLayout.Section.NAVBAR. - See Also:
-
setPrimarySection
Defines whether navbar or drawer will come first visually.- If
AppLayout.Section.NAVBAR, the navbar takes the full available width and moves the drawer down. This is the default. - If
AppLayout.Section.DRAWERis set, then the drawer will move the navbar, taking the full available height.
- Parameters:
primarySection- new value for the primarySection property. Notnull.- Throws:
NullPointerException- if primarySection isnull.
- If
-
isDrawerOpened
Whether the drawer is opened (visible) or not. Its default value depends on the viewport:truefor desktop size viewsfalsefor mobile size views
- Returns:
trueif the drawer is opened (visible).falseotherwise.
-
setDrawerOpened
public void setDrawerOpened(boolean drawerOpened) Server-side API for showing and hiding the drawer.- Parameters:
drawerOpened- new value for the drawerOpened property.- See Also:
-
isOverlay
Note: This property is controlled via CSS and can not be changed directly.- Returns:
trueif drawer is an overlay on top of the content.falseotherwise.
-
getContent
- Returns:
- the displayed content
-
setContent
Sets the displayed content.- Parameters:
content-Componentto display in the content area
-
addToDrawer
Adds the components to the drawer slot of this AppLayout.- Parameters:
components- Components to add to the drawer slot.- Throws:
NullPointerException- if any of the components is null or if the components array is null.
-
remove
Removes the child components from the parent. Components can be in any slot or be the main content.- Parameters:
components- Components to remove.
-
showRouterLayoutContent
Shows the content of the layout which is the router target component annotated with a@Route.Note implementors should not care about old
@Routecontent, since it's handled separately byRouterLayout.removeRouterLayoutContent(HasElement)which by default simply removes the old content.- Specified by:
showRouterLayoutContentin interfaceRouterLayout- Parameters:
content- the content component ornullif the layout content is to be cleared.- Throws:
IllegalArgumentException- if content is not aComponent
-