Box
Box
is the most abstract component on top of which all other Pearl UI components are built. By default, it renders a React Native View element.
The Box component improves the development experience in the following ways:
- Create flexible layouts with ease.
- Provides an easier way to pass styles via props (
backgroundColor
can be passed as a prop instead of using React Stylesheet or inline styles). Shorthand props are also supported (bg
instead ofbackgroundColor
). - Create more complex components using
Box
as the base component, instead ofView
(All components in Pearl UI useBox
under the hood).
#
Importimport { Box } from "pearl-ui";
#
Usage<Box width="100%" height={200} backgroundColor="primary.500" marginBottom="m"> This is a box</Box>
#
Example#
Props#
Supported style propsThe Box
component supports the following style props:
- backgroundColor (Only
backgroundColor
props are supported, not thecolor
prop) - layout
- position
- opacity and visiblity
- margin and padding
- border
- shadow