Skip to content

bendman/typescript-polymorphic-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Typescript Polymorphic Examples

View on CodeSandbox

Example of a typescript project with polymorphic components using an as prop.

Meaning, you can do something like this:

<Box as="h1">Examples</Box>

<Box title="sometitle">Default div only allows basic div stuff</Box>

<Box as="blockquote" cite="me">
  A blockquote, where the "cite" prop is allowed.
</Box>

// Even custom components and their props should work
<Box as={Hello} name="me"/>

About

Solutions for strongly-typed polymorphic (as={X}) components in typescript and react.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published