Skip to content

Instantly share code, notes, and snippets.

@LekoArts
Created January 15, 2021 23:40
Show Gist options
  • Save LekoArts/d31103c960078473eebfa5ad0b6cddf1 to your computer and use it in GitHub Desktop.
Save LekoArts/d31103c960078473eebfa5ad0b6cddf1 to your computer and use it in GitHub Desktop.
Chakra UI TypeScript "Spacer" component
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