Svg Clip Mask
SvgClipMask reveals its children through an SVG clipPath whose shape can be a preset (blob, arch, diamond, wave) or custom path data. The shape can morph on a loop, step through paths as the page or a container scrolls, or swap on hover.


shadcn add · no workarounds · theme neutral (none shipped)Installation
Requires @smoothui in the registries of your components.json (shadcn adds official directory namespaces automatically).
Usage
import SvgClipMask from '@/components/smoothui/svg-clip-mask';export function Example() { return ( <SvgClipMask shape='blob' animate='morph' className='h-80 w-80'> <img src='/hero.jpg' alt='Product photo' className='h-full w-full object-cover' /> </SvgClipMask> );}- Hero images or feature cards that should break out of plain rectangles with an organic or arch-shaped frame.
- Decorative media blocks where the shape should animate over time, on scroll, or on hover without a canvas or video.
- Landing-page sections that need a scroll-linked shape transition tied to a scrollable container.
- Marketing visuals that need a branded custom SVG path while keeping the children fully interactive and accessible.
Examples
Preset arch with static shape
Clips children to the arch preset with no animation.
import SvgClipMask from '@/components/smoothui/svg-clip-mask';export function ArchCard() { return ( <SvgClipMask shape='arch' className='h-96 w-72'> <img src='/portrait.jpg' alt='Portrait of the team lead' className='h-full w-full object-cover' /> </SvgClipMask> );}Looping morph between shapes
Cycles through morphPaths forever. All paths share the same M/L/C/Z structure so the interpolation stays smooth.
import SvgClipMask from '@/components/smoothui/svg-clip-mask';const morphPaths = [ 'M0,1 L0,0.4 C0,0.18 0.18,0 0.5,0 C0.82,0 1,0.18 1,0.4 L1,1 Z', 'M0,1 L0,0.2 C0,0.1 0.2,0 0.5,0 C0.8,0 1,0.1 1,0.2 L1,1 Z',];export function MorphHero() { return ( <SvgClipMask animate='morph' morphPaths={morphPaths} duration={6} className='h-80 w-80'> <div className='h-full w-full bg-gradient-to-br from-violet-500 to-sky-400' /> </SvgClipMask> );}Scroll-driven shape inside a scroll container
Steps through morphPaths as the referenced scrollable container scrolls.
import { useRef } from 'react';import SvgClipMask from '@/components/smoothui/svg-clip-mask';const morphPaths = [ 'M0,1 L0,0.4 C0,0.18 0.18,0 0.5,0 C0.82,0 1,0.18 1,0.4 L1,1 Z', 'M0,1 L0,0.2 C0,0.1 0.2,0 0.5,0 C0.8,0 1,0.1 1,0.2 L1,1 Z',];export function ScrollReveal() { const scrollRef = useRef<HTMLDivElement>(null); return ( <div ref={scrollRef} className='h-96 overflow-y-auto'> <SvgClipMask container={scrollRef} animate='scroll' morphPaths={morphPaths} className='h-80 w-full'> <img src='/scene.jpg' alt='Scenic landscape' className='h-full w-full object-cover' /> </SvgClipMask> </div> );}Custom path with hover swap
Uses custom objectBoundingBox path data. On hover-capable devices it swaps to morphPaths[1] when hovered.
import SvgClipMask from '@/components/smoothui/svg-clip-mask';const hoverPaths = [ 'M0.5,0 L1,1 L0,1 Z', 'M0.5,0 L1,0.6 L0.5,1 L0,0.6 Z',];export function HoverShape() { return ( <SvgClipMask shape='custom' path='M0.5,0 L1,1 L0,1 Z' animate='hover' morphPaths={hoverPaths} className='h-64 w-64'> <div className='h-full w-full bg-rose-500' /> </SvgClipMask> );}API reference
Accessibility
- The internal SVG is marked aria-hidden='true' and holds only the clipPath definition, so screen readers skip it.
- Clipping is visual only and does not hide content. Children remain in the accessibility tree, so provide meaningful alt text on images.
- The component respects prefers-reduced-motion via useReducedMotion: morph and scroll stop animating and show the first path.
- Hover mode only activates on devices matching (hover: hover) and (pointer: fine). Touch users see the base shape, so do not rely on the hover state to convey information.
- Clipping can cut off focus outlines of focusable children, so verify that focus rings remain visible inside the clipped area.
Docs written by anthropic:claude-haiku-5-5 from the registry source.
Use with Coding Agent
Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.
Use the "Svg Clip Mask" component (smoothui/svg-clip-mask) from its shadcn registry.1. Install it with: npx shadcn@latest add @smoothui/svg-clip-mask2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: children, shape, path, animate, morphPaths, duration, container, className.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport SvgClipMask from '@/components/smoothui/svg-clip-mask';export function Example() { return ( <SvgClipMask shape='blob' animate='morph' className='h-80 w-80'> <img src='/hero.jpg' alt='Product photo' className='h-full w-full object-cover' /> </SvgClipMask> );}```Files & dependencies
- index.tsx→ components/smoothui/svg-clip-mask/index.tsx