Anchor
v0.0.10
mix mishka.ui.gen.headless anchor
Overview of the Phoenix and LiveView Headless Anchor Component
The Mishka Chelekom Headless Anchor is a Phoenix function component for links. It renders a plain <a> from href, or a LiveView <.link> when you pass navigate or patch. Link attributes such as target, rel, download and replace, along with aria-* and phx-* attributes, pass through to the element.
The anchor has no parts and no data states. The link always carries the class chelekom-anchor, next to the classes you pass in class, so color, underline, hover and focus styles are Tailwind utilities on the link itself.
Base UI Anchor example - a themed inline link (Phoenix headless)
<p class="text-sm text-neutral-700 dark:text-neutral-300">
Built with
<.anchor
href="https://phoenixframework.org"
target="_blank"
rel="nofollow noopener"
class="font-medium text-blue-600 underline underline-offset-2 hover:no-underline dark:text-blue-400"
>Phoenix</.anchor>.
</p>Accessibility
The anchor is a native link, so Enter follows it and screen readers announce it as a link, as described by the WAI-ARIA Link pattern. The component draws no focus ring, so keep one with focus-visible: utilities. If a link opens a new tab, say so in the link text.
Attributes
| Name | Type | Default | Values | Required | Description |
|---|---|---|---|---|---|
id
|
string
| — | — | No | Optional unique id |
navigate
|
string
| — | — | No | Navigates to another LiveView |
patch
|
string
| — | — | No | Patches the current LiveView |
href
|
string
| — | — | No | Link target |
class
|
any
| — | — | No | Extra classes |
rest
|
global
| — | — | No | Any anchor/global attrs (target, rel, phx-*, …) |
Slots
| Name | Required | Description |
|---|---|---|
inner_block
| Yes | The link text/content |
Options
Each option takes one or more of its values, separated by commas.
| Option | Values |
|---|---|
--type
|
anchor
|
--module
| A module name of your own |
What it generates
mix mishka.ui.gen.headless anchor