---
name: aksel-spacing
description: Responsive layout patterns using Aksel spacing tokens with Box, VStack, HStack, and HGrid
---
# Aksel Spacing Skill
This skill provides responsive layout patterns using Nav Aksel Design System spacing tokens.
## Critical Rule
**NEVER use Tailwind padding/margin utilities (`p-`, `m-`, `px-`, `py-`) with Aksel components.**
Always use Aksel spacing tokens: `space-4`, `space-6`, `space-8`, etc.
## Page Container Pattern
```typescript
import { Box, VStack } from '@navikt/ds-react';
export default function Page() {
return (
{/* Page content */}
);
}
```
## Card Pattern
```typescript
import { Box, VStack, Heading, BodyShort } from '@navikt/ds-react';
export function Card({ title, children }: { title: string; children: React.ReactNode }) {
return (
{title}
{children}
);
}
```
## Form Layout Pattern
```typescript
import { VStack, HStack, TextField, Button } from '@navikt/ds-react';
export function UserForm() {
return (
{/* Input fields with consistent vertical spacing */}
{/* Button group with horizontal spacing */}
);
}
```
## Dashboard Grid Pattern
```typescript
import { HGrid, Box, VStack, Heading } from '@navikt/ds-react';
export function Dashboard() {
return (
Dashboard
{/* Responsive grid: 1 col mobile, 2 tablet, 4 desktop */}
{/* Content area */}
{/* Content */}
);
}
```
## Two-Column Layout Pattern
```typescript
import { HGrid, Box, VStack } from '@navikt/ds-react';
export function TwoColumnLayout() {
return (
{/* Left column */}
{/* Left content */}
{/* Right column */}
{/* Right content */}
);
}
```
## Filter Section Pattern
```typescript
import { Box, VStack, HGrid, Select, TextField, Heading } from '@navikt/ds-react';
export function FilterSection() {
return (
Filters
{/* Responsive filter inputs */}
);
}
```
## Spacing Tokens Reference
```typescript
"space-0"; // 0px
"space-1"; // 4px
"space-2"; // 8px
"space-3"; // 12px
"space-4"; // 16px ← Form field gaps
"space-5"; // 20px
"space-6"; // 24px ← Card padding (mobile)
"space-8"; // 32px ← Card padding (desktop), section gaps
"space-10"; // 40px ← Page padding (desktop)
"space-12"; // 48px ← Page padding block (desktop)
```
## Responsive Breakpoints
```typescript
xs: "0px"; // Mobile (default)
sm: "480px"; // Large mobile
md: "768px"; // Tablet
lg: "1024px"; // Desktop
xl: "1280px"; // Large desktop
```
## Common Patterns
```typescript
// ✅ Page padding
paddingBlock={{ xs: 'space-8', md: 'space-12' }}
paddingInline={{ xs: 'space-4', md: 'space-10' }}
// ✅ Card padding
padding={{ xs: 'space-6', md: 'space-8' }}
// ✅ Section gaps
gap={{ xs: 'space-6', md: 'space-8' }}
// ✅ Form field gaps
gap="space-4"
// ✅ Button group gaps
gap="space-4"
// ❌ NEVER use Tailwind
className="p-4 m-2" // WRONG!
className="px-6 py-4" // WRONG!
```