defmodule Corex.Action do @moduledoc ~S''' 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 ```heex <.action class="button">Send! <.action class="button" phx-click="go">Send! <.action class="button" type="submit">Save <.action class="button" aria_label="Close dialog"> <.heroicon name="hero-x-mark" aria-hidden="true" /> ``` ## Style Import tokens and `button.css`, then set `class="button"` on `<.action>`. ```css @import "../corex/main.css"; @import "../corex/tokens/themes/neo/light.css"; @import "../corex/components/button.css"; ``` Stack modifiers on the host. ### Color | Modifier | Classes | | -------- | ------- | | Default | `button` | | Accent | `button button--accent` | | Brand | `button button--brand` | | Alert | `button button--alert` | | Info | `button button--info` | | Success | `button button--success` | ### Size | Modifier | Classes | | -------- | ------- | | SM | `button button--sm` | | MD | `button button--md` | | LG | `button button--lg` | | XL | `button button--xl` | ### Rounded Use Tailwind `rounded-*` utilities on the host (for example `class="button rounded-xl"`). | Modifier | Classes | | -------- | ------- | | None | `button rounded-none` | | SM | `button rounded-sm` | | MD | `button rounded-md` | | LG | `button rounded-lg` | | XL | `button rounded-xl` | | Full | `button rounded-full` | ''' @doc type: :component use Phoenix.Component attr(:type, :string, default: "button", values: ["button", "submit", "reset"], doc: "The button type, defaults to button to prevent accidental form submissions" ) attr(:aria_label, :string, default: nil, doc: "Required for icon-only buttons, describes the button to screen readers" ) attr(:disabled, :boolean, default: false, doc: "Disables the button") attr(:name, :string, default: nil, doc: "Form input name for submit buttons") attr(:value, :string, default: nil, doc: "Form input value for submit buttons") attr(:rest, :global) slot(:inner_block, required: true) def action(assigns) do ~H""" """ end end