Box | NativeBase | Universal Components for React and React Native

Search
K
Hire us
Data Display
Typography
Disclosure
Media and Icons
Others
If you are starting a new project, please try gluestack-ui for better performance and new design.
Box
This is a generic component for low level layout needs. It is similar to a in HTML.
Show Code
This is a Box
Playground
Example
Basic
This is a Box
Playground

Composition
image
PHOTOS
The Garden City
The Silicon Valley of India.
Bengaluru (also called Bangalore) is the center of India's high-tech industry. The city is also known for its parks and nightlife.
6 mins ago
Playground

With Linear gradient
If you're using managed or bare workflow, you can install and configure it in the as shown below.
This is a Box with Linear Gradient
Playground

If you're not using Expo, you can install and configure in the as shown below.
Copy
import React from 'react';
import { Box, NativeBaseProvider } from 'native-base';
const App = () => {
return (
<Box
bg={{
linearGradient: {
colors: ['lightBlue.300', 'violet.800'],
start: [0, 0],
end: [1, 0],
},
}}
p="12"
rounded="lg"
_text={{ fontSize: 'md', fontWeight: 'bold', color: 'white' }}
>
This is a Box with Linear Gradient
</Box>
);
};
const config = {
dependencies: {
'linear-gradient': require('react-native-linear-gradient').default,
},
};
export default () => {
return (
<NativeBaseProvider config={config}>
<App />
</NativeBaseProvider>
);
};

Basic (With Ref)
This is a Box
Playground


Tip: Common use cases for Box component are:
Create responsive layouts with ease.
Provide a shorthand to pass styles via props (bg instead of backgroundColor).
Props
children
Renders components as Box children. Accepts a JSX.Element or an array of JSX.Element.
Type: any
_text
For providing props to Text inside Box
Type: Partial<ITextProps>
bg
Type: ResponsiveValue<|>
background
Type: ResponsiveValue<|>
bgColor
Type: ResponsiveValue<|>
backgroundColor
Type: ResponsiveValue<|>
Nativebase logo
MadeWithNativeBase
Gluestack logo
gluestack-ui