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%{}.phoenix_kit_current_scope(:any) - Defaults tonil.phoenix_kit_current_user(:any) - Defaults tonil.page_title(:string) - Defaults tonil.current_path(:string) - Defaults tonil.inner_content(:string) - Defaults tonil.project_title(:string) - Defaults to"PhoenixKit".current_locale(:string) - Defaults tonil.
Slots
inner_block