Advanced Workflow
Relevant source filesPurpose and Scope
This document covers non-standard scenarios where the 15 composite UI components from src/components/ui/ are insufficient for your use case. You will learn how to compose the five core primitives (Block, Box, Grid, Flex, Stack) from src/core/ui/ to build custom interfaces.
For typical component usage with ready-made composites, see Basic Workflow. For general usage guidelines and patterns, see Best Practices.
Sources: .devin/wiki.json191-198 src/components/GUIDE_CREATE_FORM.md1-10
When to Use Advanced Workflow
The library provides 15 composite components that cover ~80% of common UI scenarios. However, certain elements are intentionally absent from the library:
Decision Tree: Basic vs Advanced Workflow
Building Forms with Block and Box
The library does not include dedicated Form, Label, or Input components. Instead, use the polymorphiccomponent prop on Block and Box to render semantic HTML elements with the full variant system.
Component Prop Pattern
Thecomponent prop transforms primitives into any HTML element while maintaining type-safe variant props:
Form Structure Pattern
UseBlock with component="form" as the form wrapper, applying layout and styling variants:
Form Container Structure:
Example form structure (see src/components/GUIDE_CREATE_FORM.md14-32):
Input Field Patterns
All input types useBox with component="input" and standard HTML attributes:
Text Input (src/components/GUIDE_CREATE_FORM.md37-50):
Textarea Fields
UseBox with component="textarea" for multi-line text input:
Basic Textarea (src/components/GUIDE_CREATE_FORM.md99-115):
Complete Form Example
Contact Form Architecture:- Form event handling:
onSubmitprop on form Block - Field structure: Block wrapper → label → input in each group
- Spacing:
className="space-y-6"on form,className="space-y-2"on field groups - Validation:
requiredattribute on inputs - Focus states: Combine variants with
classNamefor focus rings
Multi-Column Form Layout
For complex forms, useBox with grid display (src/components/GUIDE_CREATE_FORM.md228-277):
Form Validation Pattern
Build reusable validated input components (src/components/GUIDE_CREATE_FORM.md311-339):- Conditional
borderColorandbgbased on error state - Dynamic focus ring colors via
className - Error message display with
Boxfor text color - Props spreading with
{...props}for HTML attributes
Available Variant Props for Primitives
All primitives support the 12 CVA variant categories. Key variants for form building:Spacing Variants
Layout Variants
Border & Style Variants
Color Variants
Sources: src/components/GUIDE_CREATE_FORM.md279-301 src/components/README.md205-222
Best Practices for Advanced Composition
Form Field Guidelines
- Always set
w="full"on input fields for consistent width (src/components/GUIDE_CREATE_FORM.md304) - Use
Blockfor form structure (form element, field groups) (src/components/GUIDE_CREATE_FORM.md305) - Use
Boxfor actual inputs (input, textarea, select) (src/components/GUIDE_CREATE_FORM.md306) - Combine variant props with Tailwind classes for focus states (src/components/GUIDE_CREATE_FORM.md307)
- Use
minHfor textarea instead of fixed height (src/components/GUIDE_CREATE_FORM.md308) - Apply
className="resize-none"to prevent textarea resizing if needed (src/components/GUIDE_CREATE_FORM.md309)
Variant + ClassName Hybrid Pattern
The variant system covers ~80% of styling needs. For remaining 20%, combine variants withclassName:
className:
- Interactive states (
:hover,:focus,:active) - Pseudo-elements (
:before,:after) - Complex animations
- Grid/flex utilities not covered by variants
- Responsive breakpoints beyond variant system
Custom Component Composition
Building Reusable Composites
When you need the same pattern repeatedly, extract it into a custom component: Pattern: Labeled Input Field- Accept variant props and HTML attributes via props spreading
- Handle conditional logic (error states, validation)
- Maintain accessibility (label associations, ARIA attributes)
- Return primitive composition (Block + Box)
Non-Form Custom Scenarios
Custom Interactive Widgets: When building application-specific widgets (sliders, pickers, custom controls):- Start with
BoxorBlockas container - Apply semantic
componentprop (<Box component="button">for clickable elements) - Use variant props for layout and styling
- Add event handlers (
onClick,onChange, etc.) - Combine with
classNamefor complex interactions
- Compose
Grid,Flex, orStackfrom src/core/ui/ - Apply layout variants (
cols,gap,align,justify) - Nest primitives for hierarchical structure
- Use
Blockwithcomponent="section"/component="aside"for semantic markup
Comparison: Basic vs Advanced Workflow
When to use each approach:
Sources: src/components/README.md1-19 src/components/GUIDE_CREATE_FORM.md1-10
Summary
The advanced workflow enables building custom interfaces when the 15 composite components are insufficient:- Forms: Compose
Block+Boxwithcomponentprop for form elements, labels, and inputs - Custom widgets: Use primitives with semantic
componentprops and variant system - Unique layouts: Compose
Grid,Flex,Stackfor structural requirements - Hybrid approach: Combine variant props (~80% coverage) with
classNamefor edge cases