Block Components
Scaffold
Overview
Scaffold is a powerful layout component that provides a complete application scaffolding structure, including top navigation bar, sidebar, main content area, bottom navigation, and footer. This component supports responsive layouts for both desktop and mobile devices and offers rich customization options.
Installation and Import
Basic Usage
ScaffoldProps Properties Detailed
1. leftSidebar (Optional)
- Type:
React.ReactNode
- Description: Custom left sidebar component. If provided, the layout will use this component instead of the default sidebar component
- Use Case: When you need to completely customize the sidebar style and functionality
2. leftSideProps (Optional)
- Type:
SideBarProps
- Description: Configuration properties for the default sidebar component
- Main Properties:
title
: Sidebar titleitems
: Array of menu itemsopen
: Whether the sidebar is expandedonOpenChange
: Callback for expansion state changesonItemSelect
: Callback for menu item selectioncurrent
: Currently selected menu itemmaxWidth
: Maximum width when expanded (default: 185px)minWidth
: Minimum width when collapsed (default: 98px)
3. topBar (Optional)
- Type:
React.ReactNode
- Description: Custom top navigation bar component
- Use Case: When you need to completely customize the top navigation bar
4. mainNavProps (Optional)
- Type:
MainNavWidgetProps
- Description: Configuration properties for the default main navigation component
- Main Properties:
leading
: Content on the left side of the navigation bartrailing
: Content on the right side of the navigation barlogo
: Brand logo configurationmainMenus
: Array of main menu itemscampaigns
: Campaign menu itemcampaignPosition
: Campaign menu positioninitialProduct
: Initial productinitialMenu
: Initial menu pathonItemClick
: Menu item click callback
5. bottomNavProps (Optional)
- Type:
BottomNavProps
- Description: Mobile bottom navigation configuration (only displayed on mobile devices)
- Main Properties:
mainMenus
: Array of bottom menu items
6. footer (Optional)
- Type:
React.ReactNode
- Description: Custom footer component
7. footerProps (Optional)
- Type:
FooterProps
- Description: Configuration properties for the default footer component
- Main Properties:
telegramUrl
: Telegram linktwitterUrl
: Twitter linkdiscordUrl
: Discord linktrailing
: Content on the right side of the footer
8. routerAdapter (Optional)
- Type:
RouterAdapter
- Description: Router adapter for integrating with different routing libraries
- Main Properties:
onRouteChange
: Route change handler functioncurrentPath
: Current path
9. classNames (Optional)
- Type: Style class name configuration object
- Description: Used to customize styles for various layout areas
- Configurable Areas:
root
: Root container (topNavbar + container + footer)container
: Main containercontent
: Content areabody
: Body area (leftSidebar + content)leftSidebar
: Left sidebartopNavbar
: Top navigation barfooter
: Footer
Complete Usage Example
Responsive Behavior
The Scaffold component automatically detects device type and provides appropriate layouts:
- Desktop: Displays complete sidebar, top navigation bar, and footer
- Mobile: Hides sidebar, displays bottom navigation bar, optimized for touch interaction
Best Practices
- Router Integration: Always provide
routerAdapter
to ensure navigation functionality works properly - Responsive Design: Provide
bottomNavProps
configuration for mobile devices - Style Customization: Use the
classNames
property for style customization instead of directly modifying component styles - Menu State Management: Ensure the
current
property is synchronized with actual route state - Performance Optimization: For large menu lists, consider using React.memo to optimize rendering performance
Important Notes
- The Scaffold component must be wrapped in
ScaffoldProvider
to work properly (automatically handled internally) - Sidebar expand/collapse state is automatically saved to localStorage
- Mobile and desktop use different layout components to ensure good user experience on different devices
- All navigation callbacks should properly handle route navigation logic
Related Components
ScaffoldProvider
: Provides Scaffold contextuseScaffoldContext
: Hook to get Scaffold stateMobileScaffold
: Mobile layout componentDesktopScaffold
: Desktop layout component