GPUI.UI.Overlay (gpui_components v0.2.0)

Copy Markdown View Source

Controlled overlay components backed by GPUI Component.

Overlay content is declared with ordinary HEEx named slots. Overlay state remains authoritative in Elixir assigns while native state preserves focus and dismissal behavior between snapshots.

Summary

Types

Options accepted by dialog/1.

Options accepted by popover/1.

Options accepted by tooltip/1.

Functions

Builds a controlled modal dialog with an optional :trigger and one :content slot.

Builds a controlled dropdown menu with one :trigger and one or more :item slots.

Builds a controlled popover with one :trigger and one :content slot.

Builds a native tooltip with one :trigger and one textual :content slot.

Types

dialog_options()

@type dialog_options() :: %{
  :id => String.t(),
  optional(:open) => boolean(),
  :title => String.t(),
  optional(:width) => number(),
  optional(:overlay) => boolean(),
  optional(:closable) => boolean(),
  optional(:keyboard) => boolean(),
  optional(:close_button) => boolean(),
  optional(:"phx-change") => String.t(),
  optional(:trigger) => [slot()],
  :content => [slot()],
  optional(:class) => String.t(),
  optional(:style) => keyword() | map()
}

Options accepted by dialog/1.

dropdown_menu_options()

@type dropdown_menu_options() :: %{
  :id => String.t(),
  :label => String.t(),
  optional(:open) => boolean(),
  optional(:anchor) => String.t(),
  optional(:disabled) => boolean(),
  optional(:"phx-change") => String.t(),
  optional(:"phx-select") => String.t(),
  :trigger => [slot()],
  :item => [slot()],
  optional(:class) => String.t(),
  optional(:style) => keyword() | map()
}

Options accepted by dropdown_menu/1.

popover_options()

@type popover_options() :: %{
  :id => String.t(),
  :label => String.t(),
  optional(:open) => boolean(),
  optional(:anchor) => String.t(),
  optional(:appearance) => boolean(),
  optional(:closable) => boolean(),
  optional(:"phx-change") => String.t(),
  :trigger => [slot()],
  :content => [slot()],
  optional(:class) => String.t(),
  optional(:style) => keyword() | map()
}

Options accepted by popover/1.

slot()

@type slot() :: %{attrs: keyword(), children: [GPUI.Element.child()]}

tooltip_options()

@type tooltip_options() :: %{
  :id => String.t(),
  optional(:delay) => number(),
  optional(:hoverable) => boolean(),
  :trigger => [slot()],
  :content => [slot()],
  optional(:class) => String.t(),
  optional(:style) => keyword() | map()
}

Options accepted by tooltip/1.

Functions

dialog(assigns)

@spec dialog(dialog_options()) :: GPUI.Element.t()

Builds a controlled modal dialog with an optional :trigger and one :content slot.

A non-empty title supplies the dialog heading and names its optional trigger. Changes to open are emitted through phx-change. The native dialog traps focus while open and restores the previous focus when it closes. Escape and overlay clicks request closure when enabled.

Options

OptionTypeRequiredDefault
:idString.t()yes—
:openboolean()nofalse
:titlenon-empty String.t()yes—
:widthnumber()no448.0
:overlayboolean()notrue
:closableboolean()notrue
:keyboardboolean()notrue
:close_buttonboolean()notrue
:"phx-change"non-empty event nameno—
:triggerzero or one named slotno—
:contentone named slotyes—
:classString.t()no—
:stylekeyword() or map()no—

popover(assigns)

@spec popover(popover_options()) :: GPUI.Element.t()

Builds a controlled popover with one :trigger and one :content slot.

A non-empty label names the trigger and its expanded state. Changes to open are emitted through phx-change. Escape and, by default, outside clicks request closure and restore focus to the trigger.

Options

OptionTypeRequiredDefault
:idString.t()yes—
:labelnon-empty String.t()yes—
:openboolean()nofalse
:anchor"top_left", "top_center", "top_right", "bottom_left", "bottom_center", "bottom_right", "left_center", "right_center"no"top_left"
:appearanceboolean()notrue
:closableboolean()notrue
:"phx-change"non-empty event nameno—
:triggerone named slotyes—
:contentone named slotyes—
:classString.t()no—
:stylekeyword() or map()no—

tooltip(assigns)

@spec tooltip(tooltip_options()) :: GPUI.Element.t()

Builds a native tooltip with one :trigger and one textual :content slot.

delay is the show delay in milliseconds from 0 through 60_000. Set hoverable when the pointer may move into the tooltip without dismissing it.

Options

OptionTypeRequiredDefault
:idString.t()yes—
:delaynumber()no500.0
:hoverableboolean()nofalse
:triggerone named slotyes—
:contentone named slotyes—
:classString.t()no—
:stylekeyword() or map()no—