How to Choose UI Components for AI-Assisted Coding
Compare component states, keyboard behavior, and framework examples before adopting them.
Ask an AI to “make a modal” and you may get a screen quickly. But the name alone does not tell you whether Escape closes it, focus stays inside it, or confirmation and cancellation lead to the right states. Choosing a component is not just choosing a shape. It means matching the user's task and the states they will encounter.
This guide walks through what to check when adapting a library example to a product. It also describes the implementation coverage available in Quark's catalog.
1. User Tasks and UI Pattern Selection
Instead of stopping at “add tabs,” describe the user's goal: “Switch between invoices and payment methods while viewing each in the same content area.” That helps determine whether tabs, filters, or links to separate pages fit the task.
- Tabs switch between related panels in the same context. They need keyboard navigation, a selected state, and a relationship between each tab and its panel.
- Filters narrow or sort a result set. Check whether multiple values can be selected and whether the result count changes.
- Accordions expand or collapse supporting information. Decide whether multiple items can remain open and whether each heading communicates its state.
- Modals or dialogs temporarily separate a task or request input. Design the close, cancel, and submit behavior, including focus and data state afterward.
Components can look similar while creating different expectations and keyboard behavior. If the choice is unclear, ask the AI to compare options and explain their interactions before implementing one.
2. Component States and Transitions
Do not describe only the normal state. A short table gives designers, developers, and AI a shared interaction model.
| Component | Starting state | User action | Expected result |
|---|---|---|---|
| Tabs | First tab selected | Press Right Arrow or click another tab | Selection and panel update together |
| Search field | Empty | Enter and clear a query | Results update, and clearing restores all results |
| Date picker | No date | Choose a date, then cancel | Value is committed only after Apply |
| File upload | No file | A validation error occurs | Explain why and how to fix it |
Add loading, empty results, input errors, or success feedback when they apply. For asynchronous actions, specify what happens after activation, how duplicate submissions are prevented, and whether the user can retry after failure.
3. Framework and Project Conventions
A framework listed by a library does not guarantee that its example fits your product. Check the project's React version, styling approach, icon package, and form conventions first. Then adapt the example for that framework to the existing codebase.
In the repository snapshot, Quark has 80 component metadata entries. Their metadata marks Svelte, React, Vue, and Vanilla JS as supported frameworks, and each folder contains an example file for those frameworks. The Vanilla example is a JavaScript module that generally returns a DOM element, not a packaged component.
That metadata does not mean there is a production package for all four frameworks or that every example has received equivalent validation. Some detailed specifications provide framework-specific implementation guidance, such as using the project's existing component or UI library first and consulting the guidance only when a custom implementation is needed. Quark's current public catalog presents 64 component groups; groups, variants, and source folders are different counts. Check the actual source, implementation guidance, preview, and dependencies for the item you choose, then verify it in your app.
4. Component Code Review
Do not copy a name and description without checking the implementation. Review at least these areas:
- States and events: What changes selection, open state, or error state? Is the value owned by the parent or by the component?
- Accessible structure: Are the control's name, role, and
aria-*relationships appropriate? Are keyboard conventions implemented for tabs, dialogs, and menus? - Style dependencies: Does it require global CSS, variables, fonts, icons, or a wrapper element?
- Product contract: Does its submitted data, validation, loading behavior, or server-error handling match the app's existing rules?
- Responsive and long content: Does it work with small screens, long labels, translated text, and enlarged type?
Instead of “copy this example,” ask the AI to find similar project patterns and dependencies, compare the example for the project's framework, then adapt it to the existing state management and accessibility conventions.
5. Design Tokens and Brand Adaptation
Shared tokens help manage recurring choices such as spacing and color. Before hardcoding a new hex color or spacing value, find the project's tokens and map the component to their intended meanings.
Quark's examples assume its shared preview.css, --q-* tokens, and q-preview wrapper. If you use the styles elsewhere, load the shared stylesheet or map its values to your app's tokens. Some examples may import an icon package, so inspect the source for actual dependencies. Quark's theme preview is an adapter for shared tokens and some button behavior; it does not fully convert every branded component into an official implementation.
Mapping tokens also does not automatically align typography, voice, or interaction with a product's brand. Designers still need to decide and review those details.
6. Destructive Action Dialog Example
Suppose a user wants to delete a saved payment method. Before showing a modal, ask whether deletion is reversible, whether another method is required, and where the user should go afterward. A confirmation dialog may fit an irreversible action. For a recoverable draft, an undo toast may be faster and less disruptive.
When adapting an AI-generated dialog, check that its title names the action and target; initial focus is on the safer action; cancel, close, and Escape follow a clear policy; the confirmation button prevents duplicate submissions; server errors leave a useful retry path; and focus returns to a predictable place after completion.
A sample cannot decide these product policies for you. It is a starting point that must be adapted to the app's data flow and user expectations.
7. AI Coding Prompt Example
First inspect the project's framework, existing components, tokens, forms, and accessibility conventions.
Requirement: [user goal and task]
Required states: [default, loading, empty, error, success, and others]
Constraints: [supported browsers, viewport, data contract, dependencies]
Compare candidate component structures and keyboard behavior, then choose the best fit.
Adapt it to the existing conventions and check responsive behavior, names, focus, and error handling.
Report the example used, new dependencies, and anything you could not verify.
Pre-Release UI Component Checklist
- Does the component fit the user's actual task?
- Are expected input and server-response states covered?
- Can people complete the main flow using a keyboard and assistive technology?
- Does the implementation follow the project's framework, styling, and data conventions?
- Does it work on small screens with long and translated text?
- Are its dependencies and validation limits understood?
- Are product policies and visual details that need human review clear?
A component library provides reusable starting points. A good choice is not complete when you find a matching name. It is complete when you have checked the states it represents and how it should behave in the product.