Layout
Center
Centra contenido en ambos ejes, con espaciado opcional entre los hijos.
Propósito
Center es un contenedor flex que centra a sus hijos en horizontal y en vertical por defecto: estados
vacíos, indicadores de carga, contenido destacado.
Importación
import { Center } from "@neshel-ui/layout";Uso
Vista previa: center-basic
No projects yet
Create your first project to get started.
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
| Prop | Tipo | Predeterminado | Descripción |
|---|---|---|---|
| align | Responsive<MainAxisAlign> | — | — |
| alignX | Responsive<MainAxisAlign> | — | — |
| alignY | Responsive<CrossAxisAlign> | — | — |
| as | LayoutElement | — | — |
| asChild | boolean | — | — |
| ref | Ref<HTMLElement> | — | — |
| space | Responsive<SpaceValue> | — | — |
| spaceX | Responsive<SpaceValue> | — | — |
| spaceY | Responsive<SpaceValue> | — | — |
También acepta las props de: React DOM attributes.
alignX / alignY sustituyen los valores predeterminados (center). El centrado vertical necesita
que el Center sea más alto que su contenido: dale una altura (min-h-*) o colócalo en un padre que se
estire.
Errores habituales
- Esperar centrado vertical en un Center de altura automática: no hay espacio libre que distribuir.
- Usar Center para centrar la columna de una página: eso es
Container.