Stack
Children in a column.
Import
import { Stack } from '@nizivo/react/stack';
// Once per app (Getting started), after
// @nizivo/tokens/tokens.css and @nizivo/react/css/base.css
import '@nizivo/react/css/stack.css';Static or interactive
Server. It ships no client JavaScript when a Server Component renders it, in every Next.js build
mode; its code is bundled only when a client component (a 'use client' file) imports it. How to
choose.
In a client app (a Vite or React Router single-page app, or a 'use client' file) it is an ordinary React component: event handlers, refs and state work as usual. In a client app.
Examples
Basic
- Stoneware mug
- Linen napkins
import type { JSX } from 'react';
import { Stack } from '@nizivo/react/stack';
export function StackExample(): JSX.Element {
return (
<Stack gap="4">
<div>Order #1040</div>
<div>Paid</div>
<Stack gap="2" render={<ul />}>
<li>Stoneware mug</li>
<li>Linen napkins</li>
</Stack>
</Stack>
);
}
Props
Children in a column.
Server component Renders data-slot="stack" with the class nz-stack. Props: StackProps. Source: src/stack/stack.tsx.
| Name | Type | Default | Description |
|---|---|---|---|
gap | LayoutGap"0""0-5""1""1-5""2""3""4""5""6""8""10""12""16""20""24" | – | Space between children. Absent, there is none. |
render | RenderProp<StackState> | – | Another element, for example |
- Also takes every attribute of
<div>. (ComponentPropsWithRef<"div">)
render takes an element, or, in client code, a function of the props and this state (StackState):
| Name | Type | Default | Description |
|---|---|---|---|
gaprequired | LayoutGap | undefined"0""0-5""1""1-5""2""3""4""5""6""8""10""12""16""20""24" | – |
Other exports
LayoutGaptypeimport type { LayoutGap } from '@nizivo/react/stack'A
--nz-space-*key:'4'is--nz-space-4(1rem),'0-5'is--nz-space-0-5. Token keys only.type LayoutGap = "0" | "0-5" | "1" | "1-5" | "2" | "3" | "4" | "5" | "6" | "8" | "10" | "12" | "16" | "20" | "24"StackPropstypeimport type { StackProps } from '@nizivo/react/stack'The props of
Stack, listed above.StackStatetypeimport type { StackState } from '@nizivo/react/stack'The render state of
Stack, listed above.
Data attributes and slots
Style parts by class (.nz-<slot>) and state by data attribute. Attribute meanings come from contracts/vocabulary.json.
| Slot | Rendered by | Data attributes |
|---|---|---|
stack.nz-stack | Stackroot (takes render) |
|
CSS hooks
Set a hook on the component's class or any ancestor to restyle it without specificity games; leave it unset for the default shown.
| Hook | Default | Read as |
|---|---|---|
--nz-stack-gap |
|
|
Layers: nz.components. Classes: .nz-stack.
Tokens this stylesheet reads (15)
--nz-space-0, --nz-space-0-5, --nz-space-1, --nz-space-1-5, --nz-space-10, --nz-space-12, --nz-space-16, --nz-space-2, --nz-space-20, --nz-space-24, --nz-space-3, --nz-space-4, --nz-space-5, --nz-space-6, --nz-space-8
Accessibility
Nothing in this component takes focus or keyboard input.
Keyboard
None.
Figma
Node ids from design/component-map.json, which nz gen writes from component.json. The links open the Nizivo Figma library, which may ask you to sign in.
- Canonical: none
- Ghost masters: none
Split
A main column and an aside, side by side while there is room and stacked below that, by the Split's own width, with no breakpoint and no script.
StickyBar
A bar of actions that sticks to the bottom of the viewport while its section scrolls, above the device's home indicator and the shell's bottom tab bar.