reactnatively

Box

The universal layout primitive. Express spacing, sizing, flex, and position constraints directly as props — eliminating most StyleSheet boilerplate for structural layout.

Import

typescript
import { Box } from 'reactnatively';

Hero section layout

HeroSection.tsx
1import { Box, Heading, Text, Button } from 'reactnatively';23export function HeroSection() {4  return (5    <Box flex={1} justify="center" align="center" px={24} py={48}>6      <Box7        bg="rgba(139,92,246,0.15)"8        borderRadius={16}9        px={12}10        py={6}11        mb={20}12      >13        <Text variant="xs" color="#a78bfa" weight="semibold">14          New in 2.015        </Text>16      </Box>1718      <Heading level="h1" align="center" style={{ marginBottom: 16 }}>19        Build faster with Glass20      </Heading>2122      <Text variant="lg" align="center" color="rgba(255,255,255,0.5)" style={{ marginBottom: 32 }}>23        Production-ready components for React Native and Expo24      </Text>2526      <Box direction="row" gap={12}>27        <Button variant="solid" color="primary" size="lg">Get Started</Button>28        <Button variant="glass" size="lg">View Docs</Button>29      </Box>30    </Box>31  );32}

Card with absolute badge

NotificationCard.tsx
1import { Box, Text, Heading } from 'reactnatively';23export function NotificationCard({ unread, title, body }) {4  return (5    <Box6      bg="rgba(255,255,255,0.05)"7      borderRadius={16}8      p={20}9      mb={12}10      position="relative"11      overflow="hidden"12    >13      {unread && (14        <Box15          position="absolute"16          top={16}17          right={16}18          width={8}19          height={8}20          borderRadius={4}21          bg="#6366f1"22        />23      )}24      <Heading level="h5" style={{ marginBottom: 6 }}>{title}</Heading>25      <Text variant="sm" color="rgba(255,255,255,0.5)" numberOfLines={2}>26        {body}27      </Text>28    </Box>29  );30}

Props

PropTypeDefaultDescription
p / px / py / pt / pb / pl / prSpacingKey | numberundefinedPadding shorthand props. SpacingKey maps to theme spacing tokens.
m / mx / my / mt / mb / ml / mrSpacingKey | numberundefinedMargin shorthand props.
flexnumberundefinedFlex grow/shrink factor.
directionFlexDirectionundefinedFlex direction (row, column, etc.).
alignFlexAlignundefinedalignItems value.
justifyFlexJustifyundefinedjustifyContent value.
wrapFlexWrapundefinedflexWrap value.
gapSpacingKey | numberundefinedGap between flex children.
width / heightnumber | stringundefinedExplicit dimensions.
minWidth / maxWidth / minHeight / maxHeightnumber | stringundefinedSize constraints.
bgstringundefinedBackground color.
borderRadiusRadiiKey | numberundefinedCorner radius using a theme token or pixel value.
overflow'visible' | 'hidden' | 'scroll'undefinedOverflow behaviour.
opacitynumberundefinedOpacity (0–1).
position'relative' | 'absolute'undefinedCSS-style position.
top / right / bottom / left / zIndexnumberundefinedPosition offset and z-index.
styleStyleProp<ViewStyle>undefinedEscape hatch for arbitrary styles.
childrenReactNodeundefinedContent rendered inside the box.