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

Checkbox only uses strings as a display value #143

Closed milogert closed 5 years ago

milogert commented 5 years ago

I noticed that Bootstrap.Form.Checkbox.checkbox (and custom) only allows a String as a display value.

Is it possible to display html there? For instance, if I had a checkbox that was like

If it's not possible could this be added? Might be nice to have for situations like the above.

mordrax commented 5 years ago

I have the same problem. I'd like to do:

image

but because the checkbox is a block display, even if I put the bold href after it, it goes to the next line.

What I've done in my UI packages is to make the lbl a Html msg, ie:

type Checkbox msg
    = Checkbox
        { options : List (Option msg)
       --  , label : String
        , label : Html msg
        }

The consequence of this that it will break your API, and the callers won't be as nice:

-- currently
checkbox "I Agree to the terms" value msg

-- after
checkbox (Html.text "I agree to the terms") value msg

But at least then you can use custom for the latter cases and keep the simple case the same.

In the view, Html.text is simply removed:

view =
   ...
    -- [ Html.text chk.label ]
    [ chk.label ]

I'm happy to provide a PR if something like this aligns with the goals of the project.