rundis / elm-bootstrap

Responsive and reliable web apps with Elm and Twitter Bootstrap
http://elm-bootstrap.info/
BSD 3-Clause "New" or "Revised" License
398 stars 72 forks source link

Radio buttons using ... buttons? #168

Open David-Klemenc opened 4 years ago

David-Klemenc commented 4 years ago

This is not an issue ... more a question.

Bootsrap has a button group option that looks like this:

<div class="btn-group" role="group" aria-label="Basic example">
  <button type="button" class="btn btn-secondary">Left</button>
  <button type="button" class="btn btn-secondary">Middle</button>
  <button type="button" class="btn btn-secondary">Right</button>
</div>

Why not just use a button element for the radio button? Something like:

radioButton :
    Bool
    -> List (Html.Attribute msg)
    -> List (Html.Html msg)
    -> RadioButtonItem msg
radioButton checked options children =
    Html.button
        (Attr.classList [ ( "active", checked ) ] :: options )
        children
        |> RadioButtonItem

I think that the checkbox trick was used to store the state, that is manipulated with js?

Anyway, thank you for this library and have a nice day!