npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@curtissimo/elm-native-modal-dialog

v3.0.1

Published

Use the native <dialog> element in Elm instead of rolling your own.

Readme

elm-native-modal-dialog Build Status

Are you tired of using janky modal dialogs from UI packages like Bootstrap and Zurb Foundation?

Why not just use the HTML 5 <dialog> element? It's built into the browser, correctly handles the modal aspect of dialog-ness, and has a style-able backdrop using the ::backdrop pseudo-element.

"What about ports?"

"What about ports," you ask.

This package has no ports. It uses a custom Web component to forward and report events for the native <dialog> element so you don't need to worry about ports.

I like the declarative nature of this over the use of ports.

Examples

Check out the Simple example in ./examples.

Using Curtissimo.NativeModalDialog

This is two steps: include the Web component, then use the Elm package.

Install the Web component

You can do this in one of two ways.

Using your build process

If you're using a build process (Vite, Rollup, whatever) and you don't mind installing an NPM package, you can do that and import the JS file from the node_modules.

npm install @curtissimo/elm-native-modal-dialog

Then, import it in file to include it in the build.

import '@curtissimo/elm-native-modal-dialog/js/elm-dialog-proxy.js';

Just include it in your HTML

For you application, load the JavaScript file found at ./js/elm-dialog-proxy.js. It is Vanilla JavaScript, so you can just copy the file to your project and include it from a <script> tag or through a JavaScript build process.

Using the Elm package

You'll need something to let your Elm code know when to show the element.

type alias Model =
    { showDialog : Bool }

Then, you'll want a message to show the dialog and one to notify the page when the dialog has been closed.

type Msg
    = DialogClosed
    | ShowDialog

Your update function responds to those events and sets model.showDialog accordingly.

update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
    case msg of
        DialogClosed ->
            ( { model | showDialog = False }
            , Cmd.none
            )

        ShowDialog ->
            ( { model | showDialog = True }
            , Cmd.none
            )

Once you have that, you're ready to set up your view.

view : Model -> Html Msg
view model =
    let
        dialogOptions =
            { id = "my-dialog"
            , cancel = Dialog.allowDefault DialogClosed
            , close = DialogClosed
            , showDialog = model.showDialog
            }
    in
    Html.main_ []
        [ Dialog.view dialogOptions
            [ Html.form [ Html.Events.onSubmit DoSomething ]
                [ Html.header []
                    [ Html.h1 [] [ Html.text "My Dialog" ] ]
                , Html.section []
                    [ Html.p [] 
                        [ Html.text "This is in a <dialog>!" ]
                    , Html.p []
                        [ Html.text "You can hit the "
                        , Html.kbd [] [ Html.text "Esc" ]
                        , Html.text " key to cancel it"
                        ]
                    ]
                , Html.div []
                    [ Html.button []
                        [ Html.text "Submit" ]
                    , Html.button
                        [ Attrs.attribute "formmethod" "dialog" ]
                        [ Html.text "Close" ]
                    ]
                ]
            ]
        ]