- Home
- Skills
- Supercent Io
- Skills Template
- Ui Component Patterns
ui-component-patterns_skill
- Shell
24
GitHub Stars
2
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill supercent-io/skills-template --skill ui-component-patterns- SKILL.md12.7 KB
- SKILL.toon658 B
Overview
This skill teaches how to build reusable, maintainable UI components using modern design patterns for React and TypeScript. It focuses on props API design, composition, render-props, custom hooks, performance optimizations, and accessibility. Use it when creating component libraries, design systems, or scalable frontend architectures. The guidance is practical and example-driven for real-world component development.
How this skill works
The skill inspects component responsibilities and prescribes a clear Props API with TypeScript interfaces and sensible defaults. It recommends composition patterns (compound components, polymorphic as prop), render-props/children-as-function for flexible rendering, and extracting logic into custom hooks. Performance guidance covers memoization, useCallback/useMemo, and avoiding inline objects to reduce unnecessary re-renders.
When to use it
- Building a reusable component library or design system
- Creating complex components with multiple variants (Button, Modal, Dropdown)
- Refactoring duplicated UI into single-responsibility components
- Implementing accessible components with proper aria and roles
- Scaling frontend architecture to reduce prop drilling and improve maintainability
Best practices
- Single responsibility: each component does one thing and keeps UI logic only
- Define Props with TypeScript interfaces and provide sensible defaults
- Prefer composition (children, compound components) over many props
- Extract business logic to custom hooks; keep components pure and presentational
- Avoid inline objects/functions in JSX; use useMemo/useCallback and React.memo
- Ensure accessibility: aria-*, role, keyboard support, and focus management
Example use cases
- A Button component with variant/size props, loading state, and HTML attribute passthrough
- A Card compound component exposing Card.Header, Card.Body, Card.Footer for composition
- A Dropdown that accepts items and a renderItem function for custom rendering
- A Modal paired with a useModal hook for open/close state and focus handling
- An Accordion using Context to coordinate active items without prop drilling
FAQ
Use controlled components when parent needs exact state control or sync; choose uncontrolled for simple, self-contained UI where local state is sufficient. Offer both APIs when appropriate.
How do I avoid prop drilling for deeply nested components?
Use composition patterns and React Context for shared state, or lift state into a custom hook that components can consume to avoid passing props through many layers.