Skip to main content
On this page

Center

A layout component that centers its children both horizontally and vertically.

import { Center } from "@ninna-ui/layout";

pnpm add @ninna-ui/layout@latest
Includes @ninna-ui/core. CSS setup required.View source

Usage

Import and use the Center component.

import { Center } from "@ninna-ui/layout";
export default function Example() {
return (
<Center className="h-screen">
<Spinner />
</Center>
);
}

Basic

Center content in a container.

Live preview
Centered Content

Inline

Use inline-flex for inline centering.

Live preview

inline=false (default)

Centered

Takes full width

inline=true

🎯

Shrinks to content

Use Cases

Common patterns using Center.

Live preview

Loading State

Loading...

Empty State

📭

No items found

Icon Button

+

Hero Section

Welcome

Centered hero content

API Reference

Complete list of props.

Props

PropTypeDefaultDescription
asElementType—Semantic HTML element to render
inlinebooleanfalseUse inline-flex instead of flex
classNamestring—Additional CSS classes
childrenReact.ReactNode—Content to center

Accessibility

  • Center is a pure layout component with no semantic meaning
  • Useful for loading states, empty states, and hero sections
  • Ensure centered content remains accessible at all viewport sizes