react-native-constraint-layout

1.0.5 • Public • Published

React Native Constraint Layout

Example Usage

import {
  ConstraintSystem,
  ConstraintSystemView,
  Pin,
} from "react-native-constraint-layout";
 
const App = () => (
  <ConstraintSystem
    style={{
      width: 300,
      height: 300,
    }}
  >
    <ConstraintSystemView
      label="hello"
      // centered in parent
      constraints={[
        { pin: Pin.top, target: "parent" },
        { pin: Pin.bottom, target: "parent" },
        { pin: Pin.left, target: "parent" },
        { pin: Pin.right, target: "parent" },
      ]}
      style={{
        width: 100,
      }}
    >
      <Text
        style={{
          textAlign: "center",
        }}
      >
        Hello
      </Text>
    </ConstraintSystemView>
    <ConstraintSystemView
      label="world"
      // pin to bottom of "hello"
      // centered horizontally in parent
      constraints={[
        { pin: Pin.bottom, target: "hello", value: 0 },
        { pin: Pin.left, target: "parent" },
        { pin: Pin.right, target: "parent" },
      ]}
      style={{
        width: 100,
      }}
    >
      <Text
        style={{
          textAlign: "center",
        }}
      >
        Constraint-World!
      </Text>
    </ConstraintSystemView>
  </ConstraintSystem>
);

Readme

Keywords

none

Package Sidebar

Install

npm i react-native-constraint-layout

Weekly Downloads

1

Version

1.0.5

License

ISC

Unpacked Size

13.8 kB

Total Files

9

Last publish

Collaborators

  • twalk4821