Provides prefix-aware link components for PhoenixKit navigation.
These components automatically apply the configured PhoenixKit URL prefix to paths, ensuring links work correctly regardless of the prefix configuration.
Why Use These Components?
PhoenixKit supports a configurable URL prefix (default: /phoenix_kit).
Using these components instead of hardcoded paths ensures your links
work correctly when the prefix changes.
Examples
# Instead of hardcoding:
<.link navigate="/phoenix_kit/dashboard">Dashboard</.link>
# Use pk_link for automatic prefix handling:
<.pk_link navigate="/dashboard">Dashboard</.pk_link>
# Works with all link types:
<.pk_link navigate="/admin/users">Users</.pk_link>
<.pk_link patch="/dashboard?tab=settings">Settings</.pk_link>
<.pk_link href="/api/export">Export</.pk_link>Configuration
The URL prefix is configured in your application:
config :phoenix_kit, url_prefix: "/my_prefix"
Summary
Functions
Renders a link with automatic PhoenixKit URL prefix handling.
Renders a button-styled link with automatic PhoenixKit URL prefix handling.
Functions
Renders a link with automatic PhoenixKit URL prefix handling.
This component wraps Phoenix's <.link> and automatically prepends
the configured PhoenixKit URL prefix to the path.
Attributes
navigate- The path for LiveView navigation (full page load within LiveView)patch- The path for LiveView patch (updates URL without full navigation)href- The path for standard HTTP navigationclass- CSS classes to applyreplace- When true, replaces browser history instead of pushing
Only one of navigate, patch, or href should be provided.
Examples
<.pk_link navigate="/dashboard">Dashboard</.pk_link>
<.pk_link navigate="/admin/users" class="btn btn-primary">
Manage Users
</.pk_link>
<.pk_link patch="/settings" replace={true}>
Settings
</.pk_link>Attributes
navigate(:string) - Path for LiveView navigate. Defaults tonil.patch(:string) - Path for LiveView patch. Defaults tonil.href(:string) - Path for standard href. Defaults tonil.class(:string) - Defaults tonil.replace(:boolean) - Defaults tofalse.- Global attributes are accepted. Supports all globals plus:
["download", "hreflang", "referrerpolicy", "rel", "target", "type"].
Slots
inner_block(required)
Renders a button-styled link with automatic PhoenixKit URL prefix handling.
Convenience component that combines pk_link with button styling.
Examples
<.pk_link_button navigate="/dashboard">Dashboard</.pk_link_button>
<.pk_link_button navigate="/admin/users" variant="secondary">
Manage Users
</.pk_link_button>Attributes
navigate(:string) - Defaults tonil.patch(:string) - Defaults tonil.href(:string) - Defaults tonil.class(:string) - Defaults tonil.variant(:string) - Defaults to"primary". Must be one of"primary","secondary","ghost","link", or"outline".replace(:boolean) - Defaults tofalse.- Global attributes are accepted.
Slots
inner_block(required)