import { Button, Link } from "@senvenli/react/action";
import { Heading, Text } from "@senvenli/react/display";
import { Form, Input } from "@senvenli/react/form";
import { Split, SplitPane, Stack } from "@senvenli/react/layout";
export default function Example() {
return (
// A real sign-in page is the whole screen: `<Split fullHeight …>` and no frame.
<div className="overflow-hidden rounded-ds-large border border-ds-border">
<Split ratio="1.05fr 1fr" collapseBelow="48rem" hideOnNarrow="start">
<SplitPane as="aside" background="surface-sunken" padding="space-600">
<Stack space="space-600">
<Text size="body-large" weight="medium">Acme</Text>
<Stack space="space-100">
<Heading level={2} size="heading-xlarge">Every project in one place</Heading>
<Text tone="subtle">Plan the work, track it and bill it.</Text>
</Stack>
</Stack>
</SplitPane>
<SplitPane as="main" align="center" padding="space-600">
<Stack space="space-300" as="div">
<Stack space="space-075">
<Heading level={1} size="heading-large">Sign in</Heading>
<Text tone="subtle">Use your work email.</Text>
</Stack>
<Form onSubmit={(event) => event.preventDefault()}>
<Input label="Email" name="email" type="email" autoComplete="email" isRequired />
<Input type="password" label="Password" name="password" autoComplete="current-password" isRequired />
<Button type="submit" variant="primary">Sign in</Button>
</Form>
<Link href="#reset" variant="subtle">Forgot your password?</Link>
</Stack>
</SplitPane>
</Split>
</div>
);
}import { Split, SplitPane } from "@senvenli/react/layout";Examples
List and detail
A fixed-width list beside the item it opens; stacked when narrow.import { GridList, type GridListStackProps } from "@senvenli/react/collection";
import { Heading, Text } from "@senvenli/react/display";
import { Split, SplitPane, Stack } from "@senvenli/react/layout";
import { useState } from "react";
const INVOICES = [
{ id: "inv-318", customer: "Northwind", total: "€1,240.00", due: "Due March 25" },
{ id: "inv-317", customer: "Globex", total: "€860.50", due: "Due March 27" },
{ id: "inv-316", customer: "Initech", total: "€2,015.00", due: "Due April 2" },
];
type Keys = NonNullable<GridListStackProps["selectedKeys"]>;
export default function Example() {
const [selected, setSelected] = useState<Keys>(new Set(["inv-318"]));
const id = selected === "all" ? INVOICES[0]!.id : ([...selected][0] ?? INVOICES[0]!.id);
const invoice = INVOICES.find((item) => item.id === id)!;
return (
<Split ratio="16rem 1fr" space="space-300">
<SplitPane>
<GridList
aria-label="Invoices"
items={INVOICES}
selectionMode="single"
selectedKeys={selected}
onSelectionChange={setSelected}
renderItem={(item) => ({ id: item.id, title: item.customer, description: item.total })}
/>
</SplitPane>
<SplitPane background="surface-sunken" radius="large" padding="space-300">
<Stack space="space-100">
<Heading level={3} size="heading-small">{invoice.customer}</Heading>
<Text size="body-large" weight="medium">{invoice.total}</Text>
<Text tone="subtle">{invoice.due}</Text>
</Stack>
</SplitPane>
</Split>
);
}Guidelines
When to use it
- A screen of two (or more) panes that sit side by side when there is room: a sign-in form beside a brand pane, a list beside its detail.
- The split must follow the space the layout gets (a dialog, a shell with a sidebar), not the window.
Use something else when
Do and avoid
- Hide a decorative pane on narrow layouts with hideOnNarrow; never hide the pane that holds the task.
- Put the page's one main landmark on the pane that holds the task (
as="main") when the Split is the whole page.
Accessibility
Built in
- A pane hidden on narrow layouts is display: none, so it leaves the accessibility tree too.
- Panes follow source order in every layout, so reading and tab order never jump.
You provide
- The landmark of each pane (
as="main",as="aside") and the headings in it.
API reference
Split
| Prop | Type | Default | Description |
|---|---|---|---|
as | LayoutElement | "div" | |
ratio | string | "1fr 1fr" | The columns side by side, as a CSS grid template: |
collapseBelow | SplitCollapse | "48rem" | Below this width of the layout itself the panes stack in one column. Default |
hideOnNarrow | "start" | "end" | – | The pane that is left out when stacked (a brand or picture pane that adds nothing on a phone). Default: none. |
space | Space | – | The gap between the panes. Default none: panes meet edge to edge, each with its own ground. |
fullHeight | boolean | false | At least as tall as the viewport: a screen of its own, like a sign-in page. |
asLayoutElementDefault"div"ratiostringDefault"1fr 1fr"The columns side by side, as a CSS grid template:
"1fr 1fr"(default),"1.05fr 1fr","20rem 1fr".collapseBelowSplitCollapseDefault"48rem"Below this width of the layout itself the panes stack in one column. Default
"48rem".hideOnNarrow"start" | "end"The pane that is left out when stacked (a brand or picture pane that adds nothing on a phone). Default: none.
spaceSpaceThe gap between the panes. Default none: panes meet edge to edge, each with its own ground.
fullHeightbooleanDefaultfalseAt least as tall as the viewport: a screen of its own, like a sign-in page.
SplitPane
| Prop | Type | Default | Description |
|---|---|---|---|
padding | Space | – | |
paddingInline | Space | – | |
paddingBlock | Space | – | |
background | Background | – | |
radius | Radius | – | |
shadow | Shadow | – | |
border | Border | – | |
as | LayoutElement | "div" | |
align | "center" | "stretch" | "stretch" |
|
paddingSpacepaddingInlineSpacepaddingBlockSpacebackgroundBackgroundradiusRadiusshadowShadowborderBorderasLayoutElementDefault"div"align"center" | "stretch"Default"stretch"stretch(default): content fills the pane.center: content sits in the middle, both ways.