0.1.1 • Published 3 years ago

reactjs-layouts v0.1.1

Weekly downloads
57
License
-
Repository
github
Last release
3 years ago

Layouts

This project is an implementation of css Flexbox & Grid for React library

Install

// npm
npm install reactjs-layouts

// yarn
yarn add reactjs-layouts

Get started

Layouts have three main components: Row, Col (Column) and Grid.

Note: react-layouts support type definitions

Row / Col

    import { Row, Col } from 'reactjs-layouts'

    const Component = ()=>{
        return (
            <>
                // control how elements are positioned horizontally
                <Row justifyContent="space-between"></Row>
                
                <Col></Col>
            </>
        )
    }
PropType
justifyContentstring
alignItemsstring
alignContentstring
wrapstring
inlineboolean
reverseboolean
alignSelfstring
gapstring
fluidstring

Grid

    import { Grid } from 'reactjs-layouts'

    const Component = ()=>{
        return (
            // Define the number & width of rows and columns
            <Grid templateRows="auto" templateCols="20vw 1fr"></Grid>
        )
    }
PropType
templateColsstring
templateRowsstring
templateAreasstring
colGapstring
rowGapstring
autoColsstring
autoRowsstring
justifyContentstring
alignItemsstring
alignContentstring
alignSelfstring
wrapstring
inlineboolean
reverseboolean
fluidstring

Content

As You can use any HTML element in the content you can also use predefined items which let you have more control over the element directly

import { Row } from 'reactjs-layouts'

const Component = ()=>{
    return (
        <Row>
            // Create div element
            // can't control directly
            <div></div>

            // Create a div item
            // you can use content props only
            <Row.item></Row.item>

            // Create a row item
            // you can use Row props + content props
            <Row.row></Row.row>

            // Create a Col item
            // you can use Column props + content props
            <Row.col></Row.col>

            // Create a grid item
            // you can use Grid props + content props
            <Row.grid></Row.grid>
        </Row>
    )
}

Row/Col Content Props

PropType
orderstring
growstring
shrinkstring
basisstring
alignSelfstring
    import { Grid } from 'reactjs-layouts'

    const Component = ()=>{
        return (
            <Grid>
                // Create div element, can't controls directly
                // can't control directly
                <div></div>
            
                // Create a div item
                // you can use content props only
                <Grid.item></Grid.item>
            
                // Create a row item 
                // you can use Row props + content props
                <Grid.row></Grid.row>
            
                // Create a column item
                // you can use Column props + content props
                <Grid.col></Grid.col>
            
                // Create a grid item 
                // you can use Grid props + content props
                <Grid.grid></Grid.grid>
            </Grid>
        )
    }

Grid Content Props

PropType
justifySelfstring
alignSelfstring
colStartstring
colEndboolean
rowStartboolean
rowEndstring
colstring
rowstring
areastring
fluidstring

License

svelte-layouts is MIT Licenced

Learn More

if you want to learn more about css flexbox and grid and how they works, you can feel free to check out these useful links: