ui/ColumnLayout.svelte

Two-column layout - fixed-width aside on the left, fluid children column on the right. Both columns scroll independently.

Below a threshold of the layout's own width - a container query, not a media query, so a nested layout decides for itself - the columns stack: the aside collapses behind a toggle button labelled toggle_label, and when opened it sits in flow above the content, pushing it down, until the toggle closes it or a navigation does. Opening scrolls the aside into view, under the toggle, when it would land above the view.

With a bounded height, the stacked layout scrolls as one column and the toggle sticks to its top; under a parent that grows with its content, the page scrolls and the toggle scrolls away with it.

The threshold matches fuz_css's sm breakpoint. Above it the toggle is display: none. The switch is CSS alone, so the server render shows the right form at any width and hydration changes nothing.

The root is an inline-size query container, so its width can't come from its content: a layout placed where it would shrink to fit (an inline-block, an absolutely positioned or floated box without a width, a flex row item that doesn't grow) collapses to zero width. Give it a width from its context, as a block or a stretched or growing flex item.

Requires the SvelteKit runtime - it closes the aside from afterNavigate. Without JS the stacked aside can't be opened, since the toggle is client state; above the threshold it's always shown.

The aside column is a plain <div>, not a landmark, as with AppShell's sidebar: render the landmark inside the aside snippet - a <nav aria-label> for navigation links, or an <aside aria-label> for other content.

Styling hooks: --column_width (set from column_width) and --column_toggle_bg, the stacked toggle bar's opaque background so content scrolls under it unseen (default --shade_00, the page ground).

view source

Declarations
#

ColumnLayout
#

ui/ColumnLayout.svelte view source

accepts children

import ColumnLayout from '@fuzdev/fuz_app/ui/ColumnLayout.svelte';

aside

type Snippet<[]>

children

type Snippet<[]>

column_width?

CSS width of the fixed aside column.

type string
optional default '280px'

toggle_label?

The stacked toggle's text.

type string
optional default 'menu'

class?

type ClassValue | null
optional default ''

CSS custom properties

--column_toggle_bg
fallback var(--shade_00)

external types

SvelteHTMLElements['div']