DevactionUI.Segmented (devaction_ui v0.1.0)

Copy Markdown View Source

A control to pick one of a few options that change the view at once (list or board, week or month): a pill with a segment per option. It is a group of toggle buttons with aria-pressed; the caller keeps the value and learns of a choice through event (phx-value-value). A segment can have an icon, a count, or only an icon (the label is then read by assistive technology). full stretches it to the width of its box.

Summary

Functions

segmented(assigns)

Attributes

  • id (:string) (required)
  • label (:string) (required) - what the control chooses, for assistive technology.
  • value (:string) (required) - the value of the chosen option.
  • event (:string) (required) - the event sent with value when an option is pressed.
  • size (:atom) - Defaults to :md. Must be one of :sm, or :md.
  • full (:boolean) - Defaults to false.
  • class (:any) - Defaults to nil.
  • target (:any) - a phx-target (a @myself) when used inside a LiveComponent. Defaults to nil.
  • Global attributes are accepted.

Slots

  • option (required) - Accepts attributes:
    • value (:string) (required)
    • label (:string) (required)
    • count (:any)
    • icon_only (:boolean)
  • icon - the icon of an option; gets %{value: option value}.