Scenic.Components.radio_group

You're seeing just the function radio_group, go back to Scenic.Components module for more information.
Link to this function

radio_group(graph, data, options \\ [])

View Source

Specs

radio_group(
  source :: Scenic.Graph.t() | Scenic.Primitive.t(),
  data :: [{String.t(), any()} | {String.t(), any(), boolean()}],
  options :: list()
) :: Scenic.Graph.t() | Scenic.Primitive.t()

Add a RadioGroup to a graph

Data

{radio_buttons, selected_id}

  • radio_buttons must be a list of radio button data. See below.

Radio button data:

{text, radio_id}

  • text - must be a bitstring
  • radio_id - can be any term you want. It will be passed back to you as the group's value.

Messages

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}

Options

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}.

Styles

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

Theme

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

Examples

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

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