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

useflex

v3.0.0

Published

Flex layout in react using react components.

Downloads

27

Readme

useflex

Useflex allows you to make flex layout using React components. You don't need to create any styles, just install 'useflex' library and start using flex layout. But if you need some additional styles which are not related to flex you can use style prop with regular js object. All properties and how to use them you can find below.

NPM JavaScript Style Guide

Install

npm install --save useflex

Usage

Simple usage useflex library just import two components Container and Item.

import React, { Component } from 'react';

import { Container, Item } from 'useflex';

class Example extends Component {
  render () {
    return (
      <Container direction='column' justifyContent='space-between' height='200px' width='200px' >
        <Item>
          ...
        </Item>
         
        <Item>
          ...
        </Item>
        <Item>
          ...
        </Item>
      </Container>
    )
  }
}

By default Container is 'div' element, but you can specify whatever element type you want. Just set 'type' prop to Container component with a name of an element.


import React, { Component } from 'react';

import { Container, Item } from 'useflex';

class Example extends Component {
  render () {
    return (
      <Container type='form' >
        ...
      </Container>
    )
  }
}

Useflex allows you to make inner flex containers as well.


import React, { Component } from 'react';

import { Container, Item } from 'useflex';

class Example extends Component {
  render () {
    return (
      <Container type='form' >
        <Item>
          ...
        </Item>
          <Container>
            <Item>
            ...
          </Item>
          <Item>
            ...
          </Item>
        </Container>
      </Container>
    )
  }
}

You are allowed to create Items by specifying certain element name as well. In the example below you will see a flex container with one flex item, which is 'h1' element with 'Useflex' text.


import React, { Component } from 'react';

import { Container, Item } from 'useflex';

class Example extends Component {
  render () {
    return (
      <Container type='form' >
        <Item type='h1'>Useflex</Item>
      </Container>
    )
  }

Container props

  • direction - Direction of a flex container. If not specified - 'row'.
  • width | height - Size of a flex container.
  • justifyContent - Like 'justify-content' in css. If not specified - 'flex-start'.
  • alignItems - Like 'align-items' in css. If not specified - 'flex-start'.
  • flexBasis | flexShrink | flexGrow | flex - Like 'flex-basis | flex-shrink | flex-grow | flex' in css.
  • alignSelf - Like 'align-self' in css.
  • type - Element's name of a flex container. If not specified - 'div'.
  • flexWrap - Like 'flex-wrap in css. If not specefied - 'nowrap'.
  • flexFlow - Like 'flex-flow' in css. If not specefied - 'row nowrap'.
  • className - For specifying class names.
  • style - JS object with styles.

Item props

  • width | height - Size of a flex style.
  • flexBasis | flexShrink | flexGrow | flex - Like 'flex-basis | flex-shrink | flex-grow | flex' in css.
  • alignSelf - Like 'align-self' in css.
  • type - Element's name of a flex item. If not specified you have to provide element inside Item or you'll get an error.
  • order - Like 'order' in css. If not specefied - 0.
  • className - For specifying class names.
  • style - JS object with styles.

Authors

  • Anton Kalkou

License

MIT ©