conditional-link component wraps content in a link only when certain conditions are met, such as user permissions. It’s particularly useful for displaying content that should only be clickable for authorized users.
Basic Usage
Permission-Based Links
Use thecan attribute to show links only for authorized users:
Model Binding
Automatically display model attribute values:Value Formatting
Status Enums
The component automatically detects status enums and displays them with colors:Multiline Text
Display text with line breaks preserved:Array Values
Arrays are automatically joined with a separator:Custom Content
Override default rendering with slot content:Attributes
The URL to link to when the link is shown
The model attribute name to display when no value is provided
Explicitly control whether to show the link. When null, uses the
can attribute to determine visibilityThe permission to check. Link is only shown if the user has this permission
Arguments to pass to the permission check (typically the model instance)
The authentication guard to use for permission checking
The value to display. If null, uses the bound value from the model
The model instance to extract values from when using the
name attributeWhether to preserve line breaks in the displayed text
The CSS framework to use for rendering
Display Logic
The component follows this rendering logic:- If slot content is provided, it’s displayed
- If the value is an AdminModel, displays
admin_link_name - If the value is a status enum, renders as a status badge with color
- If
multilineis true, preserves line breaks - If the value is an array, joins elements with a separator
- Otherwise, formats the value using default formatting