moonstone/ Panels
Panels provides a way to manage different screens of an app.
import Panels from '@enact/moonstone/Panels';Members
PanelsComponent
Basic Panels component without breadcrumbs or default arranger
import Panels from '@enact/moonstone/Panels';Properties
Set of functions that control how the panels are transitioned into and out of the viewport.
An object containing properties to be passed to each child.
aria-ownswill be added or updated to this object to add the close button to the accessibility tree of each panel.Panels to be rendered
Sets the hint string read when focusing the application close button.
Default: 'Exit app'The background opacity of the application close button.
Values:
'translucent','lightTranslucent','transparent'
Default: 'transparent'A slot to insert additional Panels-level buttons into the global-navigation area.
Unique identifier for the Panels instance.
When defined,
Panelswill manage the presentation state ofPanelinstances in order to restore it when returning to thePanel. See noSharedState for more details on shared state.Index of the active panel
Default: 0Disables panel transitions.
Default: falseIndicates the close button will not be rendered on the top right corner.
Default: falseCalled when the app close button is clicked.
Called with cancel/back key events.
ActivityPanelsComponent
An instance of Panels in which the Panel uses the entire viewable screen with a single breadcrumb for the previous panel when viewing any panel beyond the first.
Note ActivityPanels requires that the data-index property that all panels variations add to
its children be applied to the root DOM node of each child in order to manage layout correctly.
It is recommended that you spread any extra props on the root node but you may also handle this
property explicitly if necessary.
import {ActivityPanels} from '@enact/moonstone/Panels';AlwaysViewingPanelsComponent
An instance of Panels which restricts the Panel to the right
half of the screen with the left half used for breadcrumbs that allow navigating to previous
panels. Typically used for overlaying panels over a screen.
import {AlwaysViewingPanels} from '@enact/moonstone/Panels';BreadcrumbComponent
Vertical, transparent bar used to navigate to a prior Panel.
ActivityPanels has one breadcrumb, and AlwaysViewingPanels can have multiple stacked horizontally.
import {Breadcrumb} from '@enact/moonstone/Panels';Properties
Index of the associated panel.
Called when the breadcrumb is clicked.
The index of the clicked breadcrumb is passed in the event data.
HeaderComponent
A header component for a Panel with a title, titleBelow, and subTitleBelow
import {Header} from '@enact/moonstone/Panels';Properties
Centers the
title,titleBelow, andsubTitleBelow.This setting has no effect on the
type="compact"header.Children provided are added to the header-components area.
A space for controls which live in the header, apart from the body of the panel view.
Indents then content and removes separator lines.
Default: falseInput element that will replace the
title.This is also a slot, so it can be referred to as if it were JSX.
Note: Only applies to
type="standard"headers.Example
<Header> <title>Example Header Title</title> <headerInput> <Input dismissOnEnter /> </headerInput> <titleBelow>The Adventure Continues</titleBelow> <subTitleBelow>The rebels face attack by imperial forces on the ice planet</subTitleBelow> </Header>Hides the horizontal-rule (line) under the component
Determines what triggers the header content to start its animation.
Default: 'hover'Sub-title displayed at the bottom of the panel.
This is a slot, so it can be used as a tag-name inside this component.
Title of the header.
This is a slot, so it can be used as a tag-name inside this component.
Example:
<Header> <title>Example Header Title</title> <titleBelow>The Adventure Continues</titleBelow> <subTitleBelow>The rebels face attack by imperial forces on the ice planet</subTitleBelow> </Header>Text displayed below the title.
This is a slot, so it can be used as a tag-name inside this component.
Set the type of header to be used.
Default: 'standard'
PanelComponent
import {Panel} from '@enact/moonstone/Panels';Properties
The "aria-label" for the Panel.
By default, the panel will be labeled by its Header. When
aria-labelis set, it will be used instead to provide an accessibility label for the panel.Sets the strategy used to automatically focus an element within the panel upon render.
"none" - Automatic focus is disabled
"last-focused" - The element last focused in the panel with be restored
"default-element" - The first spottable component within the body will be focused
Custom Selector - A custom CSS selector may also be provided which will be used to find the target within the Panel
When used within Panels, this prop may be set by
Panelsto "default-element" when navigating "forward" to a higher index. This behavior may be overridden by settingautoFocuson thePanelinstance as a child ofPanelsor by wrappingPanelwith a custom component and overriding the value passed byPanels.// Panel within CustomPanel will always receive "last-focused" const CustomPanel = (props) => <Panel {...props} autoFocus="last-focused" />; // The first panel will always receive "last-focused". The second panel will receive // "default-element" when navigating from the first panel but `autoFocus` will be unset // when navigating from the third panel and as a result will default to "last-focused". const MyPanels = () => ( <Panels> <Panel autoFocus="last-focused" /> <Panel /> <Panel /> </Panels> );Default: 'last-focused'Header for the panel.
This is usually passed by the Slottable API by using a Header component as a child of the Panel.
Hides the body components.
When a Panel is used within Panels, ActivityPanels, or AlwaysViewingPanels, this property will be set automatically to
trueon render andfalseafter animating into view.Default: false
RoutableHigher-Order Component
A higher-order component that provides support for mapping Routes as children of a component
which are selected via path instead of the usual flat array.
import {Routable} from '@enact/moonstone/Panels';RouteComponent
Used with Routable to define the path segment and the
component to render.
import {Route} from '@enact/moonstone/Panels';