Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Containers

  • Layout
  • AdminLayout
  • SettingsLayout
  • ScrollArea
  • Viewport
  • Resizable
  • AspectRatio
  • FitScreen
  • PreviewSandbox
  • Masonry
  • Container
  • AccentScope

Arrangement

  • Stack
  • Grid
  • Spacer
  • Divider
  • Separator

AdminLayout

admin-layout

Provides an admin shell with navigation, header actions, managed route tabs, and scrollable content.

Usage

Basic skeleton

Sidebar brand + NavMenu + top bar + multiple tabs + content area; click the menu to automatically open tabs (uncontrolled).

Hulian Admin
  • Business Management
Home / Dashboard
3Hu
Dashboard

Dashboard

This is "Dashboard" page content. Click the menu on the left to open a new tab. The tab above can be switched/closed to experience the middle and backend keep-alive navigation.

Indicators 1
1,234
Indicators 2
2,468
Indicators 3
3,702
Indicators 4
4,936
Indicators 5
6,170
Indicators 6
7,404
tsx
<AdminLayout
  menuItems={menu}
  logo={<span className="font-bold text-primary">Hulian Admin</span>}
  defaultActiveKey="dashboard"
  defaultSelectedKey="dashboard"
  breadcrumb={<span className="text-sm text-muted-foreground">Home/Dashboard</span>}
  headerExtra={<Avatar fallback="Hu" />}
>
  <Dashboard />
</AdminLayout>

Close the sidebar by default

defaultCollapsed Let the sidebar initially collapse into an icon track, and click the top bar burger to expand it.

Hu
  • Dashboard
  • Order Management
  • Product Management
  • User Center
  • System Settings
Home / Dashboard
Hu
Dashboard

Dashboard

This is "Dashboard" page content. Click the menu on the left to open a new tab. The tab above can be switched/closed to experience the middle and backend keep-alive navigation.

Indicators 1
1,234
Indicators 2
2,468
Indicators 3
3,702
Indicators 4
4,936
Indicators 5
6,170
Indicators 6
7,404
tsx
<AdminLayout
  menuItems={menu}
  logo={<Logo />}
  logoCollapsed={<span>hu</span>}
  defaultCollapsed
  defaultActiveKey="dashboard"
>
  <Dashboard />
</AdminLayout>

Hide multiple tabs

showTabs={false} Close the tab bar and reduce it to a single page of content (suitable for a minimalist console).

Hulian Admin
  • Business Management
Home / Dashboard
Hu

Dashboard

This is "Dashboard" page content. Click the menu on the left to open a new tab. The tab above can be switched/closed to experience the middle and backend keep-alive navigation.

Indicators 1
1,234
Indicators 2
2,468
Indicators 3
3,702
Indicators 4
4,936
Indicators 5
6,170
Indicators 6
7,404
tsx
<AdminLayout
  menuItems={menu}
  logo={<Logo />}
  showTabs={false}
  defaultSelectedKey="dashboard"
>
  <Dashboard />
</AdminLayout>

When to use

Use AdminLayout when you need a complete admin shell with a sidebar menu, header, and multi-tab keep-alive navigation out of the box. Provide menuItems and children to get started. If you need full control over each region, no built-in tab behavior, or a more composable foundation, use Layout instead.

Import

ts
import { AdminLayout } from "@hulianui/ui"

Props

NameTypeDefaultDescription
menuItems*NavMenuNode[]-Sidebar menu data rendered with NavMenu.
selectedKeystring-Controlled selected menu item key.
defaultSelectedKeystring-Initial selected menu item key when uncontrolled.
openKeysstring[]-Controlled keys for expanded submenus.
defaultOpenKeysstring[]-Initial expanded submenu keys when uncontrolled.
collapsedboolean-Controlled sidebar collapse state.
defaultCollapsedbooleanfalseInitial sidebar collapse state when uncontrolled.
breakpoint"sm"|"md"|"lg"|"xl"|"2xl"|number-Responsive breakpoint with the same semantics as LayoutSider. The sidebar collapses when the viewport is at or below this width and expands above it. In uncontrolled mode, the component updates its own state. When collapsed is passed, it only calls onCollapsedChange; the consumer decides whether to apply the new state. Omit this prop to disable automatic collapsing.
showTabsbooleantrueWhether to show the tab bar.
tabsAdminTab[]-Controlled tab list. When omitted, menu selections maintain the list automatically.
activeKeystring-Controlled active tab key.
defaultActiveKeystring-Initial active tab key when uncontrolled; it also determines which tab opens on first render.
fitViewportbooleantrueWhether the shell fills the viewport. Keep true for a full-page application: the shell uses a fixed 100dvh height and scrolls inside the content area. Pass false inside a fixed-height preview or container and use h-full to follow the parent height.
classNamestring-Additional class name for the root container.
contentClassNamestring-Additional class name for the content area.

