Documentation
Preview Block
A container component that displays live previews of components in documentation. Shows component boundaries with optional background patterns, perfect for showcasing UI components.
Installation
shellUsage
tsxProps
Background Variants
Dots
Default background with subtle dot pattern. Use for most component previews.
tsxGrid
Grid pattern for layout demonstrations.
tsxNone
No background. Use for components with their own backgrounds or full-width layouts.
tsxPattern Customization
Customize the pattern size and color to match your design needs.
Custom Size
tsxCustom Color
tsxCombined
tsxExamples
Single Component
tsxMultiple Components
tsxWith Custom Layout
tsxFull-Bleed Gradient
Use p="0" for gradients that should extend to the edges.
tsxImage Background
Use p="0" with a background image for full-bleed photo backgrounds.
tsxCustom Spacing
Adjust padding and margin to fit your layout needs.
tsxDesign Decisions
- Centered layout: Components are centered both horizontally and vertically
- Min height: 240px minimum height ensures adequate preview space
- Soft card: Uses soft Card variant for subtle container
- Font family override: Sets
fontFamily="sans"via Theme to ensure consistent preview rendering - Spacing: Default vertical margin (
my="3") for separation from surrounding content
Accessibility
Preview Block provides accessible component previews:
Structure
- Wraps content in semantic Box and Card components
- Maintains proper document outline
- No special ARIA attributes needed (presentational container)
Visual
- Background patterns use CSS variables that respect color mode
- Sufficient contrast between background and components
- Patterns are subtle and don't interfere with component visibility
Changelog
Added
- Preview Block component for live component demos
- Dots background pattern (default)
- Grid background pattern
- None background option
- Centered layout with flexible spacing
patternSizeprop for customizing pattern spacingpatternColorprop for customizing pattern colorwidthandheightprops for sizingvariantprop for card stylingappearanceprop for theme controlshowThemeToggleprop for interactive theme switching- Padding props (
p,px,py,pt,pr,pb,pl) for inner content spacing - Margin props (
m,mx,my,mt,mr,mb,ml) for outer container spacing
© 2026 Kushagra Dhawan. Licensed under MIT. GitHub.