Components
Resize Handle
ExperimentalExperimental — the contract and the rendering can change without notice. Own the installed copy before shipping it.Edge and corner grip for resizing a positioned box; the host owns the drag math.
Composition
Resizable box
Inside a zoomed canvas, border widths snap to device pixels before the scale applies: draw the rim with --cui-resize-handle-shadow instead, sized by the inverse scale. --cui-resize-handle-radius shapes the grip and its focus ring together.
- positioned box
- <ResizeHandle />
Installation
The Control UI source installs this component from src/registry/sources/control-ui/ui/resize-handle.tsx.
npx shadcn@latest add https://control-ui.dev/r/resize-handle.jsonRaw code
Primary installed source
import type { ComponentProps, CSSProperties } from "react";import type { ResizeHandleKnobStyle } from "@/components/control-ui/knob-contracts/resize-handle-knobs";import { cn } from "@/components/control-ui/lib/cn";
export const resizeHandleDirections = ["n", "ne", "e", "se", "s", "sw", "w", "nw"] as const;
export type ResizeHandleDirection = (typeof resizeHandleDirections)[number];
export type ResizeHandleProps = Omit<ComponentProps<"button">, "style"> & { direction: ResizeHandleDirection; style?: CSSProperties & ResizeHandleKnobStyle;};
const resizeHandleLabels = { n: "Resize top edge", ne: "Resize top-right corner", e: "Resize right edge", se: "Resize bottom-right corner", s: "Resize bottom edge", sw: "Resize bottom-left corner", w: "Resize left edge", nw: "Resize top-left corner",} as const satisfies Record<ResizeHandleDirection, string>;
export function ResizeHandle({ direction, className, ...props }: ResizeHandleProps) { return ( <button type="button" data-control-ui="resize-handle" data-control-family="resize-handle" data-slot="root" data-direction={direction} aria-label={resizeHandleLabels[direction]} className={cn("absolute touch-none", className)} {...props} /> );}
Knobs
Typed custom properties the recipe paints with. Set one on the root — style, a utility class, or a skin — and every slot inherits it.
| Knob | Syntax | Default |
|---|---|---|
--cui-resize-handle-size | <length-percentage> | 10px |
--cui-resize-handle-hit-size | <length-percentage> | var(--target-min) |
--cui-resize-handle-background | <color> | var(--background) |
--cui-resize-handle-hover-background | <color> | oklch(from var(--primary) l c h / 0.1) |
--cui-resize-handle-border-color | <color> | var(--primary) |
--cui-resize-handle-border-width | <length> | var(--control-rim-width) |
--cui-resize-handle-radius | <length-percentage> | 0px |
--cui-resize-handle-shadow | * | none |