ensolabs/designsystemet-elm/1.0.0

Designsystemet.SkipLink

A link for keyboard users to jump past the header and navigation to the main content.

Mirrors SkipLink from @digdir/designsystemet-react.

Html.body []
    [ SkipLink.view { href = "#main-content" } [] [ Html.text "Hopp til hovedinnhold" ]
    , siteHeader
    , Html.main_ [ Attr.id "main-content", Attr.tabindex -1 ] [{- … -}]
    ]

It's invisible until focused, so put it first on the page where the first Tab reveals it.

React → Elm

  • <SkipLink href="#main">Hopp</SkipLink> → SkipLink.view { href = "#main" } [] [ … ]
{ href : String }
-> List (Attribute msg)
-> List (Html msg)
-> Html msg

An <a class="ds-skip-link"> to an element on the same page. href is "#" plus the target's id. Give the target tabindex="-1" so it can take focus.