# `Plushie.Widget.PaneGrid`
[🔗](https://github.com/plushie-ui/plushie-elixir/blob/v0.7.2/lib/plushie/widget/pane_grid.ex#L16)

Pane grid, resizable tiled panes.

Children are keyed by their node ID and rendered as individual panes.
The renderer manages an internal `pane_grid::State` cache.

## Accessibility

The pane grid itself does not expose a semantic role to assistive
technology. To make the grid navigable by screen readers, wrap it
in a `container` with an explicit role and label:

    container "editor-panes" do
      a11y do
        role :group
        label "Editor panes"
      end

      pane_grid "grid", panes: ["left", "right"] do
        text_input "left", model.left
        text_input "right", model.right
      end
    end

Individual panes can carry their own `a11y` annotations for
further context (e.g., `label` describing each pane's purpose).
The `pane_focus_cycle` event (F6/Shift+F6) provides keyboard
navigation between panes.

## Props

| Name | Type | Default | Description |
|------|------|---------|-------------|
| `panes` | `[String.t() \| atom()]` | `nil` | List of pane identifiers. |
| `spacing` | `number()` | `nil` | Space between panes in pixels. Default: 2. |
| `width` | `:fill \| :shrink \| {:fill_portion, pos_integer()} \| number()` | `nil` | Grid width. Default: fill. |
| `height` | `:fill \| :shrink \| {:fill_portion, pos_integer()} \| number()` | `nil` | Grid height. Default: fill. |
| `min_size` | `number()` | `nil` | Minimum pane size in pixels. Default: 10. |
| `divider_color` | `String.t()` | `nil` | Color for the split divider. |
| `divider_width` | `number()` | `nil` | Divider thickness in pixels. |
| `leeway` | `number()` | `nil` | Grabbable area around dividers in pixels. |
| `split_axis` | `:horizontal \| :vertical` | `nil` | Split axis for initial layout. |
| `event_rate` | `integer()` | `nil` | Max events per second for coalescable events. |
| `a11y` | `%Plushie.Type.A11y{} \| map() \| keyword()` | `%{role: :group}` | Accessibility annotations. |

## Events

| Event | Type | Description |
|-------|------|-------------|
| `:pane_clicked` | none | Emitted when a pane is selected. |
| `:pane_resized` | `value: %{split: String.t() \| atom(), ratio: number()}` | Emitted when a split divider is moved. |
| `:pane_dragged` | none | Emitted during pane drag operations. |
| `:pane_focus_cycle` | none | Emitted on F6/Shift+F6 focus cycling. |

# `option`

```elixir
@type option() ::
  ((((((((({:panes, [String.t() | atom()]} | {:spacing, number()})
          | {:width,
             :fill | :shrink | {:fill_portion, pos_integer()} | number()})
         | {:height,
            :fill | :shrink | {:fill_portion, pos_integer()} | number()})
        | {:min_size, number()})
       | {:divider_color, atom() | String.t() | map()})
      | {:divider_width, number()})
     | {:leeway, number()})
    | {:split_axis, :horizontal | :vertical})
   | {:event_rate, integer()})
  | {:a11y,
     %Plushie.Type.A11y{
       active_descendant: term(),
       busy: term(),
       described_by: term(),
       description: term(),
       disabled: term(),
       error_message: term(),
       expanded: term(),
       has_popup: term(),
       hidden: term(),
       invalid: term(),
       label: term(),
       label_from: term(),
       labelled_by: term(),
       level: term(),
       live: term(),
       mnemonic: term(),
       modal: term(),
       orientation: term(),
       position_in_set: term(),
       radio_group: term(),
       read_only: term(),
       required: term(),
       role: term(),
       selected: term(),
       size_of_set: term(),
       toggled: term(),
       value: term()
     }
     | map()
     | keyword()}
```

# `t`

```elixir
@type t() :: %Plushie.Widget.PaneGrid{
  a11y:
    (%Plushie.Type.A11y{
       active_descendant: term(),
       busy: term(),
       described_by: term(),
       description: term(),
       disabled: term(),
       error_message: term(),
       expanded: term(),
       has_popup: term(),
       hidden: term(),
       invalid: term(),
       label: term(),
       label_from: term(),
       labelled_by: term(),
       level: term(),
       live: term(),
       mnemonic: term(),
       modal: term(),
       orientation: term(),
       position_in_set: term(),
       radio_group: term(),
       read_only: term(),
       required: term(),
       role: term(),
       selected: term(),
       size_of_set: term(),
       toggled: term(),
       value: term()
     }
     | map()
     | keyword())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  children: [Plushie.Widget.ui_node()],
  divider_color:
    String.t()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  divider_width:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  event_rate:
    integer()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  height:
    (:fill | :shrink | {:fill_portion, pos_integer()} | number())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  id: String.t(),
  leeway:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  min_size:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  panes:
    [String.t() | atom()]
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  spacing:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  split_axis:
    (:horizontal | :vertical)
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  width:
    (:fill | :shrink | {:fill_portion, pos_integer()} | number())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil
}
```

# `a11y`

```elixir
@spec a11y(
  widget :: t(),
  value ::
    (%Plushie.Type.A11y{
       active_descendant: term(),
       busy: term(),
       described_by: term(),
       description: term(),
       disabled: term(),
       error_message: term(),
       expanded: term(),
       has_popup: term(),
       hidden: term(),
       invalid: term(),
       label: term(),
       label_from: term(),
       labelled_by: term(),
       level: term(),
       live: term(),
       mnemonic: term(),
       modal: term(),
       orientation: term(),
       position_in_set: term(),
       radio_group: term(),
       read_only: term(),
       required: term(),
       role: term(),
       selected: term(),
       size_of_set: term(),
       toggled: term(),
       value: term()
     }
     | map()
     | keyword())
    | nil
) :: t()
```

Accessibility annotations.

Accepts `%Plushie.Type.A11y{} | map() | keyword()`.

# `build`

```elixir
@spec build(widget :: t()) :: Plushie.Widget.ui_node()
```

Converts this widget struct to a `ui_node()` map.

# `divider_color`

```elixir
@spec divider_color(widget :: t(), value :: (atom() | String.t() | map()) | nil) ::
  t()
```

Color for the split divider.

Accepts `String.t()`.

# `divider_width`

```elixir
@spec divider_width(widget :: t(), value :: number() | nil) :: t()
```

Divider thickness in pixels.

Accepts `number()`.

# `event_rate`

```elixir
@spec event_rate(widget :: t(), value :: integer() | nil) :: t()
```

Max events per second for coalescable events.

Accepts `integer()`.

# `extend`

```elixir
@spec extend(widget :: t(), children :: [Plushie.Widget.child()]) :: t()
```

Appends multiple children to the widget.

# `height`

```elixir
@spec height(
  widget :: t(),
  value :: (:fill | :shrink | {:fill_portion, pos_integer()} | number()) | nil
) :: t()
```

Grid height. Default: fill.

Accepts `:fill | :shrink | {:fill_portion, pos_integer()} | number()`.

# `leeway`

```elixir
@spec leeway(widget :: t(), value :: number() | nil) :: t()
```

Grabbable area around dividers in pixels.

Accepts `number()`.

# `min_size`

```elixir
@spec min_size(widget :: t(), value :: number() | nil) :: t()
```

Minimum pane size in pixels. Default: 10.

Accepts `number()`.

# `new`

```elixir
@spec new(id :: String.t(), opts :: [option()]) :: t()
```

Creates a new widget struct with the given ID and keyword options.

# `pane_grid`
*macro* 

Creates a `:pane_grid` widget.

Shorthand for `new/2`. Import this macro to use the widget name
directly in view functions:

    import Plushie.Widget.PaneGrid, only: [pane_grid: 2]

    pane_grid("my-id", prop: value)

# `panes`

```elixir
@spec panes(widget :: t(), value :: [String.t() | atom()] | nil) :: t()
```

Sets the list of pane identifiers. Atoms are coerced to strings.

# `push`

```elixir
@spec push(widget :: t(), child :: Plushie.Widget.child()) :: t()
```

Appends a child to the widget.

# `spacing`

```elixir
@spec spacing(widget :: t(), value :: number() | nil) :: t()
```

Space between panes in pixels. Default: 2.

Accepts `number()`.

# `split_axis`

```elixir
@spec split_axis(widget :: t(), value :: (:horizontal | :vertical) | nil) :: t()
```

Split axis for initial layout.

Accepts `:horizontal | :vertical`.

# `width`

```elixir
@spec width(
  widget :: t(),
  value :: (:fill | :shrink | {:fill_portion, pos_integer()} | number()) | nil
) ::
  t()
```

Grid width. Default: fill.

Accepts `:fill | :shrink | {:fill_portion, pos_integer()} | number()`.

# `with_options`

```elixir
@spec with_options(widget :: t(), opts :: [option()]) :: t()
```

Applies keyword options to an existing widget struct.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
