Corex.Action (Corex v0.1.0-rc.1)

View Source

Renders a button element for actions based on Phoenix Core Components. Use the type attribute to set the button type. Icon-only buttons must pass aria_label to screen readers.

Anatomy

<.action class="button">Send!</.action>

<.action class="button" phx-click="go">Send!</.action>

<.action class="button" type="submit">Save</.action>

<.action class="button" aria_label="Close dialog">
  <.heroicon name="hero-x-mark" aria-hidden="true" />
</.action>

Style

Import tokens and button.css, then set class="button" on <.action>.

@import "../corex/main.css";
@import "../corex/tokens/themes/neo/light.css";
@import "../corex/components/button.css";

Stack modifiers on the host.

Color

ModifierClasses
Defaultbutton
Accentbutton button--accent
Brandbutton button--brand
Alertbutton button--alert
Infobutton button--info
Successbutton button--success

Size

ModifierClasses
SMbutton button--sm
MDbutton button--md
LGbutton button--lg
XLbutton button--xl

Rounded

Use Tailwind rounded-* utilities on the host (for example class="button rounded-xl").

ModifierClasses
Nonebutton rounded-none
SMbutton rounded-sm
MDbutton rounded-md
LGbutton rounded-lg
XLbutton rounded-xl
Fullbutton rounded-full

Summary

Components

action(assigns)

Attributes

  • type (:string) - The button type, defaults to button to prevent accidental form submissions. Defaults to "button". Must be one of "button", "submit", or "reset".
  • aria_label (:string) - Required for icon-only buttons, describes the button to screen readers. Defaults to nil.
  • disabled (:boolean) - Disables the button. Defaults to false.
  • name (:string) - Form input name for submit buttons. Defaults to nil.
  • value (:string) - Form input value for submit buttons. Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)