SlidingColumn
A panel that slides in along the right edge of a view, resized by dragging its left edge. With side="left" it stands along the left edge and drags by its right one. The edge it drags by shows an accent line while the pointer is on it or a drag runs.
import { SlidingColumn } from '@adecore/ui';import { CloseButton, IconButton, PanelHeader, SlidingColumn } from '@adecore/ui';
import { PanelRight } from 'lucide-react';
import { useState } from 'react';
const BOUNDS = { min: 200, max: () => 360 };
export default function SlidingColumnDemo() {
const [open, setOpen] = useState(true);
const [width, setWidth] = useState(260);
return (
<div className="flex h-72 w-full overflow-hidden rounded-lg border border-border bg-bg">
<div className="flex grow items-start justify-end p-2">
<IconButton icon={PanelRight} label={open ? 'Hide details' : 'Show details'} active={open} onClick={() => setOpen(!open)} />
</div>
<SlidingColumn open={open} width={width} bounds={BOUNDS} onWidthChange={setWidth}>
<PanelHeader title="Details">
<span className="grow" />
<CloseButton label="Close details" size="sm" onClick={() => setOpen(false)} />
</PanelHeader>
<p className="p-3 text-xs text-text-muted">Drag the left edge. The column is {width} pixels wide.</p>
</SlidingColumn>
</div>
);
}Closed, the column is 0 pixels wide and inert. The contents keep the stored width while it slides, so they do not reflow, and stay mounted until a close finishes.
You hold the width. During a drag, onWidthChange reports whole pixels within bounds.min and bounds.max(). Clamp a stored width yourself with clampColumnSize before passing it in.
instant skips the animation, for a width restored on page load.
Space between panels
gap={8} replaces the border on the free edge with 8 pixels of --separator space, which the resize handle fills. width, bounds and onWidthChange measure the column alone, so an open column takes width + gap pixels.
A column with shortcuts
body hands the column the keyboard. The inner column gets tabIndex={-1}, so code can move focus into it, and its onKeyDown hears keys while focus is inside.
Props
| Prop | Type | Default | |
|---|---|---|---|
open | boolean | Required. | |
side | 'left' | 'right' | 'right' | The edge of the view the column stands against. |
width | number | Required. In pixels, already clamped. | |
gap | number | 0 | Space on the free edge of the column, in whole pixels. |
edge | boolean | true | The border on the free edge without a gap. Off in a Workspace side panel, whose left edge is the sheet's. |
bounds | { min: number; max(): number } | Required. max is read at drag time. | |
onWidthChange | (width: number) => void | Required. | |
instant | boolean | false | |
body | { ref: RefObject<HTMLDivElement | null>; onKeyDown(event): void } | ||
children | ReactNode | ||
className | string | On the outer column. | |
ref | Ref<HTMLElement> | The outer column, for bounds that measure what is beside it. |
SlidingColumnProps is an exported type.