---
name: piruicy-ui
description: Study a reference UI component and implement its interaction in an existing app. Use for a supplied URL, Figma frame, screenshot, or recording when the task needs reproducible behaviour, motion, responsive details, or accessible controls.
---

# Piruicy UI

Turn one reference into a component the host team can review and maintain.

## 1. Observe the interaction

Read the target repository's instructions, primitives, tokens, and closest existing component. Identify its intended user task and where it mounts. Open the supplied reference with available tools. Only inspect materials you are authorized to access. For designs and assets the user owns or has permission to reproduce, match the agreed reference. Otherwise adapt the interaction with the host's own layout, copy, styling, and artwork.

Capture resting, focused, pressed, and settled states. Include cancellation, disabled, empty, loading, or error states when relevant. A still establishes geometry, never duration, easing, keyboard support, or touch. Mark each finding as measured, observed, or assumed. If a missing recording prevents a faithful motion match, use the nearest existing project motion token and disclose the assumption.

## 2. Describe behaviour before styling

Write a short state table with trigger, state change, visible feedback, and focus destination. Sample at the same viewport, device-pixel ratio, and theme. For motion, compare start, first visible response, peak, and settle. Compute elapsed milliseconds from frame indices and actual frame rate or timestamps. Include fast repetition and interruption. Use DevTools or browser inspection to distinguish movement from reflow. Keep the contract short enough to evaluate during review.

## 3. Build on the host system

Reuse the nearest semantic primitive, colour and spacing tokens, and public state APIs. Preserve form submission, focus, and controlled/uncontrolled behaviour. For modes that filter content, commit the selection immediately and announce the changed result count. For a command dialog, support Escape, select via keyboard, and restore focus to its trigger. For drag, specify cancellation and leave an alternative input. For confirmation, protect the action against retries and duplicate submission. Keep decorative motion separate from the task state. Prefer CSS or WAAPI first, and keep rendering effects optional when graphics support is missing.

Use the host's visual system for focus, touch targets, narrow widths, and dark mode. Reserve room for expanding controls. In reduced motion, keep the state change and drop nonessential movement. A quick fade can be sufficient. Prefer transform and opacity for moving affordances when this avoids reflow, and measure before claiming a performance gain.

## 4. Verify and hand off

Run the normal entry point in a real browser. Compare the same scripted sequence with the reference using matched frames when available. Check pointer, keyboard, touch, reduced motion, at least one narrow viewport, and the required fallback or failure states. When precise motion is required, measure time and bounds. Report actual results, any remaining visual differences, and which devices or settings were simulated. Include changed paths, the demo route, and attribution. If comparing two agent prompts, hold model, context, inputs and budget constant and grade both with the same checklist.

## Example

Adapt a hopping category indicator from a reference into a project library. Clicking Motion immediately filters the list and updates its count. The indicator can still be settling. Arrow keys select the next filter and move focus. Reduced motion keeps the selection and list update with minimal feedback. Test a rapid Motion-to-Forms change and confirm only Forms results remain.

More examples in the Piruicy collection: Filter Dot for selection feedback, Toolbar Morph for focus return, Vanish Input for feedback independent of the submission outcome, and Liquid Glass Switch for fallback rendering.

## Decide what to build

Classify the request as a live component, a multi-step flow, or an authored product illustration. A live component uses real inputs and real state. An illustration can replay a defined sequence and show a settled poster. Keep reference materials separate from instructions. Capture only what the user authorizes you to inspect. Before editing, find the normal entry point, render the current state, identify the nearest reusable primitive, and write observable acceptance criteria.

## Measure the parts that move

Record viewport, zoom, pixel ratio, input device, theme, and frame rate. At 60 fps one frame is about 16.7 ms. Report that precision and use actual timestamps for irregular captures. Align the crops around the stationary frame. Compare rest, press, first response, peak, settle, interruption and reversal. Record sizes at rest in CSS pixels, then inspect transforms and clipping separately. A screenshot gives geometry, never easing or keyboard behavior.

