---
title: Center | UI
description: This is a generic component for low level layout needs to center its children
pageTitle: Center
pageDescription: This is a generic component for low level layout needs to center its children.
showHeader: true
---

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

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

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

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

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

# Installation

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

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

## Import

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

<br />

# Basic

<AppProvider>
  <CodePreview
    showComponentRenderer={true}
    showArgsController={false}
    metaData={{
      code: `
<Center bg="$primary500" h={200} w={300}>
  <Text color="white" fontWeight="bold">
    This is the center.
  </Text>
</Center>
`,
      transformCode: (code) => {
        return transformedCode(code);
      },
      scope: {
        Wrapper,
        Center,
        Text,
      },
      argsType: {},
    }}
  />
</AppProvider>
<br />

## Anatomy

The center component consists of the following parts:

```jsx
export default () => (
  <Center>
    <Text>Center</Text>
  </Center>
);
```

## API Reference

### Center

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

<br />
<br />

<br />

# Advanced

## Customizing the Center

For customizing the Center, you have to map styled view to Center. You can refer [dank.style](https://dank.style/) for more information on how to use styled components.

### Usage

```jsx
// import the styles
import { Root } from '../components/core/center/styled-components';

// mapping the Center to root component
const Center = Root;

// Using the Center component
export default () => (
  <Center>
    <Text />
  </Center>
);
```

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