intrepidshape/elm-web3-ui/2.1.1

NOTE: the latest version is 4.0.0

Web3.Ui.ChainSelector

Pick a chain from the set your dapp supports, wired to the switch-chain flow.

ChainSelector.view
    { entries =
        [ { chainId = 369, label = "PulseChain" }
        , { chainId = 1, label = "Ethereum" }
        ]
    , current = Wallet.getChainId model.wallet |> Maybe.map T.chainIdToInt
    , onSelect = SwitchChainTo   -- then: web3Cmd (Wallet.encode (Wallet.switchChain …))
    }

Selecting an entry is a request — render the truth from Wallet.State, never optimistically: the pill only moves when SwitchChainOk / ChainChanged actually arrives. Chains the wallet doesn't know yet are the Wallet.addChain (EIP-3085) flow; fire it from your onSelect handler when the switch errors.

Rendered as a role="radiogroup" of buttons — keyboard and screen-reader native.

CSS classes: web3-chains, web3-chains__option, web3-chains__option--current.

view : List (Attribute msg) -> Config msg -> Html msg

Render the selector.

type alias Config msg =
{ entries : List Entry
, current : Maybe Int
, onSelect : Int -> msg
}

The supported set, the currently-connected chain id (if any), and the switch request handler.

type alias Entry =
{ chainId : Int
, label : String
}

One selectable chain.