polymorphic-component

Installation
SKILL.md

polymorphic-component

Implements the as prop pattern with full TypeScript safety — correct HTML prop inference per element, working ref types, and no prop leakage. Skips basics; addresses only the parts that cause real pain.


Phase 1 — Discover

Establish before writing anything:

  • Does the component need ref forwarding? (If yes, the generic chain is different — see Phase 3.)
  • Does the component have own props that may conflict with native HTML props? (e.g., a size prop clashing with <input size>)
  • What's the default element when as is omitted?
  • Should as accept custom components, or only HTML element strings? (Accepting both requires a union constraint.)

Phase 2 — The Core Type Problem (and why naive solutions fail)

Related skills

More from blunotech-dev/agents

Installs
1
GitHub Stars
2
First Seen
Apr 22, 2026