Scenic.Component.Input.RadioGroup (Scenic v0.11.0-beta.0) View Source

Add a radio group to a graph

The data format for RadioGroup has changed since v0.10!


{radio_buttons, checked_id}

  • radio_buttons must be a list of radio button data. See below.
  • checked_id Is the id of the currently selected radio from the list.

radio_buttons list:

{text, radio_id}

  • text - must be a bitstring
  • button_id - can be any term you want. It will be passed back to you as the group's value.
  • checked? - must be a boolean and indicates if the button is selected. checked? is not required and will default to false if not supplied.

Example showing the full data format

{[{"One", :one}, {"Two", :two}, {"Three", :three}], :two}


When the state of the radio group changes, it sends an event message to the host scene in the form of:

{:value_changed, id, radio_id}


Radio Buttons honor the following list of options.

  • :theme - This sets the color scheme of the button. This can be one of pre-defined button schemes :light, :dark, or it can be a completely custom scheme like this: {text_color, box_background, border_color, pressed_color, checkmark_color}.


Radio Buttons honor the following styles

  • :hidden - If false the component is rendered. If true, it is skipped. The default is false.
  • :theme - The color set used to draw. See below. The default is :dark


Radio buttons work well with the following predefined themes: :light, :dark

To pass in a custom theme, supply a map with at least the following entries:

  • :text - the color of the text
  • :background - the background of the component
  • :border - the border of the component
  • :active - the background of the circle while the button is pressed
  • :thumb - the color of inner selected-mark


You should add/modify components via the helper functions in Scenic.Components


The following example creates a radio group and positions it on the screen.

|> radio_group({[
    {"Radio A", :radio_a},
    {"Radio B", :radio_b},
    {"Radio C", :radio_c},
  ], :radio_b}, 
  id: :radio_group_id, translate: {20, 20})

Link to this section Summary


Returns a specification to start this module under a supervisor.

Link to this section Functions

Link to this function

add_to_graph(graph, data, opts \\ [])

View Source

Callback implementation for Scenic.Component.add_to_graph/3.

Returns a specification to start this module under a supervisor.

See Supervisor.