LunarCSS

Sizing

Width, height, min/max sizing, and the size shorthand.

Classes

w-{n}     h-{n}
min-w-{n} max-w-{n}
min-h-{n} max-h-{n}
size-{n}           ← sets both width and height

Value types

FormExampleResolved
Numericw-1616 × 4px = 64px
Fractionw-1/250%
Keyword fullw-full100%
Keyword autow-autoauto (or undefined on RN where unsupported)
Keyword screenw-screenDimensions.get('window').width on native / 100vw on web
Keyword pxw-px1px
Arbitraryw-[320px]320px
Named tokenw-card--width-card → fallback --spacing-card

Named tokens

// lunar.config.ts
export default defineConfig({
  theme: {
    extend: {
      width: {
        card: '320px',
        sidebar: '240px',
      },
      maxWidth: {
        content: '768px',
      },
    },
  },
})

Usage:

<View className="w-card max-w-content" />

Token fallback chain

For w-{name}, LunarCSS checks in order:

  1. --width-{name} (from theme.extend.width)
  2. --spacing-{name} (from theme.extend.spacing)

This means a spacing.card token is usable as w-card without explicitly adding it to width.

size-{n} shorthand

Sets both width and height to the same value:

<View className="size-10" />     // width: 40, height: 40
<View className="size-full" />   // width: '100%', height: '100%'
<View className="size-[48px]" /> // width: 48, height: 48

Examples

// Full screen container
<View className="w-full h-full" />

// Fixed card width
<View className="w-card min-h-[200px]" />

// Flexible content area with max width
<View className="w-full max-w-content mx-auto" />

// Square avatar
<View className="size-10 rounded-full overflow-hidden" />

// Responsive: full width on mobile, fixed on md+
<View className="w-full md:w-card" />

On this page