AI-Assisted UI Design: From Random Generation to Stable Output

    Natural-language prompts can produce UI designs that look usable at first glance but vary in details such as corner radius, spacing, hierarchy, and icons. This article explains how to constrain AI output through componentization, elevation rules, interaction states, icon standards, and type scales, and how to operationalize those rules with design tokens, component templates, and a review workflow. It also covers common implementation risks and implications for design-development collaboration.

    1. Where the Problem Starts: Randomness in Natural-Language Descriptions

    Describing UI requirements to an AI in natural language often produces results that look usable at first glance but contain many issues on closer inspection. Generate the same page twice, and button corner radii differ, card spacing expands and contracts, headings and body text barely show a hierarchy, and the same action uses different icons on different pages. The root cause is the same: during each generation, the model makes visual decisions again from scratch, and those decisions are not fixed.

    Design teams face similar problems when they lack a unified specification, with each design file following its own rules. AI amplifies the issue: generation is fast and output volume is high, so inconsistent parts accumulate quickly.

    The key to improving output quality is therefore not writing longer descriptions. It is turning visual decisions from “made ad hoc each time” into “rules agreed in advance.”

    2. Core Method: Constrain Output Across Five Dimensions

    2.1 Componentization: Define Reusable Units Before Assembling Pages

    Buttons, cards, input fields, and list items appear repeatedly across pages. If each generation draws them independently, even visually similar elements will differ slightly in structure and properties, and later changes require finding and fixing each one.

    The approach is to establish a base component library first. Each component defines variants, sizes, and states such as default, hover, disabled, and loading. Page generation may only reference existing components and pass specific content through parameters; it may not create similar elements at will. This way, changing one component updates every place that references it.

    Illustrative pseudocode:

    1. Button:
    2. variant: primary | secondary | ghost
    3. size: sm | md | lg
    4. state: default | hover | disabled | loading
    5. icon: optional
    6. label: string

    2.2 Hierarchy: Establish a Unified Shadow and Elevation System

    UI hierarchy is expressed mainly through color, spacing, shadows, and stacking relationships. If shadows follow no unified rule, modals, dropdown menus, and ordinary cards may each use different shadow parameters, and the visual hierarchy becomes unclear.

    Define a limited set of elevation levels, such as levels 0 through 4, with each level corresponding to fixed shadow parameters, background contrast, and stacking order. Overlay components should use only high levels, content cards should use low levels, and the page background should remain at the lowest level. The number of levels should not be excessive; four to five levels are usually enough for most scenarios. Too many levels make it hard for users to tell the differences.

    2.3 Interaction: Put States and Motion into the Design Output

    A static design file shows only one moment. Developers need to know how a button changes when pressed, how a list is represented while loading, and where a validation error message appears. When this information is missing, implementers can only guess.

    Design output should therefore explicitly document the state set for each interactive component and the conditions for switching between states. Motion also needs to be described clearly: trigger timing, duration range, and easing type, such as fast-then-slow. These descriptions do not need to be complex animation scripts, but they must be clear enough for frontend implementers to reproduce accurately.

    2.4 Icon Consistency: Lock in a Single Icon System

    Mixing multiple icon sets in one interface creates inconsistent stroke widths, corner styles, and visual weight. Each icon may look reasonable on its own, but together they appear messy.

    At the start of a project, choose one icon system, record its style parameters, including stroke width, corner radius, and filled or outlined style, and prohibit mixing in the specification. New icons must match the existing style or they should not be adopted.

    2.5 Typography Hierarchy: Follow a Type Scale

    Reading experience depends heavily on whether font size, font weight, and line height are combined sensibly. When font sizes are set arbitrarily, common problems include multiple levels differing by only one or two pixels, or headings and body text having mismatched line heights.

    Use a fixed type scale that defines roles such as display, heading 1, heading 2, body, and caption, with each role specifying font size, weight, and line height. Pages may only select from the scale and may not set new values on the fly.

    3. Implementation: A Three-Layer Design System Structure

    To keep these constraints effective over time, they need to be captured in materials that both people and machines can read. This usually takes three layers.

    3.1 Design Tokens: Define Atomic Variables

    Design tokens are named variables for the smallest units, such as color, spacing, corner radius, shadow, and typography. They separate concrete values from semantics. For example, use “brand color” for a button color instead of writing a specific hexadecimal value directly, which makes theme switching and unified changes easier.

    Illustrative example:

    1. {
    2. "color": { "brand": "#1F6FEB", "text-primary": "#1A1A1A" },
    3. "space": { "xs": 4, "sm": 8, "md": 16, "lg": 24 },
    4. "radius": { "sm": 4, "md": 8 },
    5. "elevation": {
    6. "1": "0 1px 2px rgba(0,0,0,0.08)",
    7. "2": "0 4px 8px rgba(0,0,0,0.12)"
    8. },
    9. "type": { "body": { "size": 16, "lineHeight": 24, "weight": 400 } }
    10. }

    The values above are illustrative only. Actual values should follow the team’s visual specification.

    3.2 Component Templates: Fix Structure and Parameters

    Component templates describe the structure, configurable options, and allowed token references for each type of base element. Templates reference token names only and do not write color or size values directly. This way, if a generated page deviates from the specification, checking token references quickly reveals the problem.

    3.3 Workflow and Quality Checklist

    The specification should describe the generation workflow: determine page structure first, then select components, then fill in content, and finally run checks. A checklist can cover the following items:

    • Are all colors, spacing values, and corner radii from tokens?
    • Do components come from the component library, with no self-made similar elements?
    • Do shadows belong to predefined elevation levels?
    • Do icons come from the unified icon system?
    • Do font sizes and line heights belong to the type scale?
    • Are all states documented for interactive components?

    Writing the checklist as executable review steps is more reliable than depending on individual experience.

    4. Common Implementation Risks and Responses

    4.1 Icons Depend on Explicit Dimensions

    In many rendering environments, an icon may fail to display or may render at an abnormal size if it has no explicit font size or width and height. The specification should require icons to declare font size, width, and height together. Automated validation can also be added after generation: an icon without dimension declarations is directly marked as invalid.

    Illustrative example:

    1. function validateIcon(node):
    2. if node.type == "icon":
    3. assert node.fontSize and node.width and node.height

    4.2 Long Text Needs Fixed Width Constraints

    If text has no width constraint, it can extend indefinitely in the layout, break its container, or squeeze adjacent elements. Long-text containers should have a fixed width and a clear overflow strategy, such as wrapping, truncation with an ellipsis, or expansion. Short text such as headings and button labels should have a maximum line count.

    4.3 Containers and Responsive Layout

    Fixed-size containers can clip content when content changes, while fully fluid layouts can cause layout instability. Set minimum and maximum widths for page regions, use flexible layout inside to distribute space, and verify key pages at multiple screen widths.

    5. Implications for Design-Development Collaboration

    With constraints in place, AI-generated content becomes closer to an engineering artifact ready for handoff. Designers can shift their focus from pixel-by-pixel adjustments to maintaining specifications, defining components, and reviewing key decisions. Developers can read tokens and component definitions directly, reducing restoration deviations. Teams can also turn experience into rules, lowering the learning cost for new members.

    More constraints mean less flexibility. Teams should distinguish between parts that must be unified, such as color, typography, icons, and spacing, and parts where creative exploration is allowed, such as campaign page visuals and illustration style, so that the specification does not block exploration.