
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
elm-dom-ports
Advanced tools
Interface with the DOM manually in Elm.
It's popular at the moment to build web apps solely as "Single Page Apps", wherein a JavaScript application completely takes over the DOM. However, this isn't always the best solution. When you're just toggling a class to show/hide a menu, it may be overkill to use a Virtual DOM solution.
In this scenario, Elm Dom Ports exposes much of the underlying JavaScript DOM API, enabling you to manually modify the DOM using Elm. This empowers you to bring interactivity to your app in a jQuery-style manner, while adding the safety of Elm.
$ npm install --save elm-dom-ports
elm-package.json, import Ports/Dom.elmAdd node_modules/elm-dom-ports/lib/elm to your source-directories:
// elm-package.json
{
// ...
"source-directories": [
"../../node_modules/elm-dom-ports/lib/elm",
"./"
],
// ...
}
update msg model =
case msg of
OpenMenu ->
( model
, Ports.Dom.addClass ("#mobile_menu", "mobile-menu--opened")
)
CloseMenu ->
( model
, Ports.Dom.removeClass ("#mobile_menu", "mobile-menu--opened")
)
FocusOnSearchBox ->
( model
, Ports.Dom.focus "#search_box"
)
PopulateSearchBox searchQuery ->
( model
, Ports.Dom.setProperty ("#search_box", "value", Json.Encode.string searchQuery)
)
HideContactForm ->
( model
, Ports.Dom.setCssProperty ("#contact_form", "visibility", "hidden")
)
var domPorts = require('elm-dom-ports');
elmRouter.start(Elm, [domPorts]);
var domPorts = require("elm-dom-ports");
var myApp = Elm.MyApp.embed(document.getElementById("app-container"));
domPorts.register(myApp.ports);
View the full API reference here.
Feel free to create an issue in the GitHub issue tracker.
FAQs
Generic Elm ports for interacting with the DOM
We found that elm-dom-ports demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.