NbGrid is a flexible layout primitive built on CSS flexbox. A dir="row" grid arranges children horizontally; a dir="col" grid arranges them vertically. Nest them freely to build any layout.
The grid is configured at compile time via src/styles/variables/_grid.scss.
Breakpoints
All breakpoints are mobile-first (min-width). Base styles apply at all viewport sizes. A rule defined at md kicks in from 672px upward and stays active unless a wider breakpoint overrides it.
| Name | Min-width |
|---|---|
sm | 320px |
md | 672px |
lg | 1056px |
xl | 1312px |
xxl | 1584px |
How responsive props work
Most layout props (dir, gap, grid, justify, align, wrap, visible) accept three input forms:
1. Scalar — applies at all viewport sizes:
<nb-grid dir="col">...</nb-grid>2. Breakpoint map — different values per breakpoint. Rules cascade upward; only the breakpoints you define are set:
<!-- col until 672px, then row -->
<nb-grid :dir="{ sm: 'col', md: 'row' }">...</nb-grid>3. Function — called reactively at render time. Any reactive state accessed inside is tracked automatically:
<script setup lang="ts">
import { ref } from 'vue'
const isExpanded = ref(false)
</script>
<template>
<nb-grid :dir="() => (isExpanded ? 'col' : 'row')">...</nb-grid>
</template>TIP
The function form is for dynamic logic that does not map cleanly to breakpoints — for example, toggling layout based on component state. For viewport-driven changes, use the breakpoint map.
Props that accept responsive forms
| Prop | Scalar | Breakpoint map | Function |
|---|---|---|---|
dir | ✓ | ✓ | ✓ |
gap | ✓ | ✓ | ✓ |
grid | ✓ | ✓ | ✓ |
shift | ✓ | ✓ | ✓ |
justify | ✓ | ✓ | ✓ |
align | ✓ | ✓ | ✓ |
wrap | ✓ | ✓ | ✓ |
visible | ✓ | ✓ | ✓ |
first | ✓ | array form | - |
last | ✓ | array form | - |
reverse | ✓ | array form | - |
grow | ✓ | - | - |
flex | ✓ | - | - |
shrink | ✓ | - | - |
first, last, and reverse use an array of breakpoint names instead of an object: :first="['sm', 'md']".
Visual demo
Getting a ref
NbGrid exposes a getRef() method that returns the underlying DOM element.
<template>
<nb-grid ref="myGrid"> content </nb-grid>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const myGrid = ref()
console.log(myGrid.value.getRef()) // → HTMLElement
</script>