Skip to content

Typescript React component to set flexbox properties on a element

Notifications You must be signed in to change notification settings

HMStitt/boxible

 
 

Repository files navigation

Build Status

make flexbox containers in typescript using emotion

Uses emotionjs to style a div using flexbox styles. React components can easily set any flexbox style using component properties. Typescript gives you nice code completion and type-safe validations.

Full docs are published at https://nathanstitt.github.io/boxible/

import { Box } from 'boxible'

<Box align="between" grow>
  <Box align="middle">Left</Box>
  <Box box direction="column>
    <Box align="end>Right Top</Box>
    <div>Right Middle Content</div>
    <div>Right Bottom</div>
  </Box>
</Box>
-----------------------------------
|                        Right Top |
|    Left     Right Middle Content |
|             Right Bottom         |
-----------------------------------

Since the Box element is a emotionjs component, you can also use the "as" prop to render elements other than div, such as label to wrap inputs.

<Box as="label">
   <input name="foo" />
   <b>Click to focus input</b>
</Box>
-----------
|         |  click to focus input
-----------

Credits

Boxible is based loosely on Grommt’s Box component, but re-written in Typescript and with a few differences, such as no animation support.

About

Typescript React component to set flexbox properties on a element

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 86.3%
  • JavaScript 11.5%
  • Shell 2.2%