Inspector Clip

About this component

Inspector Clip

The shape a box is cut to. Every thumbnail is drawn with the property it sets, so the grid is not a picture of the shapes but the shapes themselves, and a shape with a number in it brings its own slider out. Percentages throughout, so a shape survives a box that changes size.

Usage

The import and the props worth knowing about, in one place.

import { InspectorClip, clipToCss } from "@/components/beste/component/inspector-clip";

<InspectorClip label="Shape" defaultValue={{ shape: "hexagon" }} />

<InspectorClip
  label="Mask"
  value={clip}                   // { shape, amount }
  onValueChange={setClip}
  onOpenChange={(open) => console.log("editor open:", open)}
  columns={4}                    // shapes per row, five by default
  tone="outline"                 // "muted" (default) | "outline" | "ghost"
  size="sm"                      // "sm" | "default" | "lg"
/>

// Your own shapes. A function makes the shape parametric, which is what brings
// the amount slider out.
<InspectorClip
  label="Shape"
  shapes={[
    { value: "none", label: "None", css: "none" },
    { value: "arch", label: "Arch", css: "ellipse(50% 100% at 50% 100%)" },
    {
      value: "notch",
      label: "Notch",
      css: (amount) => `inset(0 0 ${amount}% 0)`,
      defaultAmount: 20,
      amountLabel: "Depth",
    },
  ]}
/>

<div style={{ clipPath: clipToCss(clip) }} />

Keyboard and gestures

Every one of these is in the component already. They are listed because a props table cannot mention a gesture, so nothing else on this page can tell you they exist.

Enter / SpaceOpen the grid from the row
TabWalks the shapes in the order they read
Left / RightStep the amount, for a shape that has one

Props

Read from the component's own type, so this cannot drift from what it accepts.

PropTypeDefaultDescription
label*string—Label rendered on the left, inside the row.
iconLucideIcon—Optional leading icon shown before the label.
valueClipValue—Controlled value. Pair it with `onValueChange`.
defaultValueClipValue—Initial value in uncontrolled mode.
onValueChange(value: ClipValue) => void—
onOpenChange(open: boolean) => void—Fires when the editor opens or closes.
shapesClipShape[]—The shapes on offer. Each carries the CSS it comes to, as a string or as a function of one number — and a function is what brings out the amount slider.
columnsnumber5Shapes per row in the grid.
disabledboolean—Block interaction and dim the row.
tone"muted" | "outline" | "ghost""muted"Surface treatment: filled (default), hairline outline, or bare until hover.
size"sm" | "default" | "lg""default"Row height preset.
classNamestring—
aria-labelstring—Accessible name. Falls back to `label`.

More Inspector components

View all Inspector