Skip to content
GitHub11 stars

Accessible resizable panel groups and layouts with keyboard support.

One
Two
Three
<ResizablePanelGroup Orientation="Orientation.Horizontal" Class="max-w-sm rounded-lg border">
    <ResizablePanel DefaultSize="50%">
        <div class="flex h-[200px] items-center justify-center p-6">

About

The Resizable component is built on a JavaScript port of react-resizable-panels v4 by bvaughn. It has the same layout rules, keyboard support and cursors, without the npm package.

Installation

dnx Blazix.Cli add resizable

Usage

<ResizablePanelGroup Orientation="Orientation.Horizontal">
    <ResizablePanel>One</ResizablePanel>
    <ResizableHandle />
    <ResizablePanel>Two</ResizablePanel>
</ResizablePanelGroup>

Composition

Use the following composition to build a ResizablePanelGroup:

ResizablePanelGroup
├── ResizablePanel
├── ResizableHandle
└── ResizablePanel

Vertical

Use Orientation="Orientation.Vertical" for vertical resizing.

Header
Content
<ResizablePanelGroup Orientation="Orientation.Vertical" Class="min-h-[200px] max-w-sm rounded-lg border">
    <ResizablePanel DefaultSize="25%">
        <div class="flex h-full items-center justify-center p-6">

Handle

Use the WithHandle parameter on ResizableHandle to show a visible handle.

Sidebar
Content
<ResizablePanelGroup Orientation="Orientation.Horizontal" Class="min-h-[200px] max-w-sm rounded-lg border">
    <ResizablePanel DefaultSize="25%">
        <div class="flex h-full items-center justify-center p-6">

Without Dragging

A handle resizes by dragging, and by the arrow keys, Home and End once it has focus. Pointer users who can't drag need another way too (WCAG 2.5.7): SetLayoutAsync on ResizablePanelGroup sets the sizes from buttons, a menu or anything else.

Sidebar
Content
@* Dragging needs an alternative for a single tap or click (WCAG 2.5.7): these buttons set the sidebar's width. *@
<div class="flex w-full max-w-sm flex-col gap-3">
    <ResizablePanelGroup @ref="_group" Orientation="Orientation.Horizontal" Class="min-h-[200px] rounded-lg border">

RTL

To enable RTL support in Blazix, see the RTL configuration guide.

Translated with AI for the demo, so it may have mistakes.

واحد
اثنان
ثلاثة
<ResizablePanelGroup Orientation="Orientation.Horizontal" Class="max-w-sm rounded-lg border">
    <ResizablePanel DefaultSize="50%">
        <div class="flex h-[200px] items-center justify-center p-6">

API Reference

Sizes follow react-resizable-panels: a plain number is a percentage, and %, px, rem, em, vh and vw units work too.

ResizablePanelGroup

ParameterTypeDefault
Orientation Orientation Orientation.Horizontal
DefaultLayout IReadOnlyDictionary<string, double>? -
Disabled bool false
DisableCursor bool false
OnLayoutChange EventCallback<IReadOnlyDictionary<string, double>> -
OnLayoutChanged EventCallback<IReadOnlyDictionary<string, double>> -
Id string? -
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

ResizablePanel

ParameterTypeDefault
Id string? -
DefaultSize string? -
MinSize string? -
MaxSize string? -
Collapsible bool false
CollapsedSize string? -
Disabled bool false
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

ResizableHandle

ParameterTypeDefault
WithHandle bool false
Disabled bool false
Id string? -
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.