Created
July 15, 2019 07:13
-
-
Save ryanditjia/b2ee5ba40bca8d653373657aaaebad3d to your computer and use it in GitHub Desktop.
Dynamic tagname React
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react' | |
| type Props = React.HTMLAttributes<HTMLElement> & { | |
| as?: 'div' | 'article' | 'section' | |
| } | |
| export const Card: React.FC<Props> = ({ | |
| children, | |
| as: Component = 'div', | |
| className, | |
| ...restProps | |
| }) => { | |
| return ( | |
| <Component | |
| className={className + ' bg-white p-4 rounded-lg shadow'} | |
| {...restProps} | |
| > | |
| {children} | |
| </Component> | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment