Close Button
v0.0.10
mix mishka.ui.gen.headless close_button
Wiring the click
The button has no handler of its own. Add one through the global attributes: a phx-click event for the LiveView, or a Phoenix.LiveView.JS command that hides the element in the browser.
<.close_button label="Close dialog" phx-click="close_dialog" />
<.close_button label="Dismiss alert" phx-click={JS.hide(to: "#saved-alert")} />Attributes and parts
label is the aria-label and defaults to "Close". disabled sets the native attribute and data-disabled. class styles the button, with the base class chelekom-close-button. icon_class styles the built-in ✕ only, because that span is not rendered once you pass your own icon. id is optional, and other global attributes such as phx-click are passed to the button.
Accessibility
The close button follows the WAI-ARIA Button pattern. Enter and Space activate it. The built-in ✕ is hidden from assistive technology with aria-hidden="true", so the label is the only name announced. Hide your own icon the same way when it is decorative.
Attributes
| Name | Type | Default | Values | Required | Description |
|---|---|---|---|---|---|
id
|
string
| — | — | No | Optional unique id |
label
|
string
|
Close
| — | No | Accessible label (aria-label) for the icon-only button |
disabled
|
boolean
|
false
| — | No | Disable the button (also sets data-disabled) |
class
|
any
| — | — | No | Extra classes for the button |
icon_class
|
any
| — | — | No | — |
rest
|
global
| — | — | No | Any button/global attrs, e.g. phx-click |
Slots
| Name | Required | Description |
|---|---|---|
inner_block
| No | Custom icon; falls back to a built-in ✕ when empty |
Options
Each option takes one or more of its values, separated by commas.
| Option | Values |
|---|---|
--type
|
close_button
|
--module
| A module name of your own |
What it generates
mix mishka.ui.gen.headless close_button