> ## Documentation Index
> Fetch the complete documentation index at: https://dnd-grid.blode.md/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Scale

<div className="not-prose my-6 rounded-lg border border-zinc-200/70 bg-white/70 shadow-sm dark:border-white/10 dark:bg-white/5">
  <iframe
    title="Scale preview"
    src="https://dnd-grid.com/examples/scale-example?embed=1"
    className="h-[640px] w-full"
    loading="lazy"
  />
</div>

[View source on GitHub](https://github.com/mblode/dnd-grid/blob/main/apps/web/examples/dnd-grid-scale-example.tsx)

## Installation

<Tabs>
<Tab title="CLI">

```bash
npx shadcn@latest add https://dnd-grid.com/r/scale-example.json
```

</Tab>
<Tab title="Manual">

```bash
npm install @dnd-grid/react
```

```css
@import "@dnd-grid/react/styles.css";
```

```tsx title="components/dnd-grid-scale-example.tsx"
"use client";

import { DndGrid, type Layout } from "@dnd-grid/react";
import { type CSSProperties, useState } from "react";

const scaleOptions = [0.75, 1, 1.25];

const initialLayout: Layout = [
  { id: "a", x: 0, y: 0, w: 3, h: 2 },
  { id: "b", x: 3, y: 0, w: 3, h: 2 },
  { id: "c", x: 6, y: 0, w: 3, h: 2 },
  { id: "d", x: 0, y: 2, w: 6, h: 2 },
  { id: "e", x: 6, y: 2, w: 3, h: 3 },
];

export function ScaleExample() {
  const [layout, setLayout] = useState<Layout>(initialLayout);
  const [scale, setScale] = useState(1);

  const scaledStyle: CSSProperties = {
    transform: `scale(${scale})`,
    transformOrigin: "top left",
    ["--dnd-grid-scale" as string]: scale,
  };

  return (
    <div>
      <div style={{ display: "flex", gap: 8, marginBottom: 12 }}>
        {scaleOptions.map((value) => (
          <button key={value} type="button" onClick={() => setScale(value)}>
            {value}x
          </button>
        ))}
      </div>

      <DndGrid
        layout={layout}
        cols={12}
        rowHeight={50}
        transformScale={scale}
        onLayoutChange={setLayout}
        containerProps={{ style: scaledStyle }}
      >
        {layout.map((item) => (
          <div key={item.id} className="grid-item">
            {item.id}
          </div>
        ))}
      </DndGrid>
    </div>
  );
}
```

</Tab>
</Tabs>

## Usage

```tsx
import { ScaleExample } from "@/components/dnd-grid-scale-example";

export default function Page() {
  return <ScaleExample />;
}
```