Box

If you're looking for a flexible component to help with low-level layout needs, the Box component might be just what you need. With its customizable styles and props, it can be used to create a wide range of UI elements, from simple containers to complex layout structures.
Themed
Unstyled
This is an illustration of a Themed Box component with default configuration.
<Box bg="$primary500" p="$5">
<Text color="white">This is the Box</Text>
</Box>

Import

To use this component in your project, include the following import statement in your file.
import { Box } from "@gluestack-ui/themed"

Anatomy

The structure provided below can help you identify and understand a Box component's various parts.
export default () => <Box />

Component Props

This section provides a comprehensive reference list for the component props, detailing descriptions, properties, types, and default behavior for easy project integration.

Box

It inherits all the properties of React Native's View component.

Themed

The themed version of the component is a pre-styled version of the component, which allows you to quickly integrate the component into your project. The component's design and functionality are fully defined, allowing you to focus on the more important aspects of your project. To know more about Themed Library please visit this link.

Examples

The Examples section provides visual representations of the different variants of the component, allowing you to quickly and easily determine which one best fits your needs. Simply copy the code and integrate it into your project.

Box with ref

A Box component with a ref property enables the direct reference and manipulation of the underlying DOM element, offering greater control and flexibility in modifying the box's appearance and behavior within a user interface.
function App() {
const myRef = useRef({})
useEffect(() => {
const styleObj = {
borderWidth: 2,
borderRadius: 4,
borderColor: "#1A91FF",
}
if (myRef.current && myRef.current.setNativeProps) {
myRef.current.setNativeProps({
style: styleObj,
})
}
}, [myRef])
return <Box h={100} w={100} bg="$primary100" ref={myRef} />
}

Unstyled

All the components in gluestack-ui are unstyled by default. To customize your UI using the extendedTheme, please refer to this link. The import names of components serve as keys to customize each component.
Edit this page on GitHub