Once UI Handbook
Beginner Guides
What is Once UI?
Install & config
Page skeleton
Your first page
Build And Launch
How to launch a portfolio site that actually gets you hired
How to build a documentation site with MDX and Next.js
How to ship a landing page and dashboard with authentication in Next.js
How to launch a social app with Next.js and Supabase
Vibe Coding
Introduction to vibe coding
Set up your local dev environment
Essential tools for vibe coding
Build your first Once UI app
Common Patterns
Hero section
Static panel
Form layout
Highlighted card
Responsive stacking
Decoration layers
Dialog & modal
Toast & feedback
Tables & lists
Loading states
App shell navigation
Dashboard & charts
Chat & messaging
Auth & verification
Settings & split panels
Data filters & toolbar
Command palette
Pricing & plans
Accordion & FAQ
Media & uploads
Empty & error states
SEO, Open Graph, and structured data
Documentation code blocks with live preview
Carousels, galleries, and before/after comparisons
Date pickers and scheduling
Context menus and dropdown actions
Tags, chips, and multi-value inputs
Roadmap & kanban
Form inputs & controls
Progress, status & badges
Scrolling & feeds
Profile, avatars & identity
Social proof & logo clouds
Masonry & media grids
Table pagination, search & bulk selection
Banners & announcements
Footer layouts
Onboarding & first run
Waitlist & coming soon
Design Tips
Color & surfaces
Harness overview
Row, Column & Grid
Spacing & rhythm
Icons & buttons
Reveal & motion
Theme tokens, FOUC-free init, and runtime style controls
Tooltips and hover cards
Block updates
Block updates changelog
Agent Resources
Column, not Flex
Semantics over CSS
Typography scale
Common gotchas
Block anchors
Validate generated code
Pro block registry
Match task bundles
TrademarkTrademark
Ctrl k
Search...
Sign up
Once UI Handbook
Beginner Guides
What is Once UI?
Install & config
Page skeleton
Your first page
Build And Launch
How to launch a portfolio site that actually gets you hired
How to build a documentation site with MDX and Next.js
How to ship a landing page and dashboard with authentication in Next.js
How to launch a social app with Next.js and Supabase
Vibe Coding
Introduction to vibe coding
Set up your local dev environment
Essential tools for vibe coding
Build your first Once UI app
Common Patterns
Hero section
Static panel
Form layout
Highlighted card
Responsive stacking
Decoration layers
Dialog & modal
Toast & feedback
Tables & lists
Loading states
App shell navigation
Dashboard & charts
Chat & messaging
Auth & verification
Settings & split panels
Data filters & toolbar
Command palette
Pricing & plans
Accordion & FAQ
Media & uploads
Empty & error states
SEO, Open Graph, and structured data
Documentation code blocks with live preview
Carousels, galleries, and before/after comparisons
Date pickers and scheduling
Context menus and dropdown actions
Tags, chips, and multi-value inputs
Roadmap & kanban
Form inputs & controls
Progress, status & badges
Scrolling & feeds
Profile, avatars & identity
Social proof & logo clouds
Masonry & media grids
Table pagination, search & bulk selection
Banners & announcements
Footer layouts
Onboarding & first run
Waitlist & coming soon
Design Tips
Color & surfaces
Harness overview
Row, Column & Grid
Spacing & rhythm
Icons & buttons
Reveal & motion
Theme tokens, FOUC-free init, and runtime style controls
Tooltips and hover cards
Block updates
Block updates changelog
Agent Resources
Column, not Flex
Semantics over CSS
Typography scale
Common gotchas
Block anchors
Validate generated code
Pro block registry
Match task bundles
TrademarkTrademark
Once UIDocumentationBlog
© Once UI. All rights reserved.
Built with Aveiro
Common patterns

Documentation code blocks with live preview

CodeBlock with prismjs, multi-file tabs, diff view, and side-by-side preview.
Updated 19d ago
SEO, Open Graph, and structured data
Carousels, galleries, and before/after comparisons
6 min · Pattern
CodeBlock lazy-loads prismjs, supports multi-file tabs, live preview, diff view, and copy — the same module powers docs.once-ui.com.

Install the peer dependency

CodeBlock is exported from @once-ui-system/core but requires prismjs at runtime. Without it, Core renders a MissingDependency placeholder with install instructions. The public entry uses React.lazy so prismjs only loads when a page actually renders a code block.

Single snippet

Pass code (string) and language. Optional label shows a tab header; highlight accepts line numbers as a string ("3-5,8"). Describe the API in prose — the live CodeBlock component is not available in this Learn renderer. In your app, import from @once-ui-system/core and pass code, language, and optional label:

Multi-file tabs

Use the codes array when a guide spans several files. Each entry has code, language, and label — readers switch tabs without leaving the page. Typical split: layout.tsx + page.tsx + a client component. Match labels to real filenames so agents can map tabs to project paths.

Live preview side-by-side

Set preview to a React node to show runnable output next to the source. This is how component docs demonstrate layout without a separate Storybook entry. Keep preview nodes small — a Column with one Button and one Input is enough. Heavy previews slow initial paint because prismjs loads on first render.

Diff and collapse

  • mode="diff" — pass oldCode and newCode for migration guides
  • collapsed / collapsible — long files start folded; readers expand on demand
  • Built-in copy and fullscreen controls ship with every block

Write this / not this

✅ Once UI way
❌ Common mistake
CodeBlock with `language="tsx"`Raw pre tags with manual escaping
`codes={[…]}` for multi-file examplesOne giant pasted file
`preview={…}` for component demosScreenshot-only docs
Install `prismjs` in the docs appImport prism in every page file

Check yourself

  • prismjs is in package.json for any app rendering CodeBlock
  • Preview content uses Column / Row, not raw div + inline styles
  • Tab labels match real filenames in the target repo
  • Diff blocks show before/after, not two unrelated snippets

Related

→ Validate generated code → Your first page → Full reference: docs.once-ui.com — CodeBlock
npm install prismjs
code="(Column with gap 16 and padding 24)…"
language="tsx"
label="page.tsx"