Search code examples
drop-down-menuf#defaultfable-f#elmish

How do I set a default Value in a dropdown menu in Fable Elmish?


i want to have a default value in the dropdown that isnt one of the choosable options (not: DefaultValue "2"). It should be something like the following but not for an input-field.

Input.Placeholder "Your name here" 

( i tried Placeholder in Select, but it didnt work)

Once you've opened the dropdown the default value should be listed the in grey and italic (or something like that). I've recognized i can't change the font settings within the option properties of the select menu.

Thanks

Select.select
[ ]
[ select
    [
        //DefaultValue "2"
    ]
    [
        option [ Value "1" ] [ str "1" ]
        option [ Value "2"] [ str "2" ]
        option [ Value "3"] [ str "3" ]
    ]
]

Solution

  • Try

    Select.select
    [ ]
    [ select
        [ ]
        [
            option [ Value ""; Disabled true; Selected true ] [ str "Your name here" ]
            option [ Value "1" ] [ str "1" ]
            option [ Value "2"] [ str "2" ]
            option [ Value "3"] [ str "3" ]
        ]
    ]