
Building Components
Design and ship accessible, composable UI primitives with tokens, polymorphism, and docs ready for npm or a registry.
Install
npx skills add https://github.com/vercel/components.build --skill building-componentsWhat is this skill?
- Artifact taxonomy: primitives, components, blocks, and templates
- Accessibility reference: ARIA, keyboard navigation, focus management, WCAG
- Composition patterns: slots, render props, controlled vs uncontrolled state
- as-child and polymorphism patterns for flexible DOM rendering
- Design tokens, theming, npm/registry publish, and component documentation
Adoption & trust: 6k installs on skills.sh; 769 GitHub stars; 3/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
Recommended Skills
Frontend Designanthropics/skills
Vercel React Best Practicesvercel-labs/agent-skills
Remotion Best Practicesremotion-dev/skills
Vercel Composition Patternsvercel-labs/agent-skills
Develop Userscriptsxixu-me/skills
Next Best Practicesvercel-labs/next-skills
Journey fit
Common Questions / FAQ
Is Building Components safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Building Components
# Building Components ## When to use this skill Use when the user is: - Building new UI components (primitives, components, blocks, templates) - Implementing accessibility features (ARIA, keyboard navigation, focus management) - Creating composable component APIs (slots, render props, controlled/uncontrolled state) - Setting up design tokens and theming systems - Publishing components to npm or a registry - Writing component documentation - Implementing polymorphism or as-child patterns - Working with data attributes for styling/state ## References - [definitions.mdx](./references/definitions.mdx) - Artifact taxonomy (primitives, components, blocks, templates) - [principles.mdx](./references/principles.mdx) - Core principles for component design - [accessibility.mdx](./references/accessibility.mdx) - ARIA, keyboard navigation, WCAG compliance - [composition.mdx](./references/composition.mdx) - Composable component patterns - [as-child.mdx](./references/as-child.mdx) - The as-child pattern for element polymorphism - [polymorphism.mdx](./references/polymorphism.mdx) - Polymorphic component patterns - [types.mdx](./references/types.mdx) - TypeScript typing patterns for components - [state.mdx](./references/state.mdx) - Controlled vs uncontrolled state management - [data-attributes.mdx](./references/data-attributes.mdx) - Using data attributes for styling and state - [design-tokens.mdx](./references/design-tokens.mdx) - Design token systems and theming - [styling.mdx](./references/styling.mdx) - Component styling approaches - [registry.mdx](./references/registry.mdx) - shadcn-style registry distribution - [npm.mdx](./references/npm.mdx) - Publishing components to npm - [marketplaces.mdx](./references/marketplaces.mdx) - Component marketplace distribution - [docs.mdx](./references/docs.mdx) - Writing component documentation --- title: Polymorphism description: How to use the `as` prop to change the rendered HTML element while preserving component functionality. type: reference summary: The as prop pattern for polymorphic components, compared with Radix UI's Slot-based asChild approach with TypeScript best practices. prerequisites: - /composition - /types related: - /as-child - /accessibility --- The `as` prop is a fundamental pattern in modern React component libraries that allows you to change the underlying HTML element or component that gets rendered. Popularized by libraries like [Styled Components](https://styled-components.com/), [Emotion](https://emotion.sh/), and [Chakra UI](https://chakra-ui.com/), this pattern provides flexibility in choosing semantic HTML while maintaining component styling and behavior. The `as` prop enables polymorphic components - components that can render as different element types while preserving their core functionality: ```tsx <Button as="a" href="/home"> Go Home </Button> <Button as="button" type="submit"> Submit Form </Button> <Button as="div" role="button" tabIndex={0}> Custom Element </Button> ``` ## Understanding `as` The `as` prop allows you to override the default element type of a component. Instead of being locked into a specific HTML element, you can adapt the component to render as any valid HTML tag or even another React component. For example: ```tsx // Default renders as a div <Box>Content</Box> // Renders as a section <Box as="section">Content</Box> // Renders as a nav <Box as="nav">Content</Box> ``` This renders different HTML elements: ```html <!-- Default --> <div>Content</div> <!-- With as="section" --> <section>Content</section> <!-- With as="nav" --> <nav>Content</nav> ``` ## Implementation Methods There are two main approaches to implementing pol