Zaid-Ajaj / Feliz

A fresh retake of the React API in Fable and a collection of high-quality components to build React applications in F#, optimized for happiness
https://zaid-ajaj.github.io/Feliz/
MIT License
544 stars 81 forks source link

Checkbox indeterminate state #502

Closed dsshep closed 2 years ago

dsshep commented 2 years ago

What is the correct way of setting a checkbox to an indeterminate state? There seems to be no logical way within the API. If there isn't, perhaps prop.isChecked should accept a Nullable<bool> or bool option to support this?

dsshep commented 2 years ago

No problem, figured it out. You need to use the ref callback, which may pass null, and you'll need to have open Fable.Core.JsInterop to use the ? dynamic syntax:

Html.input [
    prop.type' "checkbox"
    prop.ref (fun e ->
        if e = null then () else
        e?indeterminate <- (* set the bool state here... *))
]