---
title: VStack | UI
description: A VStack component is used to create a horizontal stack layout for child components.
pageTitle: VStack
pageDescription: A VStack component is used to create a horizontal stack layout for child components.
showHeader: true
---

import { Meta } from '@storybook/addon-docs';

<Meta title="components/Layout/VStack" />

import { VStack, Box } from './VStack';
import { transformedCode } from '../../../utils';
import {
  AppProvider,
  CodePreview,
  Table,
  Text,
  InlineCode,
} from '@gluestack/design-system';

import { styled } from '@dank-style/react';

import Wrapper from '../../Wrapper';

# Installation

This command copies the `VStack` component to your project.

```jsx
npx install @gluestack-ui add vstack
```

## Import

```jsx
// import the component from your component folder
import { VStack } from 'components';
```

<br />

# Basic

<AppProvider>
  <CodePreview
    showComponentRenderer={true}
    showArgsController={false}
    metaData={{
      code: `
<VStack space="md">
  <Box sx={{ w: 100, h: 100, bg: '$blue300' }} />
  <Box sx={{ w: 100, h: 100, bg: '$blue400' }} />
  <Box sx={{ w: 100, h: 100, bg: '$blue500' }} />
</VStack>
`,
      transformCode: (code) => {
        return transformedCode(code);
      },
      scope: {
        Wrapper,
        VStack,
        Box,
      },
      argsType: {},
    }}
  />
</AppProvider>
<br />

## Anatomy

The VStack component consists of the following parts:

```jsx
export default () => (
  <VStack>
    <Box>Box</Box>
    <Box>Box</Box>
  </VStack>
);
```

## API Reference

### VStack

It inherits all the properties of React Native's [View](https://reactnative.dev/docs/view#props) component.

<AppProvider>
  <Table>
    <Table.THead>
      <Table.TR>
        <Table.TH>
          <Table.TText>Prop</Table.TText>
        </Table.TH>
        <Table.TH>
          <Table.TText>Type</Table.TText>
        </Table.TH>
        <Table.TH>
          <Table.TText>Default</Table.TText>
        </Table.TH>
        <Table.TH>
          <Table.TText>Description</Table.TText>
        </Table.TH>
      </Table.TR>
    </Table.THead>
    <Table.TBody>
      <Table.TR>
        <Table.TD>
          <Table.TText>
            <InlineCode>space</InlineCode>
          </Table.TText>
        </Table.TD>
        <Table.TD>
          <Table.TText>{`number | string | undefined`}</Table.TText>
        </Table.TD>
        <Table.TD>
          <Table.TText>-</Table.TText>
        </Table.TD>
        <Table.TD>
          <Table.TText>{`It sets the space between children.`}</Table.TText>
        </Table.TD>
      </Table.TR>
    </Table.TBody>
  </Table>
</AppProvider>

<br />
<br />

## Examples

### VStack Reversed

<AppProvider>
  <CodePreview
    showComponentRenderer={true}
    showArgsController={false}
    metaData={{
      code: `
<VStack space="md" reversed>
  <Box sx={{ w: 100, h: 100, bg: '$blue300' }} />
  <Box sx={{ w: 100, h: 100, bg: '$blue400' }} />
  <Box sx={{ w: 100, h: 100, bg: '$blue500' }} />
</VStack>
`,
      transformCode: (code) => {
        return transformedCode(code);
      },
      scope: { Box, Wrapper, VStack },
      argsType: {},
    }}
  />
</AppProvider>

<br />

# Advanced

## Customizing the VStack

We have a function called `createVStack` which can be used to create a custom VStack component. This function takes in a configuration object which contains the styled components that you want to use for the VStack. You can refer [dank.style](https://dank.style/) for more information on how to use styled components.

### Usage

```jsx
// import the styles
import { Root, Spacer } from '../components/vstack/styled-components';

// import the createVStack function
import { createVStack } from '@gluestack-ui/vstack';

// Understanding the API
const VStack = createVStack({
  Root,
  Spacer,
});

// Using the vstack component
export default () => <VStack />;
```

Default styling of the component can be found in the `components/vstack` file. For reference, you can view the [source code](https://github.com/gluestack/gluestack-ui/blob/development/example/storybook/src/ui-components/VStack/index.tsx) of the styled `VStack` component.
