Class SubViewHeader
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.ClickNotifier<com.vaadin.flow.component.html.Header>, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasComponents, com.vaadin.flow.component.HasComponentsOfType<com.vaadin.flow.component.Component>, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasOrderedComponents, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasText, Serializable
A small mobile-first application often has no navigation shell: the front page is the menu, and every other view sits one level below it. What such a view needs at the top is a way up and its own name, and iOS settled the form years ago — a chevron in a circle of glass, the title beside it, floating over the content as it scrolls.
Only the arrow gets the glass. A first draft put the arrow and the title in one shared pill, and it read as a single button whose label was the name of the view you were already on — a back button to the place you are at. The title is bare text, as in iOS's current form language: the circle says "control", the undecorated word says "name", and the difference in dress is what keeps them apart.
The back control is an arrow alone. The word next to it ("Devices",
"Back") is dead weight once the gesture is learned, which on a phone is the
first time it is used — but a control with no text still has to say where it
goes, so the destination's name travels as the link's aria-label
instead of as pixels.
The bar is position: sticky: it scrolls away with the page until
it would leave, then stays — its offset counts the safe area, so an installed
PWA does not park the arrow under a phone's camera cutout — and the content
slides underneath, dissolving into a veil of blur rather than hitting an
edge. The bar itself takes no clicks; between the pieces, the page underneath
does. On the Aura theme the glass is built from the theme's own surface
tokens; on any other theme the fallbacks make a plain translucent circle and
nothing breaks.
The title is an <h1>: on a view like this it is the page's main
heading, and the document outline should say so.
NavigationView is the view around this bar, for the classes that
would rather inherit the whole arrangement than compose it.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasText
com.vaadin.flow.component.HasText.WhiteSpace -
Constructor Summary
ConstructorsConstructorDescriptionSubViewHeader(Class<? extends com.vaadin.flow.component.Component> backTarget, String backLabel) SubViewHeader(String title, Class<? extends com.vaadin.flow.component.Component> backTarget, String backLabel) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAction(com.vaadin.flow.component.Component... components) Puts the view's own controls at the right edge of the bar, mirroring the way back.<T, C extends com.vaadin.flow.component.Component & com.vaadin.flow.router.HasUrlParameter<T>>
voidsetBackTarget(Class<? extends C> backTarget, T parameter) The way back for a view more than one level down, where "up" is itself a parameterised route — a detail view's sub-view goes back to/thing/42, not to/thing.voidSeparate from construction because a title from a URL parameter arrives later.Methods inherited from class com.vaadin.flow.component.HtmlComponent
getTitleMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisibleMethods inherited from class 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.ClickNotifier
addClickListener, addClickShortcut, addDoubleClickListener, addSingleClickListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasComponents
addMethods inherited from interface com.vaadin.flow.component.HasComponentsOfType
add, add, addComponentAsFirst, addComponentAtIndex, bindChildren, getChildren, getComponentAt, getComponentCount, indexOf, remove, remove, removeAll, replaceMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasSize
bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasText
bindText, getText, getWhiteSpace, setText, setWhiteSpace
-
Constructor Details
-
SubViewHeader
-
SubViewHeader
-
-
Method Details
-
setTitle
Separate from construction because a title from a URL parameter arrives later.- Overrides:
setTitlein classcom.vaadin.flow.component.HtmlComponent
-
setBackTarget
public <T, C extends com.vaadin.flow.component.Component & com.vaadin.flow.router.HasUrlParameter<T>> void setBackTarget(Class<? extends C> backTarget, T parameter) The way back for a view more than one level down, where "up" is itself a parameterised route — a detail view's sub-view goes back to/thing/42, not to/thing. Separate from construction for the same reason as the title: the parameter comes from the URL, which the view only sees later. -
addAction
public void addAction(com.vaadin.flow.component.Component... components) Puts the view's own controls at the right edge of the bar, mirroring the way back. Icon-only buttons arrive dressed by the stylesheet as the arrow's twin; ones with text become pills.
-