Building UI Components

Prompt UI components that match your framework, design system, and state needs, with the states and props spelled out.

TL;DR

  1. Specify the framework, the design system, the props, and every state the component must handle.
  2. Point at an existing component as a pattern so new ones match your conventions.
  3. Name all the states up front: default, loading, empty, error, disabled, and focus.

Pin The Stack

    Framework & Version

    State the framework and version so APIs and patterns match.

    "React 18 function component,
    TypeScript, no class components."
    Design System

    Name your component library and tokens to reuse, not reinvent.

    "Use @/ui Button and our Tailwind
    tokens. No inline hex colors."
    Pattern Example

    Point at a real component to mirror structure and style.

    "Match the structure of
    Components/Card.tsx: <paste>"

Define The API

    Props & Types

    List exact props, types, and which are optional.

    props: { items: Item[]; onSelect:
    (id: string) => void; loading?: boolean }
    Events

    Name the callbacks and when they fire.

    "onSelect fires with the item id
    on row click."
    Composition

    Say how it slots into the app so it composes cleanly.

    "Renders inside a <Card>; accepts
    children for the footer."

Name Every State

    Data States

    Default, loading, empty, and error should all be handled.

    "Handle: loading skeleton, empty
    message, error with retry."
    Interaction States

    Hover, focus, active, disabled, and selected where relevant.

    "Disabled and focus-visible styles
    from the design system."
    Edge Content

    Long text, many items, missing images, and overflow.

    "Truncate long titles; handle 0 and
    500 items gracefully."

Baseline Quality

    Semantic & A11y

    Ask for semantic HTML, labels, and keyboard support from the start.

    "Use a <button>, label the icon,
    keyboard operable."
    No Magic Values

    Use tokens and props, not hard-coded colors or sizes.

    "Spacing and color from tokens only."
    Review Rendered

    Run it and check the real states, not just that it compiles.

    See loading, empty, and error
    in the browser.

Tips

  1. Give your tokens or utility classes ('use our Tailwind config, not inline hex') so styling fits.
  2. List the exact props and their types so the component's API is right the first time.

Warnings

  1. Models default to inline styles and ad-hoc classes; anchor to your design system or you get drift.
  2. Generated components often skip loading, empty, and error states and keyboard/focus handling.

In Practice

FAQ