Created
January 15, 2021 23:40
-
-
Save LekoArts/d31103c960078473eebfa5ad0b6cddf1 to your computer and use it in GitHub Desktop.
Chakra UI TypeScript "Spacer" component
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 * as React from "react" | |
import { Box, BoxProps } from "@chakra-ui/react" | |
interface ISpacerProps extends BoxProps { | |
size: BoxProps["width"] | |
axis: "vertical" | "horizontal" | |
} | |
const Spacer = ({ size, axis, ...rest }: ISpacerProps) => { | |
const width = axis === `vertical` ? `1px` : size | |
const height = axis === `horizontal` ? `1px` : size | |
return <Box as="span" width={width} height={height} minWidth={width} minHeight={height} display="block" {...rest} /> | |
} | |
export default Spacer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment