Introducing PrimeReact v11-alpha 🎉Discover Now

Panel

Panel is a container component with optional collapsible content.

Wireless Headphones$79.00
Phone Case$15.00
Shipping$5.99
Total$99.99
preview

Installation#

npx shadcn@latest add https://v11.primereact.org/r/panel.json

Usage#

import { Panel, PanelContent, PanelHeader, PanelIndicator, PanelTitle, PanelTrigger } from '@/components/ui/panel';
<Panel>
    <PanelHeader>
        <PanelTitle>Header</PanelTitle>
    </PanelHeader>
    <PanelContent />
</Panel>

Examples#

Basic#

Order Summary
Wireless Headphones$79.00
Phone Case$15.00
Shipping$5.99
Total$99.99
basic-demo

Toggleable#

Use Panel.Trigger inside the header to make the panel collapsible. The defaultOpen prop sets the initial state, and content visibility is animated by default.

Order Summary
Wireless Headphones$79.00
Phone Case$15.00
Shipping$5.99
Total$99.99
toggleable-demo

Controlled#

Control panel state from outside with the open and onOpenChange props.

Order Summary
Wireless Headphones$79.00
Phone Case$15.00
Shipping$5.99
Total$99.99
toggleable-controlled-demo

Indicator#

Panel.Indicator supports conditional rendering based on panel state. Use the match prop to render content only when the state matches.

<Panel.Header>
    <Panel.Title>Header</Panel.Title>
    <Panel.Trigger>
        <Panel.Indicator match="open">
            <Minus />
        </Panel.Indicator>
        <Panel.Indicator match="closed">
            <Plus />
        </Panel.Indicator>
    </Panel.Trigger>
</Panel.Header>

Available values: open, closed. Without the match prop, the indicator renders in all states.

Match open / closed

Order Summary
Wireless Headphones$79.00
Phone Case$15.00
Shipping$5.99
Total$99.99

CSS-only with data attributes

Order Summary
Wireless Headphones$79.00
Phone Case$15.00
Shipping$5.99
Total$99.99
indicator-demo

Template#

Customize the header with custom layouts such as avatars, action buttons, and additional metadata alongside Panel.Trigger.

A
Amy Elsner

Product designer focused on accessible interfaces, scalable design systems and modern frontend workflows. Passionate about creating intuitive user experiences that balance usability, consistency and performance across platforms. Currently exploring AI-assisted UI tooling, component architecture and developer experience improvements to streamline design-to-development collaboration and build more maintainable products.

Updated 2 hours ago
template-demo

Accessibility#

Screen Reader#

For toggleable panels, the trigger button uses aria-controls to reference the content region and aria-expanded to reflect visibility state. 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.