Skip to content

Container Layout

Container components used for layout, making it easy to quickly build the basic structure of a page. Uses Flexbox layout and includes five sub-components: Container, Header, Aside, Main, and Footer.

Common Page Layouts

Header + Main

Header
Main
Header + Main

Aside + Main

Main
Aside + Main

Full Layout

Classic admin layout with Header + Aside + Main + Footer. The Container component automatically detects if children include Header or Footer and switches to a vertical layout if so.

Header
Main
Footer
Full Layout

Use in Nuxt

Container component fully supports Nuxt 3/4 SSR rendering. The following example demonstrates building an admin layout with a collapsible sidebar in Nuxt's layouts/default.vue, where the content area uses <NuxtPage /> to render the current route.

My App

Current Route Content (NuxtPage)
© 2024 YH-UI
Nuxt Usage (layouts/default.vue)

SSR Notes:

  • ✅ All Props and styles fully supported
  • ✅ Flex layout direction auto-detection works normally
  • ✅ Slot content fully rendered
  • ✅ Used in combination with NuxtPage container
  • NuxtLink routing links fully supported
  • ✅ Responsive sidebar collapse support

SSR Safety

All Container sub-components have passed complete SSR tests, ensuring that server-side and client-side rendering are completely consistent with no Hydration errors.

API

Container Props

PropDescriptionTypeDefault
directionArrangement direction'horizontal' | 'vertical'Auto-detect (vertical when Header/Footer present)
themeOverridesTheme overridesComponentThemeVars

Header Props

PropDescriptionTypeDefault
heightHeader heightstring'60px'
themeOverridesTheme overridesComponentThemeVars

Aside Props

PropDescriptionTypeDefault
widthSidebar widthstring'200px'
themeOverridesTheme overridesComponentThemeVars

Main Props

PropDescriptionTypeDefault
themeOverridesTheme overridesComponentThemeVars
PropDescriptionTypeDefault
heightFooter heightstring'60px'
themeOverridesTheme overridesComponentThemeVars

Slots

All sub-components support the default slot.

Theme Variables

Container component supports customizing local styles by overriding the following CSS variables:

Variable NameDescriptionDefault
--yh-header-paddingHeader padding0 20px
--yh-header-bg-colorHeader background colortransparent
--yh-header-border-bottomHeader bottom bordernone
--yh-aside-bg-colorSidebar background colortransparent
--yh-aside-border-rightSidebar right bordernone
--yh-main-paddingMain area padding20px
--yh-main-bg-colorMain area background colortransparent
--yh-footer-paddingFooter padding0 20px
--yh-footer-bg-colorFooter background colortransparent
--yh-footer-border-topFooter top bordernone

Released under the MIT License.