Links
Easily create links, live patches or live redirects (will become deprecated - read alert below).
As of Petal Components 0.18, we have renamed `link/1` to `a/1` to make way for Live View 0.18's new `link/1`. Please try and use the official `link/1` as we will eventually deprecate `a/1`.
Types
<.a to="/" class="" label="Link" />
<.a link_type="live_patch" to="/" class="" label="Link" />
<.a link_type="live_redirect" to="/" class="" label="Link" />
<!-- We use Phoenix.HTML.Link.link() -->
<.a to="/" method="put" class="" label="Link" />
Under the hood we use the functions:
- Phoenix.HTML.Link.link/2
- import Phoenix.Component.live_patch/2
- import Phoenix.Component.live_redirect/2
All props are forwarded to these functions so you can do something like this:
<.a to="/logout" method={:delete} class="" label="Logout" />
Properties
Defaults are indicated in bold.
Name | Type | Options |
---|---|---|
label | :string | - |
class | :string | - |
link_type | :string |
a
, `live_patch`, `live_redirect`, `button`
|
inner_block | :slot | - |
[all additional properties] |
Will be forwarded to all
link HTML elements.
|