# Resizable

shadcn resizable reskinned for UI95.

Source: https://www.ui95.dev/ui/resizable

## Examples

```tsx
import type * as React from "react"

import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@/components/ui/resizable"

import type { ShowcaseDemo } from "../types"

function Label({ children }: { children: string }) {
  return (
    <div className="flex h-full items-center justify-center p-2 font-pixel text-[16px] leading-none uppercase">
      {children}
    </div>
  )
}

function Frame({
  className,
  children,
}: {
  className: string
  children: React.ReactNode
}) {
  return <div className={`w-full max-w-full ${className}`}>{children}</div>
}

export const demo: ShowcaseDemo = {
  span: "wide",
  variants: [
    {
      label: "horizontal",
      render: () => (
        <Frame className="h-24">
          <ResizablePanelGroup orientation="horizontal">
            <ResizablePanel defaultSize={35} minSize={15}>
              <Label>C:\</Label>
            </ResizablePanel>
            <ResizableHandle />
            <ResizablePanel defaultSize={65} minSize={15}>
              <Label>README.TXT</Label>
            </ResizablePanel>
          </ResizablePanelGroup>
        </Frame>
      ),
    },
    {
      label: "with handle",
      render: () => (
        <Frame className="h-24">
          <ResizablePanelGroup orientation="horizontal">
            <ResizablePanel defaultSize={50} minSize={15}>
              <Label>A:\</Label>
            </ResizablePanel>
            <ResizableHandle withHandle />
            <ResizablePanel defaultSize={50} minSize={15}>
              <Label>640K FREE</Label>
            </ResizablePanel>
          </ResizablePanelGroup>
        </Frame>
      ),
    },
    {
      label: "vertical",
      render: () => (
        <Frame className="h-40">
          <ResizablePanelGroup orientation="vertical">
            <ResizablePanel defaultSize={40} minSize={20}>
              <Label>AUTOEXEC.BAT</Label>
            </ResizablePanel>
            <ResizableHandle withHandle />
            <ResizablePanel defaultSize={60} minSize={20}>
              <Label>CONFIG.SYS</Label>
            </ResizablePanel>
          </ResizablePanelGroup>
        </Frame>
      ),
    },
    {
      label: "nested",
      render: () => (
        <Frame className="h-48">
          <ResizablePanelGroup orientation="horizontal">
            <ResizablePanel defaultSize={30} minSize={15}>
              <Label>C:\</Label>
            </ResizablePanel>
            <ResizableHandle withHandle />
            <ResizablePanel defaultSize={70} minSize={30}>
              <ResizablePanelGroup orientation="vertical">
                <ResizablePanel defaultSize={50} minSize={20}>
                  <Label>MODEM.INI</Label>
                </ResizablePanel>
                <ResizableHandle withHandle />
                <ResizablePanel defaultSize={50} minSize={20}>
                  <Label>DISK 1 OF 3</Label>
                </ResizablePanel>
              </ResizablePanelGroup>
            </ResizablePanel>
          </ResizablePanelGroup>
        </Frame>
      ),
    },
  ],
}
```

## Installation

```bash
npx shadcn@latest add https://www.ui95.dev/r/resizable.json
```

Run it in a Radix shadcn project that already has the UI95 theme.

Dependencies:

```bash
npm install cn react-resizable-panels
```

`components/ui/resizable.tsx`

```tsx
"use client"

import { cn } from "cn"
import * as ResizablePrimitive from "react-resizable-panels"

function ResizablePanelGroup({
  className,
  ...props
}: ResizablePrimitive.GroupProps) {
  return (
    <ResizablePrimitive.Group
      data-slot="resizable-panel-group"
      className={cn(
        "flex h-full w-full overflow-hidden pixel-border border-border bg-card text-xl leading-tight text-card-foreground bevel-raised offset-shadow-none aria-[orientation=vertical]:flex-col",
        className
      )}
      {...props}
    />
  )
}

function ResizablePanel({ ...props }: ResizablePrimitive.PanelProps) {
  return <ResizablePrimitive.Panel data-slot="resizable-panel" {...props} />
}

function ResizableHandle({
  withHandle,
  className,
  ...props
}: ResizablePrimitive.SeparatorProps & {
  withHandle?: boolean
}) {
  return (
    <ResizablePrimitive.Separator
      data-slot="resizable-handle"
      className={cn(
        "group/handle relative flex w-(--pixel) shrink-0 items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-2 after:-translate-x-1/2 aria-[orientation=horizontal]:h-(--pixel) aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:inset-x-0 aria-[orientation=horizontal]:after:inset-y-auto aria-[orientation=horizontal]:after:top-1/2 aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-2 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 data-[separator=active]:bg-foreground data-[separator=disabled]:bg-muted-foreground",
        className
      )}
      {...props}
    >
      {withHandle && (
        <div className="z-10 flex h-8 w-3 shrink-0 items-center justify-center pixel-border border-border bg-card bevel-raised offset-shadow-none group-aria-[orientation=horizontal]/handle:h-3 group-aria-[orientation=horizontal]/handle:w-8 group-data-[separator=active]/handle:bevel-sunken">
          <span className="block size-full bg-foreground dither-50" />
        </div>
      )}
    </ResizablePrimitive.Separator>
  )
}

export { ResizableHandle, ResizablePanel, ResizablePanelGroup }
```

## API reference

### ResizableHandle

| Prop | Type | Default |
| --- | --- | --- |
| `withHandle` | `boolean` | - |

### ResizablePanel

No props of its own. It forwards the props of the element or primitive it wraps.

### ResizablePanelGroup

No props of its own. It forwards the props of the element or primitive it wraps.

## Sounds

- `slider.tick`
