Created
December 9, 2019 10:30
-
-
Save robphoenix/1303fd329804123117e1b8b7e20eb1c6 to your computer and use it in GitHub Desktop.
react flexbox component with as prop
This file contains 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
/** @jsx jsx */ | |
import { jsx } from '@emotion/core' | |
import React from 'react' | |
const Flex: React.FC<{ | |
as?: React.ReactType | |
row?: boolean | |
column?: boolean | |
}> = ({ as: Component = `div`, row, column }) => { | |
const flexDirection = row ? 'row' : column ? 'column' : '' | |
return ( | |
<Component | |
css={{ | |
display: 'flex', | |
flexDirection, | |
}} | |
> | |
let's see | |
</Component> | |
) | |
} | |
export default Flex |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment