Getting started

Usage Guide

This guide covers the core components and conventions used to build interfaces with Zen.

Component Categories#

Zen components fall into two categories, each with a distinct purpose:

Layout Components#

Layout components handle positioning, spacing, and structure. They accept a full set of styling props.

ComponentPurpose
BoxGeneral-purpose container with all styling props
RowHorizontal flex layout
ColumnVertical flex layout
GridCSS grid layout
ContainerCentered, max-width container

Interactive Components#

Interactive components handle user interaction and display. They focus on their core functionality and delegate layout concerns to their parent.

Examples: Button, TextField, Select, Checkbox, Tabs, etc.

The Composition Pattern#

A key principle in Zen is separation of concerns: interactive components handle behavior, layout components handle positioning.

Positioning with Box#

When you need to position or add spacing to an interactive component, wrap it in a layout component:

Form SectionFill out the details below

Why This Pattern?#

  1. Focused APIs - Button handles button concerns, Box handles layout concerns
  2. Flexibility - Any component can be positioned any way without special props
  3. Predictability - Layout is always handled by layout components
  4. Smaller bundle - Interactive components don't carry unused layout prop logic

Building Layouts#

Use Semantic Layout Components#

Prefer Row and Column over Box with flex direction:

Spacing with Gap#

Use gap for consistent spacing between children instead of individual margins:

Container for Page Content#

Use Container to center and constrain page content:

Responsive Design#

Responsive Props#

Most style props accept responsive objects. Use base for mobile-first styles:

Resize to see layout change
Stacks on mobile

Breakpoints#

NameMin WidthTypical Device
base0pxAll devices (mobile-first)
sm640pxLarge phones, small tablets
md768pxTablets
lg1024pxLaptops
xl1280pxDesktops
2xl1536pxLarge desktops

Styling Props#

Common Props by Category#

Spacing:

Layout:

Visual:

Position:

Using className#

For styles not covered by props, use className with Tailwind utilities:

Forms#

Basic Form Layout#

Use Column with consistent gap for form fields:

Form with react-hook-form#

Zen provides form integration components:

Theming#

Light and Dark Mode#

Zen supports light and dark modes out of the box. Use ZenProvider to initialize:

Toggle programmatically with the useTheme hook:

Semantic Colors#

Use semantic color tokens that adapt to the theme:

TokenPurpose
surfacePage background
surface-raisedCards, elevated elements
surface-sunkenInset areas
primaryPrimary text
mutedSecondary text
disabledDisabled state

Composition Examples#

Cards#

Card Title

Card description or content goes here.

Dashboard

Welcome back, here's what's happening.

Empty State#

No items yet

Get started by creating your first item.

Tips#

  1. Start with layout - Build the structure with Row/Column/Grid first, then add content
  2. Use gap over margin - Cleaner and more maintainable for spacing between siblings
  3. Wrap for positioning - Use Box to position interactive components
  4. Think responsive - Use responsive objects for props that should adapt
  5. Leverage semantics - Use semantic colors and tokens for theme compatibility
  6. Keep it simple - Compose simple components rather than configuring complex ones