Skip to content

DockShell ​

The floating bar at the bottom of a canvas-like view, which can hide itself.

tsx
import { DockShell } from '@adecore/ui';
tsx
import { ButtonGroup, DockShell, IconButton, Separator, Switch } from '@adecore/ui';
import { Hand, MousePointer2, Square, Type } from 'lucide-react';
import { useState } from 'react';

const TOOLS = [
    { id: 'select', label: 'Select', icon: MousePointer2 },
    { id: 'pan', label: 'Pan', icon: Hand },
    { id: 'box', label: 'Box', icon: Square },
    { id: 'text', label: 'Text', icon: Type }
];

export default function DockShellDemo() {
    const [tool, setTool] = useState('select');
    const [autoHide, setAutoHide] = useState(false);

    return (
        <div className="relative h-72 w-full overflow-hidden rounded-lg bg-surface-sunken">
            <label className="absolute top-3 left-3 flex items-center gap-2 text-xs text-text-muted">
                <Switch label="Hide the dock" checked={autoHide} onCheckedChange={setAutoHide} />
                Hide until the pointer comes down
            </label>
            <DockShell autoHide={autoHide}>
                <ButtonGroup>
                    {TOOLS.map((entry) => (
                        <IconButton key={entry.id} icon={entry.icon} label={entry.label} active={tool === entry.id} onClick={() => setTool(entry.id)} />
                    ))}
                </ButtonGroup>
                <Separator />
                <span className="px-2 text-xs text-text-muted">{TOOLS.find((entry) => entry.id === tool)?.label}</span>
            </DockShell>
        </div>
    );
}

With autoHide the dock hides below the edge until the pointer comes within 120 pixels of the window's bottom. An open menu in the dock keeps it up. Keyboard focus inside it brings it back.

Mark an element that belongs to the dock, such as a popover on it, with data-holds-dock, so hovering it keeps the dock up. onHiddenChange reports when the bar hides or returns.

The dock is centered 16 pixels above the bottom of its positioned parent. The bar is a Surface.

Props ​

DockShell renders a <div> and takes its props, plus:

PropTypeDefault
childrenReactNodeRequired.
autoHidebooleanfalse
barClassNamestringClasses for the bar itself, such as letting a dock with many buttons wrap.
onHiddenChange(hidden: boolean) => void
refRef<HTMLDivElement>The outer box, not the bar.

DockShellProps is an exported type.

Licenses and third-party notices are listed in each package.