1.0.0-beta.5 • Published 3 years ago

native-layout-stack v1.0.0-beta.5

Weekly downloads
114
License
MIT
Repository
github
Last release
3 years ago

native-layout-stack

NPM version NPM downloads NPM license run in expo snack Codecov Travis

About

SwiftUI like layout management for React Native

Idea

This library recreates SwiftUI components in React Native:

Stack

Spacer

Alternatives

How to Install

First, install the library in your project by npm:

$ npm install native-layout-stack

Or Yarn:

$ yarn add native-layout-stack

Getting Started

• Connect libary with project using ES6 import:

import { LayoutProvider, Stack, Spacer } from 'native-layout-stack'

Options

LayoutProvider

nametypedescription
paddingSpace or Space or Space, Space or Space, Space, Space or Space, Space, Space, SpaceOuter space
spacesSpaceSpace between children
omitNullbooleanSkip elements that are null or React.Fragment
arrayDivisionboolean
debugbooleanAdd random color to spaces

Stack

Stack extends ViewProps and implements all LayoutProvider props without debug

Spacer

Component uses ViewProps

Types

nametype
Spacenumber or string

Example

import { LayoutProvider, Stack, Spacer } from 'native-layout-stack'

const MyComponent = () => {
  return (
    <Stack padding={[20, 10]} spaces={20}>
      <View />
      <View />
      <View />
    </Stack>
  )
}

const App = () => {
  return (
    <LayoutProvider spaces={10} padding={20}>
      <MyComponent />
    </LayoutProvider>
  )
}

export default App

License

This project is licensed under the MIT License © 2020-present Jakub Biesiada