npm.io
1.2.0 • Published 4 years ago

@s-ui/react-primitive-polymorphic-element

Licence
MIT
Version
1.2.0
Deps
0
Size
2 kB
Vulns
0
Weekly
0
Stars
147

PolymorphicElement

Render a basic polymorphic element capable of rendering a specified html tag or component when passed as a property.

Installation

$ npm install @s-ui/react-primitive-polymorphic-element

Usage

Basic usage
Import package and use the component
import PolymorphicElement from 'components/primitive/polymorphicElement/lib/index.js'

function Component() {}

return (
<>
  <PolymorphicElement as="div"/>
  <PolymorphicElement as="h1"/>
  <PolymorphicElement as={Component}/>
</>
)
Properties
Property Type Default Description
as string | function 'span' Render the passed value as the correspondent HTML tag or the component if a function is passed.

Find full description and more examples in the demo page.