The Resizable component provides a flexible layout system with resizable panels. It allows users to adjust the size of different sections of the interface by dragging handles between panels.
import { Resizable } from '@dashflowx/core'export default function ResizableExample() {return (<Resizabledirection="horizontal"className="max-w-md rounded-lg border"height="400px"panelCount={2}/>)}
Preview:
| Prop | Type | Default | Description |
|---|---|---|---|
direction | 'horizontal' | 'vertical' | 'horizontal' | Direction of the resizable layout |
className | string | - | Additional CSS classes |
height | string | - | Height of the resizable container |
type | string | - | Type of resizable layout |
panelCount | number | 2 | Number of panels to display |
showHeader | boolean | false | Whether to show a header |
headerTitle | string | 'Resizable Layout' | Title text for the header |
headerClassName | string | - | Additional CSS classes for the header |
direction: Controls the layout direction (horizontal or vertical)type: Controls the panel styling and sizing behaviorbasic: Simple two-panel layout with gray stylingvertical: Two-panel layout with red/yellow styling and 40/60 splitnested: Complex nested layout with multiple panelsdynamic: Fully customizable panels with controls and callbacks
The main resizable container component.
Container for resizable panels with direction control.
Individual resizable panel component.
Handle for resizing panels.
import { Resizable } from '@dashflowx/core'export default function BasicResizableLayout() {return (<Resizabletype="basic"direction="horizontal"className="max-w-md rounded-lg border"panelCount={2}/>)}
Preview:
import { Resizable } from '@dashflowx/core'export default function MultiplePanelsLayout() {return (<Resizabletype="basic"direction="horizontal"className="max-w-lg rounded-lg border"panelCount={3}/>)}
Preview:
import { Resizable } from '@dashflowx/core'export default function VerticalResizableLayout() {return (<Resizabletype="vertical"direction="vertical"className="max-w-md rounded-lg border"panelCount={2}/>)}
Preview:
import { Resizable } from '@dashflowx/core'export default function HorizontalVerticalTypeLayout() {return (<Resizabletype="vertical"direction="horizontal"className="max-w-md rounded-lg border"panelCount={2}/>)}
Preview:
import { Resizable } from '@dashflowx/core'export default function NestedResizableLayout() {return (<Resizabletype="nested"direction="horizontal"className="max-w-md rounded-lg border"panelCount={2}/>)}
Preview:
import { Resizable } from '@dashflowx/core'export default function DynamicResizableLayout() {return (<Resizabletype="dynamic"direction="horizontal"height="600px"className="max-w-full rounded-lg border"panelCount={2}/>)}
Preview:
import { Resizable } from '@dashflowx/core'export default function FourPanelLayout() {return (<Resizabletype="basic"direction="horizontal"className="max-w-2xl rounded-lg border"panelCount={4}/>)}
Preview:
import { Resizable } from '@dashflowx/core'export default function VerticalMultiPanelLayout() {return (<Resizabletype="basic"direction="vertical"className="max-w-md rounded-lg border"height="600px"panelCount={3}/>)}
Preview:
import { Resizable } from '@dashflowx/core'export default function CustomStyledResizable() {return (<Resizabletype="basic"direction="horizontal"className="border border-blue-500 rounded-lg p-4"panelCount={2}/>)}
Preview:
import { Resizable } from '@dashflowx/core'export default function LargeResizableLayout() {return (<Resizabletype="basic"direction="horizontal"className="scale-150"panelCount={2}/>)}
Preview:
import { Resizable } from '@/components/resizable'export default function ResizableWithHeader() {return (<Resizabledirection="horizontal"className="max-w-md rounded-lg border"height="400px"panelCount={2}showHeader={true}headerTitle="My Resizable Layout"headerClassName="bg-blue-500 text-white p-2 rounded-t-lg"/>)}
Preview:
import { Resizable } from '@/components/resizable'export default function CustomStyledHeader() {return (<Resizabledirection="horizontal"className="max-w-lg rounded-lg border"height="400px"panelCount={3}showHeader={true}headerTitle="Dashboard Layout"headerClassName="bg-gradient-to-r from-purple-500 to-pink-500 text-white p-3 rounded-t-lg font-semibold"/>)}
Preview:
import { Resizable } from '@dashflowx/core'export default function CodeEditorLayout() {return (<Resizabletype="dynamic"direction="horizontal"height="600px"className="max-w-full rounded-lg border"panelCount={2}/>)}
import { Resizable } from '@dashflowx/core'export default function DashboardLayout() {return (<Resizabletype="nested"direction="horizontal"height="500px"className="max-w-full rounded-lg border"panelCount={2}/>)}
import { Resizable } from '@dashflowx/core'export default function FileExplorerLayout() {return (<Resizabletype="vertical"direction="vertical"height="600px"className="max-w-md rounded-lg border"panelCount={2}/>)}
import { Resizable } from '@dashflowx/core'export default function ChatInterfaceLayout() {return (<Resizabletype="basic"direction="horizontal"height="500px"className="max-w-lg rounded-lg border"panelCount={3}/>)}
Provide clear content for each panel.
// ✅ Good - Clear content<Resizabletype="basic"direction="horizontal"panelCount={2}className="max-w-md rounded-lg border"/>// ❌ Avoid - Empty panels<Resizable type="basic" direction="horizontal" panelCount={0} />
Maintain consistent styling across panels.
// ✅ Good - Consistent styling<Resizabletype="basic"direction="horizontal"className="standard-resizable-style"panelCount={2}/>// ❌ Avoid - Inconsistent styling<Resizabletype="basic"direction="horizontal"className="random-styles"panelCount={2}/>
Set appropriate default panel sizes.
// ✅ Good - Appropriate sizes<Resizabletype="basic"direction="horizontal"panelCount={2}className="max-w-md rounded-lg border"/>// ❌ Avoid - Extreme sizes<Resizabletype="basic"direction="horizontal"panelCount={10}className="max-w-xs rounded-lg border"/>
Make resizable layout responsive for different screen sizes.
// ✅ Good - Responsive<Resizabletype="basic"direction="horizontal"className="flex flex-wrap justify-center"panelCount={2}/>// ❌ Avoid - Fixed width<Resizabletype="basic"direction="horizontal"className="w-96"panelCount={2}/>
Ensure resize handles are accessible to all users.
// ✅ Good - Accessible handles<Resizabletype="basic"direction="horizontal"panelCount={2}className="max-w-md rounded-lg border"/>// ❌ Avoid - Hidden handles<Resizabletype="basic"direction="horizontal"panelCount={2}className="opacity-0"/>
You can customize the resizable layout appearance using CSS classes:
import { Resizable } from '@dashflowx/core'export default function CustomStyledResizable() {return (<Resizabletype="basic"direction="horizontal"className="border-2 border-blue-500 rounded-xl shadow-lg bg-gradient-to-r from-blue-50 to-purple-50"panelCount={2}/>)}
Experiment with different numbers of panels:
// Two panels<Resizable type="basic" direction="horizontal" panelCount={2} />// Three panels<Resizable type="basic" direction="horizontal" panelCount={3} />// Four panels<Resizable type="basic" direction="horizontal" panelCount={4} />// Five panels<Resizable type="basic" direction="horizontal" panelCount={5} />
Use different layout types for various use cases:
// Basic layout<Resizable type="basic" direction="horizontal" panelCount={2} />// Vertical layout<Resizable type="vertical" direction="vertical" panelCount={2} />// Nested layout<Resizable type="nested" direction="horizontal" panelCount={2} />// Dynamic layout<Resizable type="dynamic" direction="horizontal" panelCount={2} />
Control the layout direction:
// Horizontal layout<Resizable type="basic" direction="horizontal" panelCount={2} />// Vertical layout<Resizable type="basic" direction="vertical" panelCount={2} />
Use different sizes for different emphasis levels:
// Small resizable<Resizable className="text-sm" />// Standard resizable<Resizable className="text-base" />// Large resizable<Resizable className="text-lg" />
Load panel content dynamically:
const [panelContent, setPanelContent] = useState([]);useEffect(() => {// Load panel content from APIloadPanelContent().then(setPanelContent);}, []);
Show/hide panels based on conditions:
const getPanels = (userRole) => {const basePanels = [{ id: 'main', content: 'Main Content' }];if (userRole === 'admin') {basePanels.push({ id: 'admin', content: 'Admin Panel' });}return basePanels;};
Handle panel state:
const [panelSizes, setPanelSizes] = useState({});const handleResize = (panelId, size) => {setPanelSizes(prev => ({...prev,[panelId]: size}));};
- Grid: For grid layouts
- Flex: For flex layouts
- Panel: For panel containers
- Handle: For resize handles
- Layout: For layout containers
For the complete API reference and advanced usage patterns, see the Resizable API documentation.
