A2UI.Component (A2UI v0.3.0)

Copy Markdown View Source

A single UI component in an A2UI surface.

Components are the building blocks of A2UI surfaces. Each has a unique id, a type (from the standard catalog or custom), and type-specific properties.

Standard component types

Layout:

  • :row — horizontal layout
  • :column — vertical layout
  • :list — scrollable list with item template

Display:

  • :text — text content
  • :image — image display
  • :icon — icon
  • :video — video player
  • :divider — visual separator

Interactive:

  • :button — clickable button
  • :text_field — text input
  • :checkbox — boolean toggle
  • :date_time_input — date/time picker
  • :slider — range slider
  • :choice_picker — selection from options

Display (continued):

  • :audio_player — audio playback

Container:

  • :card — grouped content
  • :tabs — tabbed sections
  • :modal — overlay dialog

Examples

%A2UI.Component{
  id: "greeting",
  type: :text,
  properties: %{text: %A2UI.BoundValue{literal: "Hello, world!"}}
}

%A2UI.Component{
  id: "submit",
  type: :button,
  properties: %{
    label: %A2UI.BoundValue{literal: "Submit"},
    action: %A2UI.Action{name: "submit_form"}
  }
}

Summary

Functions

Returns true if the given type is a standard A2UI component type.

Returns the list of standard A2UI component types.

Types

component_type()

@type component_type() ::
  :row
  | :column
  | :list
  | :text
  | :image
  | :icon
  | :video
  | :divider
  | :button
  | :text_field
  | :checkbox
  | :date_time_input
  | :slider
  | :choice_picker
  | :audio_player
  | :card
  | :tabs
  | :modal
  | {:custom, atom()}

t()

@type t() :: %A2UI.Component{
  id: String.t(),
  properties: map(),
  type: component_type()
}

Functions

standard_type?(type)

@spec standard_type?(atom()) :: boolean()

Returns true if the given type is a standard A2UI component type.

standard_types()

@spec standard_types() :: [atom()]

Returns the list of standard A2UI component types.