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

Miso.CSS

Description

Module for constructing CSS styles and stylesheets in miso

Synopsis

Types

Smart Constructor

style_ :: [Style] -> Attribute action Source #

style_ is an attribute that will set the style attribute of the associated DOM node to attrs.

style attributes not contained in attrs will be deleted.

import qualified Data.Map as M
div_ [ style_ [ backgroundColor "red" ] [ ]

https://developer.mozilla.org/en-US/docs/Web/CSS

styleInline_ :: MisoString -> Attribute action Source #

Set "style" property

view m = div_ [ styleInline_ "background-color:red;color:blue;" ] [ "foo" ]

https://developer.mozilla.org/en-US/docs/Web/CSS

sheet_ :: [Styles] -> StyleSheet Source #

Smart constructor for StyleSheet

selector_ :: MisoString -> [Style] -> Styles Source #

Used when constructing a StyleSheet

sheet_
  [ selector_ ".name"
    [ backgroundColor red
    , alignContent "top"
    ]
  ]

Render

Combinators

Colors

Units

px :: Int -> MisoString Source #

Font sizing in terms of *px*

>>> px 10
"10px"

ppx :: Double -> MisoString Source #

ppx unit of measure

pt :: Int -> MisoString Source #

Font sizing in terms of *pt*

>>> pt 10
"10pt"

vw :: Double -> MisoString Source #

Viewport width

>>> vw 10.0
"10.0vw"

vh :: Double -> MisoString Source #

Viewport height

>>> vh 10.0
"10.0vh"

deg :: Double -> MisoString Source #

Degree specification

>>> deg 10
"10deg"

turn :: Double -> MisoString Source #

Turn constructor, useful for specifying rotations

>>> turn 10.0
"10.0turn"

rad :: Double -> MisoString Source #

Radial constructor

>>> rad 10.0
"10.0rad"

rpx :: Double -> MisoString Source #

Responsive pixel sizing, *rpx*

>>> rpx 10.0
"10.0rpx"

rem :: Double -> MisoString Source #

Relative *em* sizing

>>> rem 10.0
"10.0rem"

em :: Double -> MisoString Source #

  • em* sizing
>>> em 10.0
"10.0em"

s :: Double -> MisoString Source #

Duration in seconds

>>> s 10.0
"10.0s"

ms :: Double -> MisoString Source #

Duration in milliseconds

>>> ms 10.0
"10.0ms"

Misc

url :: MisoString -> MisoString Source #

CSS function for specifying a URL

>>> url "dog.png"
"url("dog.png")"

Animation

keyframes_ :: MisoString -> [(MisoString, [Style])] -> Styles Source #

https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes

testKeyFrame :: Styles
testKeyFrame = keyframes "slide-in"
  [ "from" =:
      [ transform "translateX(0%)"
      ]
  , "to" =:
      [ transform "translateX(100%)"
      , backgroundColor red
      , backgroundSize "10px"
      , backgroundRepeat "true"
      ]
  , pct 10 =:
    [ "foo" =: "bar"
    ]
 ]

Media Queries

media_ :: MisoString -> [(MisoString, [Style])] -> Styles Source #

https://developer.mozilla.org/en-US/docs/Web/CSS/@media

media_ "screen and (min-width: 480px)"
  [ "header" =:
      [ height "auto"
      ]
  , "ul" =:
      [ display "block"
      ]
  ]