miso
Copyright(C) 2016-2026 David M. Johnson
LicenseBSD3-style (see the file LICENSE)
MaintainerDavid M. Johnson <code@dmj.io>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Miso.Html.Property

Contents

Description

Overview

Miso.Html.Property provides smart constructors for DOM properties and HTML attributes. Each produces an Attribute that the virtual DOM applies to the corresponding DOM node on every render, diffing only changed values.

All names are suffixed with _ to avoid clashing with Haskell Prelude names. This module is re-exported in its entirety by Miso.Html and Miso.

Quick start

import Miso

view :: Model -> View Model Action
view m =
  div_ [ id_ "app", class_ "container" ]
    [ input_
        [ type_ "text"
        , value_ m.text
        , placeholder_ "Type here…"
        , disabled_
        ]
        []
    , img_
        [ src_ "logo.png", alt_ "Logo", width_ "64", height_ "64" ]
        []
    ]

Class management

Four combinators handle CSS classes:

class_    "foo bar"              -- single string, set className
className "foo bar"              -- alias for class_
classes_  ["foo", "bar"]         -- list of class names
classList_ [("active", isActive)  -- conditional classes
            ,("error",  hasError)]

Property groups

See also

Synopsis

Combinators

classes_ :: [MisoString] -> Attribute action Source #

Define multiple classes

div_ [ classes_ [ "red", "warning" ] ] []

classList_ :: [(MisoString, Bool)] -> Attribute action Source #

Define multiple classes conditionally

div_ [ classList_ [ ("empty", null items) ] [ ]

xmlns_ :: MisoString -> Attribute action Source #

Since: 1.9.0.0

aria_ :: MisoString -> MisoString -> Attribute action Source #

Since: 1.9.0.0

label_ :: MisoString -> Attribute action Source #

Since: 1.9.0.0

draggable_ :: Bool -> Attribute action Source #

Since: 1.9.0.0

frameborder_ :: MisoString -> Attribute action Source #

Since: 1.9.0.0

scrolling_ :: MisoString -> Attribute action Source #

Since: 1.9.0.0

tabindex_ :: MisoString -> Attribute action Source #

tabindex attribute

Since: 1.9.0.0