PhoenixKit.Dashboard.Group (phoenix_kit v1.7.115)

Copy Markdown View Source

Struct representing a dashboard tab group.

Groups organize tabs in the dashboard sidebar. Each group has an ID, an optional label, and a priority for ordering.

Fields

  • id - Unique group identifier atom (e.g., :admin_main, :shop)
  • label - Optional display label (nil for unlabeled groups)
  • priority - Sort priority (lower = first, default: 100)
  • icon - Optional heroicon name (e.g., "hero-cube")
  • collapsible - Whether the group can be collapsed in the sidebar
  • gettext_backend - Optional Gettext backend module for label translation (default: nil)
  • gettext_domain - Gettext domain for translation lookups (default: "default")

Summary

Functions

Returns the group's label, translated via the configured gettext backend if one is set.

Creates a new group from a map or keyword list.

Types

t()

@type t() :: %PhoenixKit.Dashboard.Group{
  collapsible: boolean(),
  gettext_backend: module() | nil,
  gettext_domain: String.t(),
  icon: String.t() | nil,
  id: atom(),
  label: String.t() | nil,
  priority: integer()
}

Functions

localized_label(group)

@spec localized_label(t()) :: String.t() | nil

Returns the group's label, translated via the configured gettext backend if one is set.

Falls back to the raw label string when:

  • gettext_backend is nil (default — no translation configured)
  • the label is nil (unlabeled groups)
  • gettext has no translation for the msgid (gettext's own fallback)

Reads gettext_backend and gettext_domain via Map.get/2 rather than pattern matching, so an old-shape struct cached in ETS or :persistent_term before the 1.8.0 upgrade — which lacks those keys entirely — gracefully falls back to the raw label instead of raising FunctionClauseError.

new(attrs)

@spec new(map() | keyword()) :: t()

Creates a new group from a map or keyword list.