Split
Two-column layout with configurable proportions that stacks to a single column when its own width gets narrow.
Import
import { Split } from "@hyzer-labs/ui"Demo
fraction is the first column's share. auto sizes the first
column to its content and gives the rest to the second. Below the stackBelow width (default sm, 640px of the Split's own width)
the columns stack.
<Split fraction="1/4">
<div>First</div>
<div>Second</div>
</Split><Split fraction="1/3">
<div>First</div>
<div>Second</div>
</Split><Split fraction="1/2">
<div>First</div>
<div>Second</div>
</Split><Split fraction="2/3">
<div>First</div>
<div>Second</div>
</Split><Split fraction="3/4">
<div>First</div>
<div>Second</div>
</Split><Split fraction="auto">
<div>First</div>
<div>Second</div>
</Split>reverse swaps the columns with CSS order. The DOM is
untouched, so screen readers and Tab order still follow source order. This is useful for
alternating media and text rows.
<!-- reverse swaps the columns visually only; DOM, reading, and focus order are unchanged -->
<Split fraction="1/3" reverse>
<div>DOM first (visual right)</div>
<div>DOM second (visual left)</div>
</Split>The Split stacks when its own width drops under the chosen width token (sm 640px, md
968px, lg 1200px). The threshold resolves through var(--hz-width-*), so overriding those tokens (globally or on any ancestor)
retunes when it stacks. Use the slider to cross the threshold.
side by side
<Split stackBelow="sm">
<div>First</div>
<div>Second</div>
</Split>side by side
<Split stackBelow="md">
<div>First</div>
<div>Second</div>
</Split>side by side
<Split stackBelow="lg">
<div>First</div>
<div>Second</div>
</Split>The tinted zone is the Split; the space between its edge and the panes is the padding.
It sits on the split root, so stackBelow measures the padded-down width. padding applies on both axes; paddingInline / paddingBlock override one axis and win where set. The axis names are the
CSS logical properties, so they stay correct in RTL and vertical writing modes. See Spacing & Sizing.
<Split padding="none">…</Split>
<Split paddingInline="none">…</Split>
<Split paddingBlock="none">…</Split><Split padding="sm">…</Split>
<Split paddingInline="sm">…</Split>
<Split paddingBlock="sm">…</Split><Split padding="md">…</Split>
<Split paddingInline="md">…</Split>
<Split paddingBlock="md">…</Split><Split padding="lg">…</Split>
<Split paddingInline="lg">…</Split>
<Split paddingBlock="lg">…</Split><Split padding="near">…</Split>
<Split paddingInline="near">…</Split>
<Split paddingBlock="near">…</Split><Split padding="away">…</Split>
<Split paddingInline="away">…</Split>
<Split paddingBlock="away">…</Split>Props
| Name | Type | Default | Note |
|---|---|---|---|
fraction | '1/4' | '1/3' | '1/2' | '2/3' | '3/4' | 'auto' | '1/2' | |
gap | 'none' | 'sm' | 'md' | 'lg' | 'near' | 'away' | 'md' | near/away are the density distances — they tighten inside data-density-shift regions. |
reverse | boolean | false | |
stackBelow | 'sm' | 'md' | 'lg' | 'sm' | Stacks under the --hz-width-sm/md/lg token (640/968/1200px) of the Split's own width. Resolves via var() — overriding the token retunes the threshold. |
padding | 'none' | 'sm' | 'md' | 'lg' | 'near' | 'away' | 'none' | Both axes, on the split root — stackBelow measures the padded-down width. Shared LayoutPadding scale. |
paddingInline | 'none' | 'sm' | 'md' | 'lg' | 'near' | 'away' | — | Per-axis override — wins over padding on the inline axis. Same LayoutPadding scale. |
paddingBlock | 'none' | 'sm' | 'md' | 'lg' | 'near' | 'away' | — | Per-axis override — wins over padding on the block axis. Same LayoutPadding scale. |
as | string | 'div' | |
class | string | — | Merged after the hz-split class. |
children | Snippet | — | Two direct children become the columns. |
Theme hooks
What this component promises your CSS. The reference theme styles exactly these — from @layer hz-theme, so your unlayered rules win. See Styling Components for the how.
Root class: .hz-split
Data attributes
| Hook | Values | Styles |
|---|---|---|
data-fraction | '1/4' | '1/3' | '1/2' | '2/3' | '3/4' | 'auto' | Ratio of the two columns above the stack threshold. Default 1/2. |
data-gap | 'none' | 'sm' | 'md' | 'lg' | 'near' | 'away' | Gap between the columns. Default md. |
data-reverse | present when reversed | Visual-only swap via order — DOM and focus order are preserved. |
data-stack-below | 'sm' | 'md' | 'lg' | Picks which --hz-width-* token the stack threshold resolves through, so overriding that token retunes when the split stacks. Default sm. |
data-padding | 'none' | 'sm' | 'md' | 'lg' | 'near' | 'away' | Padding, applied to the root. Default none. |
Part classes
| Hook | Values | Styles |
|---|---|---|
.hz-split-layout | child element | The flex row. Carries the gap; the fraction and order rules reach your two children through it. |
Accessibility
Split is a layout primitive with no ARIA semantics. DOM order determines reading and focus order regardless of visual arrangement.