Action Icon
v0.0.10
mix mishka.ui.gen.headless action_icon
Overview of the Phoenix and LiveView Headless Action Icon Component
The Mishka Chelekom Headless Action Icon is an icon-only button for Phoenix and LiveView templates. It renders one button and no styling. A button with no visible text needs a name, so label is required and becomes its aria-label. The icon, an SVG or a glyph, goes in the default slot.
disabled sets the native disabled attribute and a data-disabled attribute, so you can style the state with data-[disabled]: variants. type is button by default and accepts submit and reset. There are no inner parts: style the root through class. It also carries a stable chelekom-action-icon class. For a button with a text label, a loading state or link behavior, use the headless Button.
Click handling and forms
Events go through the global attributes. Put phx-click, phx-value-* or a JS command straight on the component. form, name and value are accepted too, so an action icon with type="submit" can submit a form it does not sit inside.
<.action_icon
label="Delete invoice"
phx-click="delete"
phx-value-id={invoice.id}
class="rounded-md p-2 hover:bg-neutral-100"
>
<.icon name="hero-trash" class="size-5" />
</.action_icon><.action_icon label="Save changes" type="submit" form="settings-form" class="rounded-md p-2 hover:bg-neutral-100">
<.icon name="hero-check" class="size-5" />
</.action_icon>Parts & data attributes
The root is a button with aria-label, disabled and data-disabled. The slot content is rendered directly inside it, with no wrapper element.
Accessibility
Follows the WAI-ARIA Button pattern: Enter and Space activate the button, and label is its accessible name. A disabled action icon uses the native attribute, so it leaves the tab order and does not fire clicks.
Attributes
| Name | Type | Default | Values | Required | Description |
|---|---|---|---|---|---|
id
|
string
| — | — | No | Optional unique id |
label
|
string
| — | — | Yes | Accessible label (aria-label) |
type
|
string
|
button
|
buttonsubmitreset
| No | Button type (submit to act as a form's submit button) |
disabled
|
boolean
|
false
| — | No | Disable the button (also sets data-disabled) |
class
|
any
| — | — | No | Extra classes |
rest
|
global
| — | — | No | Any button/global attrs, e.g. phx-click |
Slots
| Name | Required | Description |
|---|---|---|
inner_block
| Yes | The icon (SVG or glyph) |
Options
Each option takes one or more of its values, separated by commas.
| Option | Values |
|---|---|
--type
|
action_icon
|
--module
| A module name of your own |
What it generates
mix mishka.ui.gen.headless action_icon