AdminTab has the shape { key: string; label: ReactNode; closable?: boolean }. By default, closable allows a tab to close when more than one tab is open; the final tab cannot be closed.

The tab bar is the standalone RouteTabs component. RouteTabs provides the context menu, pinned tabs, drag-and-drop ordering, and automatic scrolling of the active tab into view; AdminLayout simply embeds it in the shell. Use RouteTabs directly when composing your own shell.

Events

EventTypeDescription
onMenuSelect(key: string, item: NavMenuItem) => voidCalled when a leaf menu item is selected.
onOpenChange(openKeys: string[]) => voidCalled when the expanded submenu keys change.
onCollapsedChange(collapsed: boolean) => voidCalled when the sidebar collapse state changes.
onTabChange(key: string) => voidCalled when the active tab changes.
onTabClose(key: string) => voidCalled when a tab is closed.
onTabsAction(action, tabKey, affectedKeys) => voidCalled for context-menu actions such as close others, close left/right/all, or refresh. The third argument contains the keys actually affected by the action. ⚠️ This is the only update path when tabs is controlled: without this handler, these actions cannot change the consumer-owned tab list.

Slots

SlotTypeDescription
childrenReactNodeMain content for the active page, selected by the application from activeKey.
logoReactNodeBrand area (expanded).
logoCollapsedReactNodeBrand area (collapsed, logo reused by default).
breadcrumbReactNodeTop bar breadcrumb area.
headerExtraReactNodeExtension area on the right side of the top bar (user menu/notification/theme switching, etc.).

Example

tsx
const [active, setActive] = useState("dashboard");

<AdminLayout
  menuItems={menu}
  logo={<span className="font-bold text-primary">HulianUI Admin</span>}
  logoCollapsed={<span className="font-bold text-primary">H</span>}
  breakpoint="md" // Collapse the sidebar automatically at ≤768px
  defaultActiveKey="dashboard"
  defaultSelectedKey="dashboard"
  defaultOpenKeys={["users"]}
  onTabChange={setActive}
  breadcrumb={<span className="text-sm text-muted-foreground">Home / {active}</span>}
  headerExtra={<Avatar fallback="H" />}
>
  <Page k={active} />
</AdminLayout>

Usage guidelines

  • Treat logoCollapsed as required whenever collapsible is on. A collapsed sider is only 64px wide, so without a narrow mark the full logo gets clipped in half by overflow-hidden. Nothing throws, it just looks broken, so a development warning fires once (#121). A first glyph, a monochrome icon, or a square mark all work.
  • Put Brand directly in the brand area: logo={<Brand mark={…} name="…" />} and logoCollapsed={<Brand mark={…} />}. Animated or video logos also go through Brand's mark (GIF, <picture> reduced-motion fallbacks, and muted <video> already receive the fill rules). The AdminLayout logo slot only positions and aligns; it gives media no size, so a bare large image is clipped at its natural size by overflow-hidden.
  • The header and the sidebar brand block share --hl-layout-header-h, and the brand block switches to justify-center when collapsed so it shares a centre line with the collapsed NavMenu icon rail. When editing this area, switch the alignment as well as the content.
  • Handle onTabsAction when tabs is controlled. AdminLayout does not own the tabs array in controlled mode. Context-menu actions can only report the keys that should change; the consumer must apply the update.
  • Close All closes every closeable tab, including the active tab. It is distinct from Close Others.
  • Choose the height strategy with fitViewport. Keep the default true for a full-page shell and do not add another h-dvh wrapper. Pass false when embedding AdminLayout in a fixed-height container such as a documentation preview, or the page will scroll instead of the content area. See [[hulian-adminlayout-fitviewport]].
  • Choose either controlled or uncontrolled tabs. Omit tabs to let menu selections maintain the tab list. Once tabs is passed, handle onTabChange and onTabClose and keep the array and activeKey in application state.
  • children renders only the active page. The application must manage any keep-alive cache keyed by activeKey; AdminLayout does not cache each page's DOM.
  • Set breakpoint for mobile layouts ("md" is recommended). Without it, the sidebar remains expanded and occupies more than half of a 390px viewport. The prop has no default to preserve existing behavior, so responsive collapsing must be enabled explicitly.

Related

Layout · ScrollArea · Viewport · Resizable · AspectRatio · FitScreen

PreviousLayoutLayoutNextSettingsLayout

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Events
    • Slots
    • Example
    • Usage guidelines
    • Related