App Shell

Responsive shell for controlling application layout.

javascript
import { AppShell } from '@brainandbones/skeleton';
Header
Page Content
Page Footer

Usage

For best results implement this in your app's root layout. The slot order does not matter.

html
<AppShell>
	<svelte:fragment slot="header">Header</svelte:fragment>
	<svelte:fragment slot="sidebarLeft">Sidebar Left</svelte:fragment>
	<svelte:fragment slot="sidebarRight">Sidebar Right</svelte:fragment>
	<svelte:fragment slot="pageHeader">Page Header</svelte:fragment>
	<!-- Router Slot -->
	<slot />
	<!-- ---- / ---- -->
	<svelte:fragment slot="pageFooter">Page Footer</svelte:fragment>
	<svelte:fragment slot="footer">Footer</svelte:fragment>
</AppShell>

The App Shell will need expand to fill your body tag. First, remove all wrapping elements in your root page. For SvelteKit that's located in /src/app.html.

html
<body>
	<!-- Drop wrapping elements, allow your layout to be the root -->
	%sveltekit.body%
</body>

Then, disable overflow on your html and body tags to prevent duplicate scroll bars. Update your global stylesheet with the following.

css
html, body { @apply h-full overflow-hidden; }

App Bar

If you wish for your App Bar component to remain fixed at the top of the page, embed it into the top-most header slot.

html
<AppShell>
	<svelte:fragment slot="header">
		<AppBar>Skeleton</AppBar>
	</svelte:fragment>
	<!-- ... -->
</AppShell>

Sidebars

Please be aware that sidebars have a default width of auto. Sidebars will automatically collapse when their contents are empty or hidden. This is useful if you wish to hide the sidebar with CSS media queries via Tailwind's responsive breakpoints.

html
<AppShell>
	<svelte:fragment slot="sidebarLeft">
	    <!-- Hidden below Tailwind's large breakpoint -->
		<div id="sidebar-left" class="hidden lg:block">Sidebar</div>
	</svelte:fragment>
</AppShell>

Properties

Prop Type Default Description
slotHeaderstring-Provide arbitrary classes to the header slot element.
slotSidebarLeftstringw-autoProvide arbitrary classes to the header left sidebar element.
slotSidebarRightstringw-autoProvide arbitrary classes to the header right sidebar element.
slotPageHeaderstring-Provide arbitrary classes to the header page header element.
slotPageContentstring-Provide arbitrary classes to the header page content element.
slotPageFooterstring-Provide arbitrary classes to the header page footer element.
slotFooterstring-Provide arbitrary classes to the footer element.

Slots

Name Description
defaultYour page content. Insert your router slot here.
headerInsert fixed header content, such as the AppBar component.
sidebarLeftHidden when empty. Allows you to set fixed left sidebar content.
sidebarRightHidden when empty. Allows you to set fixed right sidebar content.
pageHeaderInsert content that resides above your page content. Great for global alerts.
pageFooterInsert content that resides below your page content. Recommended for most layouts.
footerInsert fixed footer content. Not recommended for most layouts.