HStack

HStack arranges its child elements horizontally, making it a suitable layout component for creating a row of items. It is worth noting that Row is just an alternative name for HStack.
Installation
API Reference
Spec Doc
This is an illustration of HStack component.
space
reversed
<HStack space="md" reversed={false}>
<Box w="$20" h="$20" bg="$primary300" />
<Box w="$20" h="$20" bg="$primary400" />
<Box w="$20" h="$20" bg="$primary500" />
</HStack>

Installation

Run the following command:

npx gluestack-ui add hstack

API Reference

To use this component in your project, include the following import statement in your file.
import { HStack } from "@/components/ui/hstack"
export default () => <HStack />

Component Props

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

HStack

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

Accessibility

The accessibility of a HStack is primarily determined by the accessibility information of the components it contains. When you pass an accessible component inside a HStack, its accessibility attributes, such as labels and hints, will be utilized by assistive technologies like screen readers.

Props

HStack component is created using View component from react-native. It extends all the props supported by React Native View, utility props and the props mentioned below.
Prop
Type
Default
Description
space
string
-
It sets the space between children.
reversed
boolean
-
When true, it places the HStack items in reverse direction.

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.

HStack Reversed

An HStack component with the reversed prop reverses the order of horizontally stacked elements, allowing for customized layouts and visual arrangements of content within a user interface.
<HStack space="md" reversed>
<Box w="$20" h="$20" bg="$primary200" />
<Box w="$20" h="$20" bg="$primary400" />
<Box w="$20" h="$20" bg="$primary600" />
</HStack>
Edit this page on GitHub