Introducing PrimeReact v11-alpha 🎉Discover Now

Panel

An unstyled, accessible panel component with optional collapsible content.

Build fully custom content panels with complete control over layout and styling.

Header
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
basic-demo

Pre-styled Versions

Choose a pre-styled library to use Panel with ready-made designs.
For hook-based usage without components, see the Headless API.

Features#

  • Compound component API with seven sub-components: Root, Header, Title, Trigger, Indicator, Content, Footer

Usage#

import { Panel } from 'primereact/panel';
<Panel.Root>
    <Panel.Header>
        <Panel.Title />
        <Panel.Trigger>
            <Panel.Indicator />
        </Panel.Trigger>
    </Panel.Header>
    <Panel.Content />
    <Panel.Footer />
</Panel.Root>

Behavior#

Motion Animation#

Use motionProps on Root to configure open/close animations.

<Panel.Root motionProps={{ name: 'p-collapsible', cssVarPrefix: 'panel-content', hideStrategy: 'none' }}>...</Panel.Root>

See Motion for animation phases, CSS variables, and hide strategies.

Polymorphic Rendering#

Use as on any sub-component to change the rendered HTML element.

<Panel.Root as="section">
    <Panel.Header as="nav">
        <Panel.Title as="h2">...</Panel.Title>
    </Panel.Header>
    <Panel.Content as="article">...</Panel.Content>
    <Panel.Footer as="nav">...</Panel.Footer>
</Panel.Root>

Default elements: Root=div, Header=div, Title=div, Trigger=button, Content=div, Footer=div, Indicator=span.

Render Function Children#

Content accepts a render function as children, providing access to the component instance. The instance exposes panel (root instance) and motion (animation state).

<Panel.Content>{(instance) => <div>Panel is {instance.panel?.state.open ? 'open' : 'closed'}</div>}</Panel.Content>

Pass Through#

Some parts may not be visible in the preview depending on the component's current state.

Loading...
/* Select a part to see its CSS selector for custom styling */

API#

PanelRoot#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: PanelRootInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: PanelRootInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instancePanelRootInstance—
The instance to pass to the component.
ptSafeRecord<PanelRootPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: PanelRootInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
openbooleanfalse
Controls the open state of the collapsible.
defaultOpenbooleanfalse
Defines the initial open state of the collapsible.
disabledbooleanfalse
When disabled, the component cannot be interacted with.
tabIndexnumber0
Index of the element in tabbing order.
onOpen(event?: SyntheticEvent) => void—
Callback triggered when the content is opened.
onClose(event?: SyntheticEvent) => void—
Callback triggered when the content is closed.
toggleablebooleanfalse
When enabled, the content of panel can be expanded and collapsed by clicking the header.
lazybooleanfalse
When enabled, hidden content is not rendered at all. Defaults to false that hides content with css.
motionPropsMotionOptions—
Used to configure the motion of the panel content.
onOpenChange(event: PanelRootOpenChangeEvent) => void—
Callback fired when the panel's open state changes.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"panel"
data-part"root"
data-openPresent when expanded
data-closedPresent when collapsed
data-disabledPresent when disabled

Defines passthrough(pt) options of Panel component.

labeltypedescription
rootPanelRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.
headerPanelRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the header's DOM element.
triggerPanelRootPassThroughType<HTMLAttributes<HTMLButtonElement>>Used to pass attributes to the trigger's DOM element.
titlePanelRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the title's DOM element.
contentPanelRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the content's DOM element.
contentOuterPanelRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the content outer wrapper's DOM element.
contentInnerPanelRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the content inner wrapper's DOM element.
footerPanelRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the footer's DOM element.
indicatorPanelRootPassThroughType<HTMLAttributes<HTMLSpanElement>>Used to pass attributes to the indicator's DOM element.

PanelHeader#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: PanelHeaderInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: PanelHeaderInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instancePanelHeaderInstance—
The instance to pass to the component.
ptSafeRecord<PanelHeaderPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: PanelHeaderInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of PanelHeadercomponent.

labeltypedescription
rootPanelHeaderPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

PanelTitle#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: PanelTitleInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: PanelTitleInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instancePanelTitleInstance—
The instance to pass to the component.
ptSafeRecord<PanelTitlePassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: PanelTitleInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of PanelTitlecomponent.

labeltypedescription
rootPanelTitlePassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

PanelTrigger#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: PanelTriggerInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: PanelTriggerInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instancePanelTriggerInstance—
The instance to pass to the component.
ptSafeRecord<PanelTriggerPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: PanelTriggerInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"panel"
data-part"trigger"
data-content-openPresent when content open
data-content-closedPresent when content closed

Defines passthrough(pt) options of PanelTrigger component.

labeltypedescription
rootPanelTriggerPassThroughType<HTMLAttributes<HTMLButtonElement>>Used to pass attributes to the root's DOM element.

PanelIndicator#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: PanelIndicatorInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: PanelIndicatorInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instancePanelIndicatorInstance—
The instance to pass to the component.
ptSafeRecord<PanelIndicatorPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: PanelIndicatorInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
match"always" | "open" | "closed"—
Determines the visibility of the indicator based on the state of the panel. Valid values are: - "open": Indicator is visible when the panel is expanded. - "closed": Indicator is visible when the panel is collapsed. - "always": Indicator is always visible.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"panel"
data-part"indicator"
data-openPresent when expanded
data-closedPresent when collapsed

Defines passthrough(pt) options of PanelIndicator component.

labeltypedescription
rootPanelIndicatorPassThroughType<HTMLAttributes<HTMLSpanElement>>Used to pass attributes to the root's DOM element.

PanelContent#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: PanelContentInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: PanelContentInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instancePanelContentInstance—
The instance to pass to the component.
ptSafeRecord<PanelContentPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: PanelContentInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"panel"
data-part"content"
data-openPresent when expanded
data-closedPresent when collapsed

Defines passthrough(pt) options of PanelContent component.

labeltypedescription
rootPanelContentPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

PanelFooter#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: PanelFooterInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: PanelFooterInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instancePanelFooterInstance—
The instance to pass to the component.
ptSafeRecord<PanelFooterPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: PanelFooterInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of PanelFooter component.

labeltypedescription
rootPanelFooterPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

Accessibility#

Screen Reader#

For toggleable panels, the trigger button uses aria-controls to reference the content region and aria-expanded to reflect visibility state. The content uses role="region" and an id that matches the trigger's aria-controls. Accessible labels can be customized with aria-label or aria-labelledby.

Keyboard Support#

KeyFunction
tabMoves focus to the next focusable element in the page tab sequence.
shift + tabMoves focus to the previous focusable element in the page tab sequence.
enterToggles the visibility of the content.
spaceToggles the visibility of the content.