# Canvas panel

The plane's side panel: a head that docks it, a body the product fills and the tools' bar at its foot, drawn as a sheet over a narrow plane, or the plane's dock at the bottom centre of the canvas.

Live variants: https://design.arcadia.is/components/canvas-panel

```tsx
import { CanvasPanel } from "@arcadia/ui";
```

The panel docked left and bottom, over the plane's ground. Drag its head, or press the head and use the arrows.

```tsx
import { useState } from "react";
import { CanvasPanel, Facts } from "@arcadia/ui";

function Stage({ place, sheet, tool, narrow }: StageProps) {
  const [where, setWhere] = useState<CanvasPanelPlace>(place ?? { side: "left", anchor: "bottom" });
  return (
    <div {...stylex.props(CanvasPanelStyles.stage, narrow === true && CanvasPanelStyles.narrow)}>
      <CanvasPanel
        label="Tools"
        place={where}
        onPlaceChange={setWhere}
        sheet={sheet}
        defaultTool={tool}
        rootStyle={CanvasPanelStyles.panel}
      >
        <Facts items={BODY} />
      </CanvasPanel>
    </div>
  );
}
```

## Accessibility

The panel is a named region. Its head is a button named for what it does, and the arrows dock it to a side and an anchor, so the drag has its keys. The bar is one tab stop with the arrow keys moving between the tools, and each tool's name and key are its tooltip. The fold is a button that names the panel it folds. A dock has no head and no fold: its tools are one group of choices, so the tool in hand is heard as checked and the row stays one tab stop with the arrows, Home and End between the tools.

- Tab: Reaches the panel's head, its body and its bar
- Arrows: Docks the panel from its head, or moves between the tools in its bar or its dock
- Enter: Picks the tool, or folds the panel from its foot

## API reference

### CanvasPanel

- `label` (`string`, required): Its name for assistive technology, in the product's words ("Tools").
- `sheet` (`boolean`, default `false`): Drawn as a sheet over the plane.
- `dock` (`boolean`, default `false`): Stands as the plane's dock: the tools alone, one row of icon buttons at the bottom centre of the canvas, with the body above them. A dock takes no head and no fold, no drag and no sheet at any width: the plane pins it while the canvas moves under it. Default: the side panel.
- `place` (`{ side: "left" | "right"; anchor: "top" | "bottom"; collapsed?: boolean }`): Where it stands. A product keeps it; the part stores nothing when the prop is given.
- `defaultPlace` (`{ side: "left" | "right"; anchor: "top" | "bottom"; collapsed?: boolean }`, default `DEFAULT_PANEL`)
- `onPlaceChange` (`(place: CanvasPanelPlace) => void`)
- `tools` (`readonly CanvasTool[]`): The tools its bar offers, in the bar's order; with one or none the bar draws no choice. Default: all six.
- `tool` (`"select" | "hand" | "comment" | "draw" | "xray" | "design"`): The plane's tools: the bar's choices, and the state a product keeps.
- `defaultTool` (`"select" | "hand" | "comment" | "draw" | "xray" | "design"`, default `"select"`): The plane's tools: the bar's choices, and the state a product keeps.
- `onToolChange` (`(tool: CanvasTool) => void`)
- `fill` (`boolean`, default `false`): The body fills the panel and scrolls on its own (a thread's list with its field at its foot): the open panel stands at its greatest height, the body does not scroll, and its one child is stretched to the height the head and the bar leave. Without it the body scrolls as one column. Design owns its own scrollport.
- `toolBodies` (`Partial<Readonly<Record<CanvasTool, ReactNode>>>`): A tool's own body, which stands in place of `children` while that tool is in hand: Design mode's controls. A collapsed panel opens when a tool with a body of its own is taken up.
- `rootStyle` (`CanvasPanelStyle`)
- `children` (`ReactNode`): Its body: a comment panel, Facts of what is selected.
