Panel | UI components (BETA)
Sales Hub
- Enterprise
Service Hub
- Enterprise
The Panel
component renders a panel overlay on the right side of the page and contains other components. Like the Modal component, you'll include the Panel
component in an overlay
prop within a Button, Link, Tag, or Image component.
To see an example of using a panel in an extension, check out HubSpot's Build a multi-step flow or Overlay example project.
Please note: as of June 24, 2024, the method for including Panel
components has changed. Moving forward:
- Panels are nested within the components that open them.
- Opening the panel is automatically handled by the parent component, rather than requiring reactions.
Extensions using the old method will continue to function, but it's recommended to review the new functionality below and update your extensions as needed.
The Panel
component uses three subcomponents to control its design and content, which follows the general structure below:
<Panel>
: the outermost container. It must be a top-level component. You cannot put aPanel
inside another component, such asFlex
.<PanelBody>
: the container that wraps the panel's content and makes it scrollable. Include only onePanelBody
perPanel
.<PanelFooter>
: a sticky footer component at the bottom of the panel. Include only onePanelFooter
perPanel
.
Below are the props available for Panel
and PanelSection
.
Prop | Type | Description |
---|---|---|
id Required |
String | A unique ID for the panel. |
onOpen |
onOpen() => void | A function that will be invoked when the panel has finished opening. |
onClose |
onClose() => void | A function that will be invoked when the panel has finished closing. |
width |
'sm' , 'small' (default) | 'md' , 'medium' | 'lg' , 'large' |
The width of the panel. |
title |
String | The text that displays at the top of the panel. |
variant |
'modal' | 'default' (default) |
The panel variant. The modal variant includes better screen reader focus on the panel and is recommended for visual and motor accessibility and tab navigation.See variants for more information. |
aria-label |
String | The panel's accessibility label. |
Prop | Type | Description |
---|---|---|
flush |
Boolean | When set to true , the section will have no bottom margin. Default is false . |
By default, HubSpot handles opening the panel when the user clicks the parent Button, Link, Tag, or Image component. A close button will also be included in the top right of the panel.
In addition, you can add a close mechanism to a panel using a Button
, Link
, Tag
or Image
with an onClick
event that triggers the closeOverlay
action. To use this action, you'll need to include the actions argument in hubspot.extend()
as seen in the example code below.
Learn more about opening and closing overlays.
Please note:
- You can only have one panel open at a time. Opening a panel while another is already open will cause the first one to close.
- A
Modal
can be opened from aPanel
, but aPanel
cannot be opened from aModal
.
By default, the panel will only obscure the content on the right side of the page where it opens. Using the variants
prop, you can add an additional overlay behind the panel to blur the rest of the page. This variant puts more focus on the panel and improves accessibility for users with screen readers. Because the modal
variant obscures the rest of the page's content, use it only when users don't need other context from the page.
Thank you for your feedback, it means a lot to us.