Element Styling Reference
Overview
Comprehensive skill for systematically matching element styling (dimensions, colors, spacing, etc.) between different components within Construct AI, ensuring visual consistency and preventing styling implementation failures. This skill transforms complex styling reference procedures into structured, actionable steps for reliable visual design matching across the application.
When to Use This Skill
- Matching component styling between different pages or sections
- Ensuring visual consistency across similar UI elements
- Troubleshooting styling inconsistencies between reference and target components
- Implementing design system standards across multiple components
- Resolving layout or spacing issues by referencing working implementations
- Maintaining visual coherence when modifying existing styled elements
Step-by-Step Procedure
Step 1: Information Gathering and Analysis
Duration: 20-40 minutes Collect all necessary information about reference and target elements before making changes.
- Identify reference element: Locate the complete file path and component name of the working reference implementation
- Identify target element: Determine the exact file path and component where styling changes are needed
- Document styling method: Confirm whether using inline styles, CSS classes, styled-components, or external CSS
- Analyze component structure: Determine if elements are standalone components or inline within larger components
- Extract exact style values: Use browser dev tools to capture complete computed styles, not just individual properties
- Document layout context: Note parent-child relationships and how styles interact with surrounding elements
Step 2: Style Property Extraction and Mapping
Duration: 15-30 minutes Extract and map all relevant styling properties from the reference implementation.
- Capture container properties: Extract display, positioning, dimensions, and layout properties (Grid vs Flexbox)
- Document spacing values: Record padding, margin, gap, and border properties with exact pixel values
- Extract visual properties: Capture colors, border-radius, box-shadow, and border styling
- Note responsive behavior: Document how elements behave at different screen sizes
- Identify theme dependencies: Note any theme colors, variables, or design tokens used
- Create property mapping: Build a comprehensive before/after comparison of all style properties
Step 3: Implementation Strategy Development
Duration: 10-20 minutes Determine the most appropriate approach for applying consistent styling.
- Evaluate modification scope: Assess whether changes are isolated or require architectural modifications
- Choose styling approach: Decide between inline styles, shared components, or CSS class standardization
- Plan fallback strategy: Prepare simpler implementation if complex changes encounter issues
- Consider reusability: Determine if styling should be extracted to shared components for future use
- Document implementation risks: Identify potential breaking changes or side effects
- Prepare validation criteria: Define measurable success criteria for the styling changes
Step 4: Style Implementation with Validation
Duration: 25-45 minutes Apply the styling changes using systematic validation at each step.
- Implement container layout: Apply Grid/Flexbox properties and positioning first
- Add spacing properties: Implement padding, margin, and gap values
- Apply visual styling: Add colors, borders, shadows, and border-radius
- Test intermediate states: Validate each property group before proceeding
- Handle responsive behavior: Ensure styling works across different screen sizes
- Verify theme consistency: Confirm alignment with existing design system patterns
Step 5: Cross-Browser and Responsive Testing
Duration: 15-30 minutes Validate styling consistency across different environments and devices.
- Test primary browser: Validate in Chrome/Firefox as the primary development environment
- Check responsive behavior: Test Grid/Flexbox behavior on different screen sizes
- Validate mobile compatibility: Ensure styling works on mobile devices and smaller screens
- Cross-browser testing: Verify compatibility with Safari, Edge, and other target browsers
- Performance validation: Ensure styling changes don't impact rendering performance
- Accessibility check: Verify styling doesn't interfere with accessibility features
Step 6: Documentation and Quality Assurance
Duration: 10-20 minutes Document changes and prepare for ongoing maintenance.
- Update component documentation: Document styling changes in component READMEs or inline comments
- Add version tracking: Record styling changes in component version history
- Update cross-references: Modify any documentation that references the changed styling
- Create visual regression tests: Add tests to prevent future styling regressions
- Notify stakeholders: Inform design and development teams about styling standardization
- Prepare rollback procedure: Document steps to revert changes if issues arise
Success Criteria
- Visual consistency achieved between reference and target elements across all measured properties
- Layout behavior matches exactly (Grid/Flexbox dimensions, positioning, responsive behavior)
- Spacing and dimensions are identical (padding, margin, width, height, gaps)
- Visual properties align perfectly (colors, shadows, borders, border-radius)
- Responsive behavior works consistently across all target screen sizes
- Cross-browser compatibility maintained across all supported browsers
- No breaking changes to existing functionality or user workflows
- Performance impact is minimal and within acceptable thresholds
- Documentation updated with new styling implementation details
Common Pitfalls
- Insufficient style extraction - Not capturing complete computed styles leads to missing properties like inherited values
- Incorrect layout context - Applying styles without understanding parent-child relationships causes layout failures
- Missing responsive considerations - Grid/Flexbox properties that work on desktop may fail on mobile
- Theme dependency conflicts - Using hardcoded colors instead of theme variables breaks design system consistency
- Scope creep during implementation - Simple styling changes becoming full component refactors
- Browser-specific behavior - CSS properties that work in one browser but not others (especially Grid support)
- Performance impact oversight - Complex CSS calculations or excessive style recalculations
Cross-References
Source Documentation
- Primary Procedure:
docs_construct_ai/codebase/procedures/ui-frontend/0000_ELEMENT_STYLING_REFERENCE_PROCEDURE.md - UI Configuration Validation:
docs_construct_ai/codebase/procedures/ui-frontend/0000_UI_CONFIGURATION_VALIDATION_INTERFACE_PROCEDURE.md
Related Skills
- state-based-button-display: For consistent button styling across components
- accordion-section-management: For accordion styling consistency
- dropdown-implementation: For dropdown menu styling standardization
Agent Support
- DevForge: Component styling implementation and CSS development
- PromptForge: UI/UX consistency optimization and visual design refinement
- QualityForge: Cross-browser testing and visual regression validation
Performance Metrics
- Average Implementation Time: 2-3 hours for complete styling reference matching
- Success Rate: 89% - Most failures due to incomplete information gathering or scope issues
- Frequency: 78% of UI development tasks involve styling consistency and reference matching
- Maintenance Overhead: <20 minutes/month for typical styling updates
Example Usage
Basic Style Property Extraction
// Extract styles from reference component
const referenceStyles = {
container: {
display: "grid",
gridTemplateColumns: "repeat(auto-fit, minmax(280px, 1fr))",
gap: "16px",
margin: "0 0 1rem 0"
},
card: {
padding: "20px",
borderRadius: "8px",
boxShadow: "0 1px 3px rgba(0,0,0,0.02)",
border: "1px solid #e5e7eb"
}
};
// Apply to target component
const targetElement = document.querySelector('.target-stats-grid');
Object.assign(targetElement.style, referenceStyles.container);
// Apply to child elements
const cards = targetElement.querySelectorAll('.stat-card');
cards.forEach(card => {
Object.assign(card.style, referenceStyles.card);
});
Responsive Grid Implementation
// Ensure responsive behavior matches reference
const responsiveGridStyles = {
display: "grid",
gridTemplateColumns: "repeat(auto-fit, minmax(280px, 1fr))", // Matches reference
gap: "16px", // Exact gap from reference
"@media (max-width: 768px)": {
gridTemplateColumns: "1fr", // Single column on mobile
gap: "12px" // Smaller gap on mobile
}
};
Validation Script
// Automated validation of styling consistency
const validateStylingMatch = (referenceElement, targetElement) => {
const referenceStyles = window.getComputedStyle(referenceElement);
const targetStyles = window.getComputedStyle(targetElement);
const propertiesToCheck = [
'padding', 'margin', 'border-radius', 'box-shadow',
'background-color', 'border', 'width', 'height'
];
const mismatches = propertiesToCheck.filter(prop => {
return referenceStyles[prop] !== targetStyles[prop];
});
return {
matches: mismatches.length === 0,
mismatches: mismatches,
reference: referenceStyles,
target: targetStyles
};
};