Skip to content

Module 03 / Lesson 02

Add motion to an accessible incident form

Module 03 · Real-World ContextStep 02 of 03

Move beyond generic "AI slop" by enforcing real design tokens, accessible motion, and surgical component targeting.

A stressed user opens your status page on a mobile phone under bright sunlight to see if their service is down. If the AI generated low-contrast grey text, erratic animations, and overlapping badges, the user cannot find the answer. When you tell the AI "make the badge look better", it often rewires the wrong component and breaks the entire screen.

Narrated lesson · 1:40
Read the narration transcript

Find the registry component first

The agent’s custom drawer opens, but Tab walks behind it. I look for the shad C N Dialog already in the app and check the project’s component configuration.

The official shad C N MCP can find components from the registries the project actually configures. I review one Motion Primitives transition for the in-app panel. Magic U I is also an option for a restrained public heading reveal.

Watch how the panel enters

The first panel creeps at the start and hits the edge at full speed. It makes the drawer feel unresponsive even though the content is already there.

Emil Kowalski’s Design Skills explain how an ease-out entry starts quickly and settles. A subtle layered shadow can show depth. I keep a visible focus outline and stop extra motion when the user asks for reduced motion.

Run an Anti-Slop review against DESIGN.md

The Anti-Slop installer is called anti slop A I. I use its accessibility review to look for low contrast, hidden focus, and unnecessary decoration. The report is a review aid. The project’s Design file still sets the visual direction.

Here I check which control gets focus on opening, where focus returns after Escape, and whether the text reaches the contrast target. A green report alone cannot prove keyboard behavior.

Test both motion preferences and a failed save

Use only the keyboard to open the form, cycle through its controls, and close it. Then turn on reduced motion. The same controls and focus behavior should work.

Simulate a failed save. The form keeps the draft and shows a useful next step. Now you know the drawer’s craft under a real constraint.

The everyday problem

The incident form looks fine when you click the trigger with a mouse. Now open it with Enter. Press Tab, and focus jumps behind the drawer onto the page. Press Escape and the form stays open. If you test only the screenshot or happy mouse path, everyone who uses the keyboard discovers the problem after release.

Start by asking what someone needs to do: open the incident form, choose the service, enter an update, recover from a failed save, and close the form when they’re ready. Each of those steps has a visible or observable result. You can verify them without debating whether the component looks modern.

Why the agent got it wrong

A model can imitate the visible shape of a dialog with a positioned div. That gets the spacing and backdrop close enough to pass a screenshot review. The interaction contract is harder: focus must move inside, the rest of the page should not take focus, and dismissal should return focus to a sensible place. Setting a high stacking number doesn’t create any of those behaviors.

Even with a component library, the agent may invent a prop the installed component doesn’t expose, or use the wrong kind of popup for the task. Inspect project components and their types. Check where the actual focus decisions live before asking for a patch.

The tool and technique

Use the registry component for keyboard behavior and add motion only when it helps the operator notice a change. Emil Kowalski’s design skills explain why ease-out works for an entrance. The panel responds immediately, then slows into place. Try the comparison in the narration. Keep your focus ring visible on top of the shadow and use the operating system’s reduced-motion setting to verify the simpler experience.

Use the project’s installed shadcn Dialog and form primitives. The official registry documents the available components, and the official MCP server is an optional way to look them up from an agent. Initialize it in the actual project, where components.json declares aliases and registries. A local import search is enough when the right component already exists.

Give the agent a narrow request: use the project dialog, keep the service control labeled, and preserve the draft if the server rejects it. Ask for a clear title and supporting text. Name the expected focus return, so the agent can test it instead of hoping the default matches your flow.

Add restrained motion and run a browser-backed design review

Keep shadcn Dialog in charge of keyboard behavior. Emil Kowalski’s design skills give the agent a reference for ease-out entrances and soft, layered shadows. Preview a Motion Primitives entrance on the dialog’s inner content, and compare Magic UI’s Blur Fade as an optional public heading treatment. Use Anti-Slop for a review against DESIGN.md, then verify its findings in the browser.

# Run from the app directory containing components.json.
npx shadcn@latest view dialog
npx shadcn@latest mcp

# Review registry code and dependencies before adding a component.
npx shadcn@latest view https://motion-primitives.com/c/in-view.json
npx shadcn@latest view @magicui/blur-fade
# Magic UI namespace in components.json:
"@magicui": "https://magicui.design/r/{name}.json"

npx skills@latest add emilkowalski/skills
npx antislop-ai

Review the publish Dialog against DESIGN.md. Keep focus visible.
Use an ease-out entrance and bypass it with reduced motion.
Report actual contrast measurements, focus return, and draft recovery.

# src/app/globals.css (animate the inner content, not the focus trap)
.publish-dialog-body { animation: publish-in 180ms ease-out both; }
@keyframes publish-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .publish-dialog-body { animation: none; }
}

Check Tab, Shift+Tab, Escape, focus return, and a failed save with both motion preferences. Check normal text at a minimum of 4.5:1 in both themes. Use the documented antislop-ai package name. A review report is evidence of findings, and keyboard or contrast results still need observation.

On screen in the status app

The first fragment is representative of the generated popup. It is revealed with a boolean and uses a visual wrapper with no focus management. The revision uses the project primitives with a trigger, title, description, and an explicitly labeled field. This snippet sits inside the client form, whose submit handler deals with application-specific validation and save results.

Display a server rejection near the relevant field or form, and keep the entered text. A disabled submit button during an active request makes it clear the request is being handled, but the server still has to handle duplicate requests safely. After success, close only once the application confirms the update was saved.

src/components/report-incident.tsx

Before

{open && <div className="fixed inset-0 z-[9999]">{form}</div>}

After

<Dialog>
  <DialogTrigger asChild><Button>Report incident</Button></DialogTrigger>
  <DialogContent>
    <DialogTitle>Report an incident</DialogTitle>
    <DialogDescription>Choose the affected service.</DialogDescription>
    <Label htmlFor="incident-summary">Summary</Label>
    <Input id="incident-summary" name="summary" />
  </DialogContent>
</Dialog>

What to watch for

An accessible primitive gives the form a good starting point. You can still break it by omitting the title, overriding keyboard behavior, or burying the validation message in a toast. Native labels and semantic grouping help the browser communicate field names. Preserve a visible focus indicator in the final theme.

Keyboard checks don’t cover every assistive technology behavior. Use a screen reader for a representative path when this form is central to the product. Check the role and accessible name in browser tools as an additional confirmation. A large component import or a copied wrapper can also bring extra behavior, so review the files the agent changed.

How you know it worked

Use only the keyboard. Focus Report incident and press Enter. Read the title and move through the fields with Tab and Shift+Tab. Open the service selector and use its documented arrow key behavior. Press Escape to dismiss the dialog and check that focus returns to the trigger. Reopen it and simulate a rejected save in the local test fixture.

Verify that the error is visible and the previously typed text remains. A teammate can reproduce those steps from your pull request. That is stronger evidence than saying the project uses an accessible library. In the next lesson you’ll point the agent at a specific visual issue while using the same discipline for scope.

In the review, note which input should receive focus when the drawer first opens. For a short form that may be the first field. For longer introductory content it may be the heading. Make that choice based on what the operator needs to understand first.

References