Skip to content

Instantly share code, notes, and snippets.

@robphoenix
Created December 9, 2019 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robphoenix/1303fd329804123117e1b8b7e20eb1c6 to your computer and use it in GitHub Desktop.
Save robphoenix/1303fd329804123117e1b8b7e20eb1c6 to your computer and use it in GitHub Desktop.
react flexbox component with as prop
/** @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