I'm trying to set a type
attribute for input:
input [ type "checkbox" ] []
But I get an error:
It looks like the keyword `type` is being used as a variable. input [ type "checkbox" ] [] ^ Rename it to something else.
When I try to use
input [ type' "checkbox" ] []
I get this error:
Ran into a single quote in a variable name. This was removed in 0.18! input [ type' "checkbox" ] [] ^ Change it to a number or an underscore, like type_ or type1 Or better yet, choose a more descriptive name!
And if I try
input [ type_ "checkbox" ] []
I get another error:
Cannot find variable `type_` input [ type_ "checkbox" ] [] ^^^^^
So how could I finally set this attribute?
The correct function is indeed named type_
and is located in the Html.Attributes
module. Ensure that you are importing it correctly.
-- this exposed type_, checked, and value (as examples)
import Html.Attributes exposing (type_, checked, value)
-- alternatively, to expose everything,
import Html.Attributes exposing (..)
Looks like you are missing an import statement in your elm file, you can import just that attribute via
import Html.Attributes exposing (type_)
or, just import everything, like so
import Html.Attributes exposing (..)
then the example you posted would work.
input [ type_ "checkbox" ] []
What I Like to do when I am writing html in elm, and need to look something up, is use this site and in the top right I can just search for the thing I am looking for. Comes complete with examples even! :)
Happy Elming!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With