One
Two
Three
<script lang="ts">
import * as Resizable from "$lib/components/ui/resizable/index.js";
</script>
<Resizable.PaneGroup direction="horizontal" class="max-w-md rounded-lg border">
<Resizable.Pane defaultSize={50}>
<div class="flex h-[200px] items-center justify-center p-6">
<span class="font-semibold">One</span>
</div>
</Resizable.Pane>
<Resizable.Handle />
<Resizable.Pane defaultSize={50}>
<Resizable.PaneGroup direction="vertical">
<Resizable.Pane defaultSize={25}>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold">Two</span>
</div>
</Resizable.Pane>
<Resizable.Handle />
<Resizable.Pane defaultSize={75}>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold">Three</span>
</div>
</Resizable.Pane>
</Resizable.PaneGroup>
</Resizable.Pane>
</Resizable.PaneGroup> About
The Resizable component is built on top of PaneForge by Huntabyte. Visit the PaneForge documentation for all the available props and abilities of the Resizable component.
Installation
pnpm dlx jsrepo@latest add resizablenpx jsrepo@latest add resizableyarn dlx jsrepo@latest add resizablebunx jsrepo@latest add resizableInstall paneforge:
pnpm add paneforge@next -Dnpm install paneforge@next -Dyarn add paneforge@next -Dbun add paneforge@next -DCopy and paste the following code into your project.
import { Pane } from 'paneforge';
import Handle from './resizable-handle.svelte';
import PaneGroup from './resizable-pane-group.svelte';
export {
PaneGroup,
Pane,
Handle,
//
PaneGroup as ResizablePaneGroup,
Pane as ResizablePane,
Handle as ResizableHandle
};
Usage
<script lang="ts">
import * as Resizable from '$lib/components/ui/resizable/index.js';
</script> <Resizable.PaneGroup direction="horizontal">
<Resizable.Pane>One</Resizable.Pane>
<Resizable.Handle />
<Resizable.Pane>Two</Resizable.Pane>
</Resizable.PaneGroup> Examples
Vertical
Use the direction prop to set the direction of the resizable panels.
Header
Content
<script lang="ts">
import * as Resizable from "$lib/components/ui/resizable/index.js";
</script>
<Resizable.PaneGroup
direction="vertical"
class="min-h-[200px] max-w-md rounded-lg border"
>
<Resizable.Pane defaultSize={25}>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold">Header</span>
</div>
</Resizable.Pane>
<Resizable.Handle />
<Resizable.Pane defaultSize={75}>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold">Content</span>
</div>
</Resizable.Pane>
</Resizable.PaneGroup> <script lang="ts">
import * as Resizable from '$lib/components/ui/resizable/index.js';
</script>
<Resizable.PaneGroup direction="vertical">
<Resizable.Pane>One</Resizable.Pane>
<Resizable.Handle />
<Resizable.Pane>Two</Resizable.Pane>
</Resizable.PaneGroup> Handle
You can set or hide the handle by using the withHandle prop on the ResizableHandle component.
Sidebar
Content
<script lang="ts">
import * as Resizable from "$lib/components/ui/resizable/index.js";
</script>
<Resizable.PaneGroup
direction="horizontal"
class="min-h-[200px] max-w-md rounded-lg border"
>
<Resizable.Pane defaultSize={25}>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold">Sidebar</span>
</div>
</Resizable.Pane>
<Resizable.Handle withHandle />
<Resizable.Pane defaultSize={75}>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold">Content</span>
</div>
</Resizable.Pane>
</Resizable.PaneGroup> <script lang="ts">
import * as Resizable from '$lib/components/ui/resizable/index.js';
</script>
<Resizable.PaneGroup direction="vertical">
<Resizable.Pane>One</Resizable.Pane>
<Resizable.Handle withHandle />
<Resizable.Pane>Two</Resizable.Pane>
</Resizable.PaneGroup>