Skip to Content
Neshel-UI
Layout

Center

Centre content on both axes, with optional spacing between children.

Purpose

Center is a flex container that centres its children horizontally and vertically by default — empty states, loading indicators, hero content.

Import

import.tsx
import { Center } from "@neshel-ui/layout";

Usage

Preview: center-basic
Preview theme

No projects yet

Create your first project to get started.

center-basic.tsx
import { Button } from "@neshel-ui/components";
import { Center, Stack } from "@neshel-ui/layout";
import { Heading, Paragraph } from "@neshel-ui/typography";

/** Centered content: an empty state centred on both axes inside a fixed-height region. */
export default function CenterBasic() {
  return (
    <Center className="min-h-56 rounded-lg border border-dashed border-[var(--neshel-border)]">
      <Stack space="3" alignX="center">
        <Heading as="h3" size="lg">
          No projects yet
        </Heading>
        <Paragraph tone="muted" size="sm">
          Create your first project to get started.
        </Paragraph>
        <Button size="sm">New project</Button>
      </Stack>
    </Center>
  );
}

API

CenterProps

CenterProps
PropTypeDefaultDescription
alignResponsive<MainAxisAlign>——
alignXResponsive<MainAxisAlign>——
alignYResponsive<CrossAxisAlign>——
asLayoutElement——
asChildboolean——
refRef<HTMLElement>——
spaceResponsive<SpaceValue>——
spaceXResponsive<SpaceValue>——
spaceYResponsive<SpaceValue>——

Also accepts the props of: React DOM attributes.

alignX / alignY override the defaults (center). Vertical centring needs the Center to be taller than its content — give it a height (min-h-*) or place it in a stretching parent.

Common mistakes

  • Expecting vertical centring in an auto-height Center: there is no free space to distribute.
  • Using Center to centre a page column: that is Container.
Edit on GitHub

On this page