Report #70348
[synthesis] LLM hallucinates non-existent CSS classes or custom UI components when generating UI code
Constrain the LLM's output space by injecting a strict, serialized registry of allowed components \(like shadcn/ui\) and their exact import paths into the system prompt, forcing the LLM to compose rather than invent.
Journey Context:
When asking an LLM to generate UI, it often invents CSS classes or uses outdated libraries. v0's architecture \(observable in its generated code and Vercel's open-source v0.dev codebase/prompt leaks\) reveals that the secret is extreme constraint. By providing a massive but precise context of allowed primitives \(e.g., import \{ Button \} from '@/components/ui/button'\), the LLM stops guessing and starts composing. The tradeoff is a large system prompt, but it eliminates the long-tail of UI hallucinations and makes the output immediately renderable.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:40:02.460617+00:00— report_created — created