VikWeb.CoreComponents (Vik v0.0.1-rc2)

View Source

Provides core UI components.

Icons are provided by heroicons. See icon/1 for usage.

Summary

Functions

Renders a button.

Generates a generic error message.

Renders flash notices.

Shows the flash group with standard titles and content.

Renders a Heroicon.

Renders an input with label and error messages.

Renders a label.

Functions

button(assigns)

Renders a button.

Examples

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

Attributes

  • type (:string) - Defaults to nil.
  • class (:string) - Defaults to nil.
  • Global attributes are accepted. Supports all globals plus: ["disabled", "form", "name", "value"].

Slots

  • inner_block (required)

error(assigns)

Generates a generic error message.

Slots

  • inner_block (required)

flash(assigns)

Renders flash notices.

Examples

<.flash kind={:info} flash={@flash} />
<.flash kind={:info} phx-mounted={show("#flash")}>Welcome Back!</.flash>

Attributes

  • id (:string) - the optional id of flash container.
  • flash (:map) - the map of flash messages to display. Defaults to %{}.
  • title (:string) - Defaults to nil.
  • kind (:atom) - used for styling and flash lookup. Must be one of :info, or :error.
  • Global attributes are accepted. the arbitrary HTML attributes to add to the flash container.

Slots

  • inner_block - the optional inner block that renders the flash message.

flash_group(assigns)

Shows the flash group with standard titles and content.

Examples

<.flash_group flash={@flash} />

Attributes

  • flash (:map) (required) - the map of flash messages.
  • id (:string) - the optional id of flash container. Defaults to "flash-group".

hide(js \\ %JS{}, selector)

Same as Phoenix.LiveView.JS.hide/2.

Left here for backwards compatibility.

icon(assigns)

Renders a Heroicon.

Heroicons come in three styles – outline, solid, and mini. By default, the outline style is used, but solid and mini may be applied by using the -solid and -mini suffix.

Examples

<.icon name="hero-x-mark-solid" />
<.icon name="hero-arrow-path" />

Attributes

  • name (:string) (required)
  • class (:string) - Defaults to nil.

input(assigns)

Renders an input with label and error messages.

A Phoenix.HTML.FormField may be passed as argument, which is used to retrieve the input name, id, and values. Otherwise all attributes may be passed explicitly.

Examples

<.input field={@form[:email]} type="email" />
<.input name="my-input" errors={["oh no!"]} />

Attributes

  • id (:any) - Defaults to nil.
  • name (:any)
  • label (:string) - Defaults to nil.
  • value (:any)
  • type (:string) - Defaults to "text". Must be one of "text", or "hidden".
  • field (Phoenix.HTML.FormField) - a form field struct retrieved from the form, for example: @form[:email].
  • errors (:list) - Defaults to [].
  • Global attributes are accepted. Supports all globals plus: ["accept", "autocomplete", "capture", "cols", "disabled", "form", "list", "max", "maxlength", "min", "minlength", "multiple", "pattern", "placeholder", "readonly", "required", "rows", "size", "step"].

label(assigns)

Renders a label.

Attributes

  • for (:string) - Defaults to nil.

Slots

  • inner_block (required)

show(js \\ %JS{}, selector)

Same as Phoenix.LiveView.JS.show/2.

Left here for backwards compatibility.