Zoom HUD
Zoom controls with current percentage, increment buttons, and reset action for canvas views. Install Zoom HUD from the VLLNT UI registry with the shadcn CLI.
Zoom controls with current percentage, increment buttons, and reset action for canvas views. Part of the overlay family in VLLNT UI, it ships as a machine-readable registry entry — copy the source directly into your app with the shadcn CLI and own it, no runtime dependency on a component library.
Preview
Switch between light and dark to inspect the embedded Storybook preview.
Installation
Add Zoom HUD to your project with the shadcn CLI. The source lands in your codebase, ready to adapt:
pnpm dlx shadcn@latest add https://ui.vllnt.ai/r/zoom-hud.jsonSource
import { Minus, Plus, RotateCcw } from "lucide-react";
import { cn } from "../../lib/utils";
import { Button } from "../button/button";
export type ZoomHUDProps = React.ComponentPropsWithoutRef<"div"> & {
onReset?: () => void;
onZoomIn?: () => void;
onZoomOut?: () => void;
zoom: number;
};
const ZoomHUD = ({
className,
onReset,
onZoomIn,
onZoomOut,
ref,
zoom,
...props
}: ZoomHUDProps & { ref?: React.Ref<HTMLDivElement> }) => (
<div
className={cn(
"inline-flex items-center gap-1 rounded-sm border border-border bg-background p-1 font-mono",
className,
)}
ref={ref}
{...props}
>
<Button
aria-label="Zoom out"
onClick={onZoomOut}
size="icon"
type="button"
variant="ghost"
>
<Minus className="size-4" />
</Button>
<div className="min-w-16 px-2 text-center text-xs font-medium tabular-nums text-foreground">
{Math.round(zoom * 100)}%
</div>
<Button
aria-label="Zoom in"
onClick={onZoomIn}
size="icon"
type="button"
variant="ghost"
>
<Plus className="size-4" />
</Button>
<Button
aria-label="Reset zoom"
onClick={onReset}
size="icon"
type="button"
variant="ghost"
>
<RotateCcw className="size-4" />
</Button>
</div>
);
ZoomHUD.displayName = "ZoomHUD";
export { ZoomHUD };
Stories
Explore every variant and state in the interactive Storybook:
Preview
Switch between light and dark to inspect the embedded Storybook preview.