Dynamic layout wrapper component for Phoenix v1.7- and v1.8+ compatibility.
This component automatically detects the Phoenix version and layout configuration to provide seamless integration with parent applications while maintaining backward compatibility.
Usage
Replace direct layout calls with the wrapper:
<%!-- OLD (Phoenix v1.7-) --%>
<%!-- Templates relied on router-level layout config --%>
<%!-- NEW (Phoenix v1.8+) --%>
<PhoenixKitWeb.Components.LayoutWrapper.app_layout flash={@flash}>
<%!-- content --%>
</PhoenixKitWeb.Components.LayoutWrapper.app_layout>Configuration
Configure parent layout in config.exs:
config :phoenix_kit,
layout: {MyAppWeb.Layouts, :app}
Summary
Functions
Renders content with the appropriate layout based on configuration and Phoenix version.
Functions
Renders content with the appropriate layout based on configuration and Phoenix version.
Automatically handles:
- Phoenix v1.8+ function component layouts
- Phoenix v1.7- legacy layout configuration
- Fallback to PhoenixKit layouts when no parent configured
- Parent layout compatibility with PhoenixKit assigns
Attributes
flash- Flash messages (required)phoenix_kit_current_scope- Current authentication scope (optional)phoenix_kit_current_user- Current user (optional, for backwards compatibility)
Inner Block
inner_block- Content to render within the layout
Attributes
flash(:map) - Defaults to%{}.socket(:any) - Defaults tonil.phoenix_kit_current_scope(:any) - Defaults tonil.phoenix_kit_current_user(:any) - Defaults tonil.page_title(:string) - Defaults tonil.page_subtitle(:string) - Defaults tonil.page_section(:string) - Optional breadcrumb segment rendered between "Admin Panel" andpage_title(e.g. "Users" on a user detail page). Desktop only — collapses along with the rest of the breadcrumb prefix on mobile. Defaults tonil.page_section_path(:string) - Prefixed path (viaPhoenixKit.Utils.Routes.path/1) thepage_sectioncrumb links to. Renders as plain text when omitted. Defaults tonil.page_action(:map) - Optional compact action button rendered right after the breadcrumb title:%{icon: "hero-plus", label: "New template", navigate: path}. Lets a page keep its primary create action without spending an in-content header row.labelbecomes the tooltip/aria-label;icondefaults to hero-plus. Defaults tonil.current_path(:string) - Defaults tonil.inner_content(:string) - Defaults tonil.project_title(:string) - Defaults tonil.current_locale(:string) - Defaults tonil.from_layout(:boolean) - Defaults tofalse.pk_pending_invitations(:list) - Defaults to[].module_assigns(:map) - Module-supplied host-consumable assigns. Each key in this map is merged into the assigns set passed to the parent layout (Layouts.app), so a host's custom layout can read e.g.assigns[:phoenix_kit_publishing_translations]from publishing, or any other module-defined key. Plainconn.assignsdon't reach a function-component layout — only declared attrs do — so this single map attribute is how modules thread arbitrary host-consumable data through the boundary without core having to declare each one explicitly. Defaults to%{}.
Slots
inner_block