Recreating Design Mockups with AI Coding Tools: Why Image Slicing Is the Real Challenge

    This article describes a hands-on experiment in recreating a product design mockup as a working React page with AI coding tools. AI handled component structure and most styling well, but turning design visuals into usable image assets was largely beyond its reach and took more than 40% of the total effort. The article covers the experiment setup, where AI tools fell short, a practical asset management approach, and recommendations for teams facing similar workflows.

    1. A Task That Looks Simple but Is Painful in Practice

    The goal is to recreate a product mockup as a fully working React page, as faithfully as possible. This sounds like something a front-end engineer would do in the first week on the job. The tech stack is not complicated either. React, Next.js, and Tailwind CSS, plus a mature state management or data-fetching solution, are enough to build a static recreation page.

    But after two days of hands-on work, I found a counterintuitive fact: the hardest part is not writing React, but slicing the images.

    This conclusion became clearer as AI coding tools spread. AI already writes code quite well. Slicing assets, however, is something AI can barely help with.

    2. My Experiment Setup

    To keep the experiment as fair as possible, I used the following setup:

    • Design mockup: A complete product mockup with a navigation bar, hero section, card list, data table, form, and footer, at a standard desktop width, plus a mobile adaptation mockup.
    • Tech stack: React, Next.js, and Tailwind CSS. This is one of the most popular combinations in the community, with rich ecosystem resources and ample AI training material.
    • Tools: I rotated among several AI coding assistants, including conversational code generators, IDE-integrated completion and refactoring tools, and online platforms that generate pages directly from design mockups.

    Every tool received the same image, the same tech stack requirements, and the same prompt. I compared the results on four dimensions: structural fidelity, style fidelity, interaction completeness, and the extra effort I had to put in during the process.

    3. How AI Tools Performed: Writing Code Is No Longer the Bottleneck

    3.1 Structure and Code Generation: Little Manual Work Needed

    The results were surprisingly consistent. Regardless of the tool, the generated component structure was clean. The navigation bar, hero section, cards, and tables were split into separate components, and the props design mostly followed the single responsibility principle.

    For a typical card component, AI could produce output like this:

    1. interface ProductCardProps {
    2. title: string;
    3. description: string;
    4. price: number;
    5. imageUrl: string;
    6. onAction?: () => void;
    7. }
    8. export function ProductCard({ title, description, price, imageUrl, onAction }: ProductCardProps) {
    9. return (
    10. <div className="rounded-xl border border-gray-200 bg-white p-5 shadow-sm transition hover:shadow-md">
    11. <img src={imageUrl} alt={title} className="aspect-video w-full rounded-lg object-cover" />
    12. <h3 className="mt-4 text-lg font-semibold text-gray-900">{title}</h3>
    13. <p className="mt-2 text-sm text-gray-500 line-clamp-2">{description}</p>
    14. <div className="mt-4 flex items-center justify-between">
    15. <span className="text-xl font-bold">¥{price}</span>
    16. <button
    17. onClick={onAction}
    18. className="rounded-lg bg-blue-600 px-4 py-2 text-sm text-white hover:bg-blue-700"
    19. >
    20. View details
    21. </button>
    22. </div>
    23. </div>
    24. );
    25. }

    The quality of this code meets or exceeds the daily output of many mid-level engineers. AI handled Tailwind class names, responsive breakpoints, and semantic HTML competently.

    3.2 Style Fidelity: Roughly 80% Right, the Rest Needs Human Work

    At the style level, every tool produced pages that looked right at a glance. Spacing, font sizes, and colors were broadly correct, and the flex and grid layout choices were generally sensible.

    The remaining differences matter most to designers:

    • Precise spacing: Subtle differences, such as 16px versus 18px in the mockup, were often unified to 16px by AI.
    • Font details: Font weight, line height, and letter spacing often did not match.
    • Missing states: AI rarely added hover, focus, disabled, and loading states on its own. These states are not visible in the mockup.
    • Multi-device adaptation: When inferring the mobile layout from the desktop mockup, AI usually switched multi-column layouts to a single column. It did not rethink the information hierarchy.

    A person must check and correct these issues one by one. The fixes are themselves coding work, and AI can apply them quickly through follow-up prompts, so the cost stays manageable.

    4. The Real Bottleneck: Image Slicing

    4.1 Why Slicing Became a Hard Problem

    The problem lies in the assets. Design mockups often contain many visual materials: product screenshots, portrait photos, icons, logos, and decorative shapes with gradients and shadows. To run the page, these materials must become real image files.

    AI coding tools have clear limits here:

    1. They cannot export assets from the original design. AI usually receives a flat image or a text description. It has no access to the design source file, so it cannot export each layer as PNG, SVG, or WebP.
    2. AI-generated placeholders do not match the design. Some tools generate image links or placeholder shapes, but these do not match the original. Correcting them adds work.
    3. Cropping precision depends entirely on people. Whether an icon should be SVG, whether a photo needs @2x or @3x versions, and whether a background image should be sliced and tiled all have no standard answer. AI will not make these decisions for you.

    4.2 The Hidden Workload of Slicing Exceeded Expectations

    In the end, I spent more than 40% of the total task time turning the visual elements of the mockup into usable assets. This work included:

    • Cropping each element: Selecting each icon and image precisely from the mockup, without background noise along the edges.
    • Format decisions: Converting vector graphics to SVG, photos to WebP, and images with transparent backgrounds to PNG.
    • Size management: An image displays at different sizes across breakpoints, so I had to export multiple resolution versions.
    • Naming and organization: Following conventions such as icon-arrow-left.svg and banner-hero@2x.webp, and placing files in the correct location under public/.
    • Performance: Compressing large images, declaring lazy loading, and writing srcSet.

    4.3 A Reusable Asset Management Approach

    To avoid starting from scratch each time, I put together a set of directory and referencing conventions:

    1. public/
    2. images/
    3. hero/
    4. banner.webp
    5. banner@2x.webp
    6. products/
    7. card-01.webp
    8. icons/
    9. arrow-left.svg
    10. search.svg

    For referencing, I wrap image handling in a single component so that lazy loading and multi-resolution settings live in one place:

    1. export function SmartImage({ src, alt, sizes }: {
    2. src: string; alt: string; sizes: string;
    3. }) {
    4. return (
    5. <img
    6. src={src}
    7. alt={alt}
    8. sizes={sizes}
    9. loading="lazy"
    10. className="object-cover"
    11. />
    12. );
    13. }

    This wrapper is thin, but it turns slicing from a routine chore into a manageable engineering task. The loading strategy for all images can be changed in one place, and new assets only need to follow the naming convention and go into the right directory.

    5. Rethinking the Workflow

    This practice changed my expectations for how work should be divided in AI-assisted development:

    Stage AI Handles Human Handles
    Component structure design Most of it Review and adjustment
    Style fidelity About 80% Fine-tuning and state completion
    Interaction logic Most of it Edge case handling
    Image slicing and asset preparation Almost none All of it

    This division shows an important point. AI is good at generating code from descriptions, while slicing is a physical operation that turns pixels into assets. It happens outside the code, and current AI coding tools cannot reach it.

    6. Recommendations for Peers

    1. Do the slicing first. Before asking AI to generate code, spend half a day slicing, naming, and organizing all assets. Once the assets are ready, AI code generation becomes faster and more accurate, because it no longer has to guess image paths.
    2. Give AI an asset list. List each asset’s path, size, and purpose in the prompt. This helps prevent AI from inventing image addresses that do not exist.
    3. Establish team-level asset standards. Document conventions for directory structure, naming rules, and format choices. This turns slicing from a personal skill into a standard team process.
    4. Do not rely on a single generation. The first draft of an AI-generated page is only a starting point. State coverage, accessibility, and responsive details still need an engineer’s judgment.

    7. Conclusion

    Mature AI coding tools have freed front-end engineers from much boilerplate code. They also exposed problems that the coding workload used to hide. Converting a design mockup into code is not fundamentally a coding problem. It is a complete pipeline that includes slicing, asset management, and fidelity verification. The core skill for front-end work may no longer be who writes components faster, but who designs this pipeline better: letting AI handle what it can, and letting people focus on the roughly 40% that AI cannot reach.