<img src="https://react-resizable-panels.vercel.app/og.svg" alt="react-resizable-panels logo" width="400" height="210" />
npm install react-resizable-panelsreact-resizable-panels: React components for resizable panel groups/layouts.
If you like this project there are several ways to support it:
- Become a GitHub sponsor
- or buy me a coffee
Begin by installing the library from NPM:
``sh`
npm install react-resizable-panels
TypeScript definitions are included within the published dist folder
Frequently asked questions can be found here.
Documentation for this project is available at react-resizable-panels.vercel.app.
A Group wraps a set of resizable Panel components.
Group content can be resized _horizontally_ or _vertically_.
Group elements always include the following attributes:
` ℹ️ Test id can be used to narrow selection when unit testing. #### Required props #### Optional props CSS class name. Uniquely identifies this group within an application. ℹ️ This value will also be assigned to the CSS properties. ⚠️ The following styles cannot be overridden: Panel and Separator components that comprise this group. Default layout for the Group. ℹ️ This value allows layouts to be remembered between page reloads. ⚠️ Refer to the documentation for how to avoid layout shift when using server components. This library sets custom mouse cursor styles to indicate drag state. Disable resize functionality. Ref attached to the root Exposes the following imperative API: ℹ️ The Called when the Group's layout is changing. ⚠️ For layout changes caused by pointer events, this method is called each time the pointer is moved. Called after the Group's layout has been changed. ℹ️ For layout changes caused by pointer events, this method is not called until the pointer has been released. Minimum size of the resizable hit target area (either ℹ️ Apple interface guidelines suggest Specifies the resizable orientation ("horizontal" or "vertical"); defaults to "horizontal" Panel size props can be in the following formats: ℹ️ Numeric values are assumed to be pixels. Panel elements always include the following attributes: ℹ️ Test id can be used to narrow selection when unit testing. ⚠️ Panel elements must be direct DOM children of their parent Group elements. #### Required props #### Optional props CSS class name. ⚠️ Class is applied to nested Uniquely identifies this panel within the parent group. ℹ️ This prop is used to associate persisted group layouts with the original panel. ℹ️ This value will also be assigned to the CSS properties. ⚠️ Style is applied to nested Panel size when collapsed; defaults to 0%. This panel can be collapsed. ℹ️ A collapsible panel will collapse when it's size is less than of the specified Default size of Panel within its parent group; default is auto-assigned based on the total number of Panels. When disabled, a panel cannot be resized either directly or indirectly (by resizing another panel). Ref attached to the root Maximum size of Panel within its parent group; defaults to 100%. Minimum size of Panel within its parent group; defaults to 0%. Called when panel sizes change. Exposes the following imperative API: ℹ️ The ⚠️ Separator elements must be direct DOM children of their parent Group elements. Separator elements always include the following attributes: ℹ️ Test id can be used to narrow selection when unit testing. ℹ️ In addition to the attributes shown above, separator also renders all required WAI-ARIA properties. #### Required props #### Optional props CSS class name. ℹ️ Use the ⚠️ The following properties cannot be overridden: Uniquely identifies the separator within the parent group. ℹ️ This value will also be assigned to the CSS properties. ℹ️ Use the ⚠️ The following properties cannot be overridden: When disabled, the separator cannot be used to resize its neighboring panels. ℹ️ The panels may still be resized indirectly (while other panels are being resized). Ref attached to the root html
``
None
Name
Description
className
id
Falls back to useId when not provided.data-group attribute.
style
display, flex-direction, flex-wrap, and overflow.
children
defaultLayout
disableCursor
Use this prop to disable that behavior for Panels and Separators in this group.
disabled
elementRef
HTMLDivElement.
groupRef
getLayout(): LayoutsetLayout(layout: Layout): voiduseGroupRef and useGroupCallbackRef hooks are exported for convenience use in TypeScript projects.
onLayoutChange
For most cases, it is recommended to use the onLayoutChanged callback instead.
onLayoutChanged
This method is recommended when saving layouts to some storage api.
resizeTargetMinimumSize
Separator or Panel edge)
This threshold ensures are large enough to avoid mis-clicks.
to ensure accessibility and ease of use, hit targets should be larger to prevent mis-clicks.20pt (27px) on desktops and 28pt (37px) for touch devices
In practice this seems to be much larger than many of their own applications use though.
orientation
$3
A Panel wraps resizable content and can be configured with min/max size constraints and collapsible behavior.
- Percentage of the parent Group (0..100)
- Pixels
- Relative font units (em, rem)
- Viewport relative units (vh, vw)
Strings without explicit units are assumed to be percentages (0%..100%).
Percentages may also be specified as strings ending with "%" (e.g. "33%")
Pixels may also be specified as strings ending with the unit "px".
Other units should be specified as strings ending with their CSS property units (e.g. 1rem, 50vh)html
``
None
Name
Description
className
HTMLDivElement to avoid styles that interfere with Flex layout.
id
Falls back to useId when not provided.data-panel attribute.
style
HTMLDivElement to avoid styles that interfere with Flex layout.
collapsedSize
collapsible
minSize
defaultSize
disabled
elementRef
HTMLDivElement.
maxSize
minSize
onResize
@param panelSize Panel size (both as a percentage of the parent Group and in pixels)
@param id Panel id (if one was provided as a prop)
@param prevPanelSize Previous panel size (will be undefined on mount)
panelRef
collapse(): voidexpand(): voidgetSize(): numberisCollapsed(): booleanresize(size: number): voidusePanelRef and usePanelCallbackRef hooks are exported for convenience use in TypeScript projects.
$3
Separators are not _required_ but they are _recommended_ as they improve keyboard accessibility.html
``
None
Name
Description
className
data-separator attribute for custom hover and active stylesflex-grow, flex-shrink
id
Falls back to useId when not provided.data-separator attribute.
style
data-separator attribute for custom hover and active stylesflex-grow, flex-shrink
disabled
To prevent a panel from being resized at all, it needs to also be disabled.
elementRef
HTMLDivElement.