ComponentsControlsZoom Slider

Zoom Slider

A zoom control that lets you zoom in and out seamlessly using a slider.

Installation

Make sure to follow the prerequisites before installing the component.

npx shadcn@latest add https://ui-components-git-tooltip-node-refactor-xyflow.vercel.app/zoom-slider

Usage

1. Copy the component into your app

import { Background, ReactFlow } from "@xyflow/react";
import { ZoomSlider } from "@/components/zoom-slider";
 
const defaultNodes = [
  {
    id: "1",
    position: { x: 200, y: 200 },
    data: { label: "Node" },
  },
];
 
export default function ZoomSliderDemo() {
  return (
    <div className="h-full w-full">
      <ReactFlow defaultNodes={defaultNodes} fitView>
        <Background />
        <ZoomSlider />
      </ReactFlow>
    </div>
  );
}

2. Connect the component with your React Flow application.

import DemoWrapper from "@/components/demo-wrapper";
import ZoomSliderDemo from "@/registry/components/zoom-slider/demo";
 
export default function ZoomSliderDemoPage() {
  return (
    <DemoWrapper>
      <ZoomSliderDemo />
    </DemoWrapper>
  );
}