Layout

OverviewExamplesPropertiesSlotsCSS PropertiesDependenciesUsageIntegration

Layout component is used to create the main layout of an app. Layout currently comes with one main configuration: two-column.

Properties

PropertyAttribute Description TypeDefault
navOpennav-openControls whether the navigation is hidden off-screen or not. Defaults to `true` for wide viewports, and `false` otherwise.boolean
persistNavStatepersist-nav-stateControls whether the navigation's open/closed state is persisted across page loads. This is useful for multi-page apps, where clicks on links trigger a full page load.booleanfalse
syncNavStatesync-nav-stateControls whether the navigation's open/closed state and width is synced across tabs/windows on the same origin. This is useful for long-lived app sessions where you may have multiple tabs/windows open at once.booleanfalse
paddingpaddingControls the padding of the default main section slot. When set to “none”, the nav and header slots will still have padding.'m' | 'none''m'
stickystickyControls whether the layout's header has sticky positioning.booleanfalse
stickyFootersticky-footerControls whether the layout's footer has sticky positioning.booleanfalse

Slots

Slot name Description
Default slotThe default main section content.
navUsed to place content inside the navigation sidebar.
top-barUsed to place the [Top Bar](../top-bar/) component.
headerUsed to place content inside the header section. This slot can be made sticky by utilizing the `sticky` property on the layout component.
footerUsed to place content inside the footer section. This slot can be made sticky by utilizing the `stickyFooter` property on the layout component.
drawerUsed to place additional content/details relating to a selected item.
nav-toggleUsed to place a own nav-toggle component, for cases where you might need to add a tooltip.

CSS Properties

CSS Custom Properties provide more fine grain control over component presentation. We advise utilizing existing properties on the component before using these.

PropertyDescriptionDefault
--n-layout-paddingControls the padding around the main layout area (the main slot), using our spacing tokens.var(--n-space-l)
--n-layout-drawer-inline-sizeControls the width of the drawer area, when used.320px
--n-layout-background-colorControls the background color of the layout, using color tokens.var(--n-color-background)

Usage

This section includes guidelines for designers and developers about the usage of this component in different contexts.

Do

  • To visually group content in a layout section, use the Card component.
  • To lay out a set of smaller components, use the Stack component.

Don’t

  • Never put layout component inside another HTML landmark.
  • Don’t use when you need a vertical or horizontal layout system. Use Stack component instead.

Additional considerations

  • Layout component uses <main> element internally which is an HTML sectioning element which by default defines an ARIA landmark role. For that reason you should never put layout component inside another HTML landmark.

Theming

Please see the Accent color and Top Bar theming sections in our theming documentation for detailed guidelines.

Theming Guidelines

Integration

For integration guidelines, please see Web Components documentation .

Was this page helpful?

Yes No

We use this feedback to improve our documentation.