| Record | A concrete example |
| --- | --- |
| Trigger and commit | Clipboard resolves before the check draws |
| Geometry and layers | 24 px inset, stable number slots beneath a soft mask |
| Timing | Initial response, exit and entry overlap, settled frame |
| Interruptions | Rapid repeat, drag cancel, Escape, and focus after close |
| Confidence | Measured from footage, observed live, or chosen for this project |

Match composition, reading order, and long text at rest before tuning motion. Verify the component inside its actual host column. Design narrow layouts around the same action rather than shrinking a complete desktop screen. Use the product's type, tokens and allowable assets. Preserve enough space for expanding controls and their focus rings.

## Implementation recipes

### Soft number rolls

Give unchanged digits and punctuation stable slots. Right-align the slots for a minute carry and reserve their width with tabular figures. Move outgoing and incoming glyphs in the same direction while crossfading, and reverse travel when a seek goes backward. A useful starting point is 6–8 px travel, up to 2 px blur, and 200–260 ms for the whole change. These are tuning choices. Hide transient glyphs from assistive technology and keep one readable value. Never announce every passive tick. Test rollover, reverse seek, fast input, pause and the end. Verify that the surviving glyph has no residual blur.

Use haptics as optional feedback on explicit user action. Prefer one short pulse on a committed seek instead of firing on every crossed value. Keep playback and rerenders silent. Test whether the application requests a pulse separately from how it feels on hardware.

### Clipboard confirmation

Write from the real button in its gesture. Keep the button mounted and focused, and reveal success only after the write resolves. Select the code and show a manual-copy message when the automatic write is unavailable or rejected. Ignore a stale write result if the surface has already closed. Use a brief press response and a 200 ms check stroke inside an unchanged button envelope. Under reduced motion, display the final state immediately. Check successful clipboard readback, a forced rejection, and dismissal while a write is pending.

### Checklist and completion

Use a native checkbox or an existing semantic primitive. Let checked state own the result. Put the visual tick in a separate layer and normalize the stroke path to length 1 so the same draw logic works at any size. Keep the tap area larger than the mark. For saved tasks, distinguish pending, committed, and failed writes. Exercise pointer, touch and Space, plus uncheck and immediate recheck. Review the contrast and focus ring in both themes.

### Menus, drag and async feedback

Move focus into a newly opened dialog and restore it when it closes. Exercise empty results and keyboard selection. Filter content immediately even if its indicator is still moving. During drag, handle capture loss and cancellation, preserve the last committed value, and leave a keyboard alternative. Model loading, success and failure when the host performs real work. A toast or checkmark communicates the outcome without replacing visible state.

## Choose a rendering approach

Use CSS for reversible state and simple keyframes. Use WAAPI when an animation must restart from the currently painted position. Use a spring or shared geometry when linked surfaces need to move together. Default to transform and opacity, then measure if blur, clipping, or a shader creates frame-time problems. Keep optional graphics effects separate from the DOM control and provide a fallback. Do not claim a performance gain without a measurement.

For authored product illustrations, [Stageshow](https://benji.org/stageshow) is an optional companion. Choose the closest example, design the focal action and settled poster, and rehearse the result at wide and compact widths. Use the film gate for an authored Stage. For a live component, drive the real control and capture its actual states, including failure paths.

## Rehearsal and handoff

1. Run the normal entry point. In desktop and compact viewports, exercise first render, normal input, rapid repeats, cancellation, keyboard and touch.
2. Set reduced motion before opening the page. Repeat the task and verify the same state and focus changes with less movement.
3. Capture rest, response, midpoint, settle, and an interrupted frame where motion matters. Check optical alignment, clipping, focus, and neighboring controls. Assertions should cover state, geometry, or data that screenshots cannot prove.
4. Exercise real clipboard success and failure, graphics fallbacks, and haptic requests when those apply. Distinguish simulated input from a physical-device check.
5. Hand off the origin and attribution, the changed files and demo route, measured versus chosen values, verified checks, and unresolved differences. If you compare two prompting workflows, hold the model, reference, repository, and budget constant.
