npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

simple-flexbox

v2.3.3

Published

A simple way to make responsive layouts using Flexbox in React

Downloads

2,480

Readme

Simple Flexbox

A simple way to make responsive layouts using Flexbox in React. Typescript supported.

Installation

npm install simple-flexbox or yarn add simple-flexbox

Examples

Look at a real UI created with simple-flexbox here: https://llorentegerman.github.io/react-admin-dashboard/ and read the code here: https://github.com/llorentegerman/react-admin-dashboard.

See examples in codesandbox.

There are two main components, Column and Row.

<Row vertical='center' horizontal='spaced'>
	<Column vertical='end'>
    	<span> Content 1 </span>
        <span> Content 2 </span>
    </Column>
    <Column>
    	<span> Content 3 </span>
        <span> Content 4 </span>
        <span> Content 5 </span>
    </Column>
</Row>

Edit simple-flexbox examples

Row props

|property|accepted values|description| | --------- | ----------- | ----------- | |reverse| true or false | | |vertical| 'start', 'center', 'end', 'stretch', 'baseline' | at rows, vertical and alignItems are the same | |horizontal|'start', 'flex-start', 'center', 'end', 'flex-end', 'spaced', 'space-between', 'around', 'space-around', 'space-evenly'| at rows, horizontal and justifyContent are the same| |justifyContent|'start', 'flex-start', 'center', 'end', 'flex-end', 'spaced', 'space-between', 'around', 'space-around', 'space-evenly'| at rows, horizontal and justifyContent are the same| |alignItems|'start', 'center', 'end', 'stretch', 'baseline' | at rows, vertical and alignItems are the same | |alignSelf|'start', 'center', 'end', 'stretch', 'baseline' | other alignment for the cross (vertical) axis | |alignContent|'start', 'flex-start', 'center', 'end', 'flex-end', 'spaced', 'space-between', 'around', 'space-around', 'stretch'| other alignment for the cross (vertical) axis | |flex| string| shorthand for grow, shrink and basis | |flexGrow| number| flex-grow | |flexShrink| number| flex-shrink | |flexBasis| string| flex-basis | |wrap| true or false| default: false | |wrapReverse| true or false| default: false | |any other property| any | i.e.: style={{bakcgroundColor: 'red'}}| |breakpoints|array of objects| different styles are applied depending on window.innerWidth, see Breakpoints section below | |element | 'article', 'aside', 'div', 'figure', 'footer', 'form', 'header', 'main', 'nav', 'section' | Defines to which html tag the styles will be applied. Default: div | |componentRef| createRef() or callback ref| reference | |children| | required |

Column props

|property|accepted values|description| | --------- | ----------- | ----------- | |reverse| true or false | | |horizontal| 'start', 'center', 'end', 'stretch', 'baseline' | at column, horizontal and alignItems are the same | |vertical|'start', 'flex-start', 'center', 'end', 'flex-end', 'spaced', 'space-between', 'around', 'space-around', 'space-evenly'| at column, vertical and justifyContent are the same| |justifyContent|'start', 'flex-start', 'center', 'end', 'flex-end', 'spaced', 'space-between', 'around', 'space-around', 'space-evenly'| at column, vertical and justifyContent are the same| |alignItems|'start', 'center', 'end', 'stretch', 'baseline' | at column, horizontal and alignItems are the same | |alignSelf|'start', 'center', 'end', 'stretch', 'baseline' | other alignment for the cross (horizontal) axis | |alignContent|'start', 'flex-start', 'center', 'end', 'flex-end', 'spaced', 'space-between', 'around', 'space-around', 'stretch'| other alignment for the cross (horizontal) axis | |flex| string| shorthand for grow, shrink and basis | |flexGrow| number| flex-grow | |flexShrink| number| flex-shrink | |flexBasis| string| flex-basis | |wrap| true or false| default: false | |wrapReverse| true or false| default: false | |any other property| any | i.e.: style={{bakcgroundColor: 'red'}}| |breakpoints|array of objects| different styles are applied depending on window.innerWidth, see Breakpoints section below | |element | 'article', 'aside', 'div', 'figure', 'footer', 'form', 'header', 'main', 'nav', 'section' | Defines to which html tag the styles will be applied. Default: div | |componentRef| createRef() or callback ref| reference | |children| | required |

Breakpoints

The breakpoints property allows you to apply styles depending on window.innerWidth.

You must indicate the maximum size for which the styles will be applied, that means that the styles will be applied as long as windows.width <= size, where size is a number. Breakpoints property must have this structure:

{
	size1: { styles1 },
	size2: { styles2 },
	...
	sizeN: { stylesN }
}

you can also use a flexDirection value such as column, column-reverse, row, row-reverse, or a className, in this case, the name of the class cannot be any of the 4 possible values of flexDirection, so, className cannot be any of these column, column-reverse, row or row-reverse.

{
	size1: 'flexDirection value, for example: column, column-reverse, row or row-reverse',
	size2: 'any className except column, column-reverse, row, row-reverse',
	...
	sizeN: 'column, column-reverse, row, row-reverse or className'
}

for example:

<Column breakpoints={{
	850: { flexDirection: 'row', backgroundColor: 'green' },
	600: 'row-reverse'
}}>
	<b>Hello</b>
    <span>world!</span>
</Column>

Breakpoints styles are applied cumulatively, for example, for the Column declared above, these will be the styles, depending on window.innerWidth:

window.innerWidth > 850 --> styles = {}

600 < window.innerWidth <= 850 --> styles = { flexDirection: 'row', backgroundColor: 'green' }

window.innerWidth <= 600 --> styles = { flexDirection: 'row-reverse', backgroundColor: 'green' }

You can see this breakpoints examples in codesandbox.

License

This software is released under the MIT License.

Author

me

Germán Llorente