PhoenixDuskmoon.Component.Form.Select (PhoenixDuskmoon v7.2.1)

View Source

Select dropdown component for single selection.

Examples

<.dm_form for={@form} phx-submit="save">
  <.dm_select field={@form[:country]} label="Country" options={country_options()} />
  <.dm_select field={@form[:priority]} label="Priority" options={priority_options()} color="warning" />
</.dm_form>

<!-- With option groups -->
<.dm_select field={@form[:category]} label="Category">
  <option value="">Select a category</option>
  <optgroup label="Fruits">
    <option value="apple">Apple</option>
    <option value="orange">Orange</option>
  </optgroup>
  <optgroup label="Vegetables">
    <option value="carrot">Carrot</option>
    <option value="broccoli">Broccoli</option>
  </optgroup>
</.dm_select>

Attributes

  • field - Phoenix form field
  • label - Select label text
  • options - List of {value, label} tuples or keyword list
  • prompt - Placeholder text for empty selection
  • size - Select size: xs, sm, md, lg (default: md)
  • color - Select color: primary, secondary, accent, info, success, warning, error (default: primary)
  • disabled - Disable the select
  • multiple - Enable multiple selection
  • class - Additional CSS classes
  • label_class - Additional CSS classes for label
  • select_class - Additional CSS classes for select element

Summary

Functions

dm_select(assigns)

Attributes

  • id (:any) - Defaults to nil.
  • name (:any)
  • value (:any)
  • field (Phoenix.HTML.FormField) - a form field struct retrieved from the form.
  • label (:string) - Defaults to nil.
  • options (:list) - Defaults to nil.
  • prompt (:string) - Defaults to nil.
  • size (:string) - Defaults to "md". Must be one of "xs", "sm", "md", or "lg".
  • color (:string) - Defaults to "primary". Must be one of "primary", "secondary", "accent", "info", "success", "warning", or "error".
  • disabled (:boolean) - Defaults to false.
  • multiple (:boolean) - Defaults to false.
  • class (:string) - Defaults to nil.
  • label_class (:string) - Defaults to nil.
  • select_class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block