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
arranger

Set of functions that control how the panels are transitioned into and out of the viewport.

childProps
Object

An object containing properties to be passed to each child.

aria-owns will be added or updated to this object to add the close button to the accessibility tree of each panel.

children
Node

Panels to be rendered

closeButtonAriaLabel
String

Sets the hint string read when focusing the application close button.

Default: 'Exit app'
closeButtonBackgroundOpacity
String

The background opacity of the application close button.

  • Values: 'translucent', 'lightTranslucent', 'transparent'

Default: 'transparent'
controls
Node

A slot to insert additional Panels-level buttons into the global-navigation area.

id
String

Unique identifier for the Panels instance.

When defined, Panels will manage the presentation state of Panel instances in order to restore it when returning to the Panel. See noSharedState for more details on shared state.

index
Number

Index of the active panel

Default: 0
noAnimation
Boolean

Disables panel transitions.

Default: false
noCloseButton
Boolean

Indicates the close button will not be rendered on the top right corner.

Default: false
noSharedState
Boolean

Prevents maintaining shared state for framework components within this Panels instance.

When false, each Panel will track the state of some framework components in order to restore that state when the Panel is recreated. For example, the scroll position of a moonstone/Scroller within a Panel will be saved and restored when returning to that Panel.

This only applied when navigating "back" (to a lower index) to Panel. When navigating "forwards" (to a higher index), the Panel and its contained components will use their default state.

Default: false
onApplicationClose
Function

Called when the app close button is clicked.

onBack
Function

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';

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

A header component for a Panel with a title, titleBelow, and subTitleBelow

import {Header} from '@enact/moonstone/Panels';
Properties
centered
Boolean

Centers the title, titleBelow, and subTitleBelow.

This setting has no effect on the type="compact" header.

children
ArrayElementElement

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.

fullBleed
Boolean

Indents then content and removes separator lines.

Default: false
headerInput
Node

Input 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>
hideLine
Boolean

Hides the horizontal-rule (line) under the component

marqueeOn
'focus''hover''render'

Determines what triggers the header content to start its animation.

Default: 'hover'
subTitleBelow
String

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
String

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>
titleBelow
String

Text displayed below the title.

This is a slot, so it can be used as a tag-name inside this component.

type
'compact''dense''standard'

Set the type of header to be used.

Default: 'standard'

PanelComponent

A Panel is the standard view container used inside a Panels view manager instance.

Panels will typically contain several instances of these and transition between them.

import {Panel} from '@enact/moonstone/Panels';
Properties
aria-label
String

The "aria-label" for the Panel.

By default, the panel will be labeled by its Header. When aria-label is set, it will be used instead to provide an accessibility label for the panel.

autoFocus
String

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 Panels to "default-element" when navigating "forward" to a higher index. This behavior may be overridden by setting autoFocus on the Panel instance as a child of Panels or by wrapping Panel with a custom component and overriding the value passed by Panels.

// 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
Header

Header for the panel.

This is usually passed by the Slottable API by using a Header component as a child of the Panel.

hideChildren
Boolean

Hides the body components.

When a Panel is used within Panels, ActivityPanels, or AlwaysViewingPanels, this property will be set automatically to true on render and false after animating into view.

Default: false
noSharedState
Boolean

Prevents the component from restoring any framework shared state.

When false, the default, Panel will store state for some framework components in order to restore that state when returning to the Panel. Setting this prop to true will suppress that behavior and not store or retrieve any framework component state.

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 moonstone/Panels.Routable to define the path segment and the component to render.

import {Route} from '@enact/moonstone/Panels';
ArrayBooleanFunctionModuleNumberObjectString