| Copyright | (C) 2016-2026 David M. Johnson |
|---|---|
| License | BSD3-style (see the file LICENSE) |
| Maintainer | David M. Johnson <code@dmj.io> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Miso.CSS
Description
Overview
Miso.CSS is a typed DSL for constructing CSS properties, stylesheets, animations, and media queries in miso applications. Two styling modes are available:
- Structured styles (
style_): CSS properties are stored in aMapand diffed by the virtual DOM, so only changed properties are written to the DOM node on each render. Prefer this for dynamic styles. - Inline string styles (
styleInline_): a raw CSS string is set on thestyleattribute verbatim and is not diffed. Useful for static one-liners or values that the structured combinators do not yet cover.
Quick start
import qualified Miso.CSS as CSS import Miso.CSS.Color (red,rgba) myView ::ViewModel Action myView =div_[ CSS.style_[ CSS.display"flex" , CSS.flexDirection"column" , CSS.gap(CSS.px8) , CSS.padding(CSS.px16) , CSS.backgroundColorred, CSS.borderRadius(CSS.px4) ] ] [text"Hello, miso!" ]
Global Stylesheets
Construct a StyleSheet with sheet_ and selector_, then render it to
a MisoString with renderStyleSheet for injection into a <style> tag:
mySheet ::StyleSheetmySheet =sheet_[selector_"body" [ CSS.margin(CSS.px0) , CSS.fontFamily"sans-serif" ] ,selector_".card" [ CSS.backgroundColor(rgba255 255 255 0.9) , CSS.borderRadius(CSS.px4) ] ]
Animations and Media Queries
myAnimation ::StylesmyAnimation =keyframes_"slide-in" [from_[ CSS.transform"translateX(-100%)" ] ,to_[ CSS.transform"translateX(0)" ] ] myMedia ::StylesmyMedia =media_(screen_`and_`minWidth_(CSS.px480)) [rule_"header" [ CSS.height"auto" ] ,rule_"nav" [ CSS.display"flex" ] ]
CSS Units
Use the unit helpers to build length and time values:
px, pt, em, rem, vh, vw, pct, ms, s, deg, rad, turn.
CSS.style_[ CSS.width(CSS.pct100) , CSS.fontSize(CSS.rem1.5) , CSS.transition("opacity " <> CSS.ms300 <> " ease") ]
Colors
The Color type and named colors are re-exported from Miso.CSS.Color:
CSS.backgroundColor(CSS.rgb30 144 255) CSS.colorCSS.whiteCSS.borderColor(CSS.rgba0 0 0 0.2)
Note: color in this module and color share the same
name but have different types. Always qualify import qualified Miso.CSS as CSS
when also importing Miso.Canvas.
Synopsis
- module Miso.CSS.Types
- style_ :: [Style] -> Attribute action
- styleInline_ :: MisoString -> Attribute action
- sheet_ :: [Styles] -> StyleSheet
- selector_ :: MisoString -> [Style] -> Styles
- renderStyleSheet :: StyleSheet -> MisoString
- alignContent :: MisoString -> Style
- alignItems :: MisoString -> Style
- alignSelf :: MisoString -> Style
- animationDelay :: MisoString -> Style
- animationDirection :: MisoString -> Style
- animationDuration :: MisoString -> Style
- animationFillMode :: MisoString -> Style
- animationIterationCount :: MisoString -> Style
- animation :: MisoString -> Style
- animationName :: MisoString -> Style
- animationPlayState :: MisoString -> Style
- animationTimingFunction :: MisoString -> Style
- aspectRatio :: MisoString -> Style
- backgroundClip :: MisoString -> Style
- backgroundColor :: Color -> Style
- backgroundImage :: MisoString -> Style
- background :: MisoString -> Style
- backgroundOrigin :: MisoString -> Style
- backgroundPosition :: MisoString -> Style
- backgroundRepeat :: MisoString -> Style
- backgroundSize :: MisoString -> Style
- borderBottomColor :: Color -> Style
- borderBottomLeftRadius :: MisoString -> Style
- borderBottom :: MisoString -> Style
- borderBottomRightRadius :: MisoString -> Style
- borderBottomStyle :: MisoString -> Style
- borderBottomWidth :: MisoString -> Style
- borderCollapse :: MisoString -> Style
- borderColor :: Color -> Style
- borderEndEndRadius :: MisoString -> Style
- borderEndStartRadius :: MisoString -> Style
- borderInlineEndColor :: Color -> Style
- borderInlineEndStyle :: MisoString -> Style
- borderInlineEndWidth :: MisoString -> Style
- borderInlineStartColor :: Color -> Style
- borderInlineStartStyle :: MisoString -> Style
- borderInlineStartWidth :: MisoString -> Style
- borderLeftColor :: Color -> Style
- borderLeft :: MisoString -> Style
- borderLeftStyle :: MisoString -> Style
- borderLeftWidth :: MisoString -> Style
- border :: MisoString -> Style
- borderRadius :: MisoString -> Style
- borderRightColor :: Color -> Style
- borderRight :: MisoString -> Style
- borderRightStyle :: MisoString -> Style
- borderRightWidth :: MisoString -> Style
- borderStartEndRadius :: MisoString -> Style
- borderStartStartRadius :: MisoString -> Style
- borderStyle :: MisoString -> Style
- borderTopColor :: Color -> Style
- borderTopLeftRadius :: MisoString -> Style
- borderTop :: MisoString -> Style
- borderTopRightRadius :: MisoString -> Style
- borderTopStyle :: MisoString -> Style
- borderTopWidth :: MisoString -> Style
- borderWidth :: MisoString -> Style
- bottom :: MisoString -> Style
- boxShadow :: MisoString -> Style
- boxSizing :: MisoString -> Style
- clipPath :: MisoString -> Style
- accentColor :: Color -> Style
- appearance :: MisoString -> Style
- backdropFilter :: MisoString -> Style
- caretColor :: Color -> Style
- color :: Color -> Style
- columnGap :: MisoString -> Style
- cursor :: MisoString -> Style
- direction :: MisoString -> Style
- display :: MisoString -> Style
- fill :: Color -> Style
- filter :: MisoString -> Style
- flexBasis :: MisoString -> Style
- flexDirection :: MisoString -> Style
- flexFlow :: MisoString -> Style
- flexGrow :: Double -> Style
- flex :: MisoString -> Style
- flexShrink :: Double -> Style
- flexWrap :: MisoString -> Style
- fontFamily :: MisoString -> Style
- fontSize :: MisoString -> Style
- fontStretch :: MisoString -> Style
- fontStyle :: MisoString -> Style
- fontVariant :: MisoString -> Style
- fontWeight :: MisoString -> Style
- gap :: MisoString -> Style
- gridAutoColumns :: MisoString -> Style
- gridAutoFlow :: MisoString -> Style
- gridAutoRows :: MisoString -> Style
- gridColumn :: MisoString -> Style
- gridColumnEnd :: MisoString -> Style
- gridColumnSpan :: MisoString -> Style
- gridColumnStart :: MisoString -> Style
- gridRow :: MisoString -> Style
- gridRowEnd :: MisoString -> Style
- gridRowSpan :: MisoString -> Style
- gridRowStart :: MisoString -> Style
- gridTemplateColumns :: MisoString -> Style
- gridTemplateRows :: MisoString -> Style
- height :: MisoString -> Style
- imageRendering :: MisoString -> Style
- insetInlineEnd :: MisoString -> Style
- insetInlineStart :: MisoString -> Style
- justifyContent :: MisoString -> Style
- justifyItems :: MisoString -> Style
- justifySelf :: MisoString -> Style
- left :: MisoString -> Style
- letterSpacing :: MisoString -> Style
- linearCrossGravity :: MisoString -> Style
- linearDirection :: MisoString -> Style
- linearGravity :: MisoString -> Style
- linearLayoutGravity :: MisoString -> Style
- linearWeight :: MisoString -> Style
- linearWeightSum :: MisoString -> Style
- lineHeight :: MisoString -> Style
- marginBottom :: MisoString -> Style
- marginInlineEnd :: MisoString -> Style
- marginInlineStart :: MisoString -> Style
- marginLeft :: MisoString -> Style
- margin :: MisoString -> Style
- marginRight :: MisoString -> Style
- marginTop :: MisoString -> Style
- maskImage :: MisoString -> Style
- mask :: MisoString -> Style
- maxHeight :: MisoString -> Style
- maxWidth :: MisoString -> Style
- minHeight :: MisoString -> Style
- minWidth :: MisoString -> Style
- mixBlendMode :: MisoString -> Style
- objectFit :: MisoString -> Style
- objectPosition :: MisoString -> Style
- opacity :: Double -> Style
- order :: Int -> Style
- outline :: MisoString -> Style
- outlineColor :: Color -> Style
- outlineOffset :: MisoString -> Style
- outlineStyle :: MisoString -> Style
- outlineWidth :: MisoString -> Style
- overflow :: MisoString -> Style
- overflowX :: MisoString -> Style
- overflowY :: MisoString -> Style
- overscrollBehavior :: MisoString -> Style
- paddingBottom :: MisoString -> Style
- paddingInlineEnd :: MisoString -> Style
- paddingInlineStart :: MisoString -> Style
- paddingLeft :: MisoString -> Style
- padding :: MisoString -> Style
- paddingRight :: MisoString -> Style
- paddingTop :: MisoString -> Style
- perspective :: MisoString -> Style
- pointerEvents :: MisoString -> Style
- position :: MisoString -> Style
- relativeAlignBottom :: MisoString -> Style
- relativeAlignInlineEnd :: MisoString -> Style
- relativeAlignInlineStart :: MisoString -> Style
- relativeAlignLeft :: MisoString -> Style
- relativeAlignRight :: MisoString -> Style
- relativeAlignTop :: MisoString -> Style
- relativeBottomOf :: MisoString -> Style
- relativeCenter :: MisoString -> Style
- relativeId :: MisoString -> Style
- relativeInlineEndOf :: MisoString -> Style
- relativeInlineStartOf :: MisoString -> Style
- relativeLayoutOnce :: MisoString -> Style
- relativeLeftOf :: MisoString -> Style
- relativeRightOf :: MisoString -> Style
- relativeTopOf :: MisoString -> Style
- resize :: MisoString -> Style
- right :: MisoString -> Style
- rowGap :: MisoString -> Style
- scrollBehavior :: MisoString -> Style
- stroke :: Color -> Style
- strokeWidth :: MisoString -> Style
- textAlign :: MisoString -> Style
- textDecoration :: MisoString -> Style
- textIndent :: MisoString -> Style
- textOverflow :: MisoString -> Style
- textShadow :: MisoString -> Style
- textStrokeColor :: Color -> Style
- textStroke :: MisoString -> Style
- textStrokeWidth :: MisoString -> Style
- textTransform :: MisoString -> Style
- top :: MisoString -> Style
- transform :: MisoString -> Style
- transforms :: [TransformFn] -> Style
- transformOrigin :: MisoString -> Style
- translate :: MisoString -> MisoString -> TransformFn
- translateX :: MisoString -> TransformFn
- translateY :: MisoString -> TransformFn
- translateZ :: MisoString -> TransformFn
- translate3d :: MisoString -> MisoString -> MisoString -> TransformFn
- rotate :: MisoString -> TransformFn
- rotateX :: MisoString -> TransformFn
- rotateY :: MisoString -> TransformFn
- rotateZ :: MisoString -> TransformFn
- rotate3d :: Double -> Double -> Double -> MisoString -> TransformFn
- scale :: Double -> TransformFn
- scaleXY :: Double -> Double -> TransformFn
- scale3d :: Double -> Double -> Double -> TransformFn
- scaleX :: Double -> TransformFn
- scaleY :: Double -> TransformFn
- scaleZ :: Double -> TransformFn
- perspectiveFn :: MisoString -> TransformFn
- matrix3d :: (Double, Double, Double, Double) -> (Double, Double, Double, Double) -> (Double, Double, Double, Double) -> (Double, Double, Double, Double) -> TransformFn
- skew :: MisoString -> MisoString -> TransformFn
- skewX :: MisoString -> TransformFn
- skewY :: MisoString -> TransformFn
- transitionDelay :: MisoString -> Style
- transitionDuration :: MisoString -> Style
- transition :: MisoString -> Style
- transitionProperty :: MisoString -> Style
- transitionTimingFunction :: MisoString -> Style
- userSelect :: MisoString -> Style
- verticalAlign :: MisoString -> Style
- visibility :: MisoString -> Style
- whiteSpace :: MisoString -> Style
- width :: MisoString -> Style
- willChange :: MisoString -> Style
- wordBreak :: MisoString -> Style
- xAutoFontSize :: MisoString -> Style
- xAutoFontSizePresetSizes :: MisoString -> Style
- xHandleColor :: Color -> Style
- xHandleSize :: MisoString -> Style
- zIndex :: Int -> Style
- module Miso.CSS.Color
- px :: Int -> MisoString
- ppx :: Double -> MisoString
- pct :: Double -> MisoString
- pt :: Int -> MisoString
- vw :: Double -> MisoString
- vh :: Double -> MisoString
- deg :: Double -> MisoString
- turn :: Double -> MisoString
- rad :: Double -> MisoString
- rpx :: Double -> MisoString
- rem :: Double -> MisoString
- em :: Double -> MisoString
- s :: Double -> MisoString
- ms :: Double -> MisoString
- url :: MisoString -> MisoString
- matrix :: Double -> Double -> Double -> Double -> Double -> Double -> MisoString
- keyframes_ :: MisoString -> [KeyframeStop] -> Styles
- from_ :: [Style] -> KeyframeStop
- to_ :: [Style] -> KeyframeStop
- at :: MisoString -> [Style] -> KeyframeStop
- media_ :: MediaQuery -> [MediaRule] -> Styles
- rule_ :: MisoString -> [Style] -> MediaRule
- screen_ :: MediaQuery
- print_ :: MediaQuery
- all_ :: MediaQuery
- and_ :: MediaQuery -> MediaQuery -> MediaQuery
- or_ :: MediaQuery -> MediaQuery -> MediaQuery
- not_ :: MediaQuery -> MediaQuery
- minWidth_ :: MisoString -> MediaQuery
- maxWidth_ :: MisoString -> MediaQuery
- minHeight_ :: MisoString -> MediaQuery
- maxHeight_ :: MisoString -> MediaQuery
- orientation_ :: MisoString -> MediaQuery
- prefersColorScheme_ :: MisoString -> MediaQuery
- prefersReducedMotion_ :: MisoString -> MediaQuery
- hover_ :: MisoString -> MediaQuery
Types
module Miso.CSS.Types
Smart Constructor
style_ :: [Style] -> Attribute action Source #
Constructs a structured style attribute from a list of CSS properties.
Each Style is a (property, value) pair produced by the combinators in
this module. Miso tracks the properties as a Map, diffs them on
each render, and applies only the changed properties to the DOM. Properties
absent from the list are removed from the node.
div_
[ style_
[ display "flex"
, flexDirection "column"
, gap (px 8)
, backgroundColor red
]
] []
See also styleInline_ for setting raw CSS strings.
styleInline_ :: MisoString -> Attribute action Source #
Sets the style attribute to a raw CSS string.
Unlike style_, the string is applied verbatim and is not tracked or
diffed by the virtual DOM. Suitable for static styles or CSS values that
the structured combinators do not yet cover.
div_ [ styleInline_ "background-color:red; color:blue;" ] [ "foo" ]
sheet_ :: [Styles] -> StyleSheet Source #
Constructs a StyleSheet from a list of Styles entries.
Combine with selector_, keyframes_, and media_ to build a full
stylesheet, then render it to a MisoString with renderStyleSheet.
mySheet :: StyleSheet mySheet = sheet_ [ selector_ "body" [ margin (px 0), fontFamily "sans-serif" ] , selector_ "button" [ cursor "pointer", borderRadius (px 4) ] ]
Render
renderStyleSheet :: StyleSheet -> MisoString Source #
Renders a StyleSheet to a MisoString suitable for injection into a
<style> tag.
view_ :: View model action view_ = style [] [ text (renderStyleSheet mySheet) ]
Combinators
alignContent :: MisoString -> Style Source #
alignItems :: MisoString -> Style Source #
alignSelf :: MisoString -> Style Source #
animationDelay :: MisoString -> Style Source #
animationDirection :: MisoString -> Style Source #
animationDuration :: MisoString -> Style Source #
animationFillMode :: MisoString -> Style Source #
animationName :: MisoString -> Style Source #
animationPlayState :: MisoString -> Style Source #
aspectRatio :: MisoString -> Style Source #
backgroundClip :: MisoString -> Style Source #
backgroundColor :: Color -> Style Source #
backgroundImage :: MisoString -> Style Source #
background :: MisoString -> Style Source #
backgroundOrigin :: MisoString -> Style Source #
backgroundPosition :: MisoString -> Style Source #
backgroundRepeat :: MisoString -> Style Source #
backgroundSize :: MisoString -> Style Source #
borderBottomColor :: Color -> Style Source #
borderBottom :: MisoString -> Style Source #
borderBottomStyle :: MisoString -> Style Source #
borderBottomWidth :: MisoString -> Style Source #
borderCollapse :: MisoString -> Style Source #
borderEndEndRadius :: MisoString -> Style Source #
borderInlineEndColor :: Color -> Style Source #
borderInlineStartColor :: Color -> Style Source #
borderLeftColor :: Color -> Style Source #
borderLeft :: MisoString -> Style Source #
borderLeftStyle :: MisoString -> Style Source #
borderLeftWidth :: MisoString -> Style Source #
borderRadius :: MisoString -> Style Source #
borderRightColor :: Color -> Style Source #
borderRight :: MisoString -> Style Source #
borderRightStyle :: MisoString -> Style Source #
borderRightWidth :: MisoString -> Style Source #
borderStyle :: MisoString -> Style Source #
borderTopColor :: Color -> Style Source #
borderTop :: MisoString -> Style Source #
borderTopStyle :: MisoString -> Style Source #
borderTopWidth :: MisoString -> Style Source #
borderWidth :: MisoString -> Style Source #
boxShadow :: MisoString -> Style Source #
boxSizing :: MisoString -> Style Source #
appearance :: MisoString -> Style Source #
backdropFilter :: MisoString -> Style Source #
columnGap :: MisoString -> Style Source #
flexBasis :: MisoString -> Style Source #
flexDirection :: MisoString -> Style Source #
fontFamily :: MisoString -> Style Source #
fontStretch :: MisoString -> Style Source #
fontStyle :: MisoString -> Style Source #
fontVariant :: MisoString -> Style Source #
fontWeight :: MisoString -> Style Source #
gridAutoColumns :: MisoString -> Style Source #
gridAutoFlow :: MisoString -> Style Source #
gridAutoRows :: MisoString -> Style Source #
gridColumn :: MisoString -> Style Source #
gridColumnEnd :: MisoString -> Style Source #
gridColumnSpan :: MisoString -> Style Source #
gridColumnStart :: MisoString -> Style Source #
gridRowEnd :: MisoString -> Style Source #
gridRowSpan :: MisoString -> Style Source #
gridRowStart :: MisoString -> Style Source #
gridTemplateRows :: MisoString -> Style Source #
imageRendering :: MisoString -> Style Source #
insetInlineEnd :: MisoString -> Style Source #
insetInlineStart :: MisoString -> Style Source #
justifyContent :: MisoString -> Style Source #
justifyItems :: MisoString -> Style Source #
justifySelf :: MisoString -> Style Source #
letterSpacing :: MisoString -> Style Source #
linearCrossGravity :: MisoString -> Style Source #
linearDirection :: MisoString -> Style Source #
linearGravity :: MisoString -> Style Source #
linearWeight :: MisoString -> Style Source #
linearWeightSum :: MisoString -> Style Source #
lineHeight :: MisoString -> Style Source #
marginBottom :: MisoString -> Style Source #
marginInlineEnd :: MisoString -> Style Source #
marginInlineStart :: MisoString -> Style Source #
marginLeft :: MisoString -> Style Source #
marginRight :: MisoString -> Style Source #
marginTop :: MisoString -> Style Source #
maskImage :: MisoString -> Style Source #
maxHeight :: MisoString -> Style Source #
minHeight :: MisoString -> Style Source #
mixBlendMode :: MisoString -> Style Source #
objectFit :: MisoString -> Style Source #
objectPosition :: MisoString -> Style Source #
outlineColor :: Color -> Style Source #
outlineOffset :: MisoString -> Style Source #
outlineStyle :: MisoString -> Style Source #
outlineWidth :: MisoString -> Style Source #
overflowX :: MisoString -> Style Source #
overflowY :: MisoString -> Style Source #
overscrollBehavior :: MisoString -> Style Source #
paddingBottom :: MisoString -> Style Source #
paddingInlineEnd :: MisoString -> Style Source #
paddingInlineStart :: MisoString -> Style Source #
paddingLeft :: MisoString -> Style Source #
paddingRight :: MisoString -> Style Source #
paddingTop :: MisoString -> Style Source #
perspective :: MisoString -> Style Source #
pointerEvents :: MisoString -> Style Source #
relativeAlignLeft :: MisoString -> Style Source #
relativeAlignRight :: MisoString -> Style Source #
relativeAlignTop :: MisoString -> Style Source #
relativeBottomOf :: MisoString -> Style Source #
relativeCenter :: MisoString -> Style Source #
relativeId :: MisoString -> Style Source #
relativeLayoutOnce :: MisoString -> Style Source #
relativeLeftOf :: MisoString -> Style Source #
relativeRightOf :: MisoString -> Style Source #
relativeTopOf :: MisoString -> Style Source #
scrollBehavior :: MisoString -> Style Source #
strokeWidth :: MisoString -> Style Source #
textAlign :: MisoString -> Style Source #
textDecoration :: MisoString -> Style Source #
textIndent :: MisoString -> Style Source #
textOverflow :: MisoString -> Style Source #
textShadow :: MisoString -> Style Source #
textStrokeColor :: Color -> Style Source #
textStroke :: MisoString -> Style Source #
textStrokeWidth :: MisoString -> Style Source #
textTransform :: MisoString -> Style Source #
transforms :: [TransformFn] -> Style Source #
Apply a list of TransformFn values as a transform style.
transforms [ translate (px 10) (pct 50), rotate (deg 45), scaleX 1.5 ]
transformOrigin :: MisoString -> Style Source #
Transform functions
translate :: MisoString -> MisoString -> TransformFn Source #
https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/translate
>>>renderTransformFn (translate (px 10) (pct 50))"translate(10px,50.0%)"
translateX :: MisoString -> TransformFn Source #
translateY :: MisoString -> TransformFn Source #
translateZ :: MisoString -> TransformFn Source #
translate3d :: MisoString -> MisoString -> MisoString -> TransformFn Source #
rotate :: MisoString -> TransformFn Source #
https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/rotate
>>>renderTransformFn (rotate (deg 45))"rotate(45.0deg)"
rotateX :: MisoString -> TransformFn Source #
rotateY :: MisoString -> TransformFn Source #
rotateZ :: MisoString -> TransformFn Source #
rotate3d :: Double -> Double -> Double -> MisoString -> TransformFn Source #
https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/rotate3d
x, y, z are unitless direction vector components; angle uses a unit constructor like deg.
scale :: Double -> TransformFn Source #
https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/scale Uniform scale on both axes.
>>>renderTransformFn (scale 1.5)"scale(1.5)"
scaleXY :: Double -> Double -> TransformFn Source #
https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/scale Non-uniform scale: separate X and Y factors.
scaleX :: Double -> TransformFn Source #
scaleY :: Double -> TransformFn Source #
scaleZ :: Double -> TransformFn Source #
perspectiveFn :: MisoString -> TransformFn Source #
https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/perspective
The perspective() transform function, distinct from the perspective CSS property.
>>>renderTransformFn (perspectiveFn (px 500))"perspective(500px)"
matrix3d :: (Double, Double, Double, Double) -> (Double, Double, Double, Double) -> (Double, Double, Double, Double) -> (Double, Double, Double, Double) -> TransformFn Source #
https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d 4x4 homogeneous matrix in column-major order; each tuple is one column.
matrix3d (1,0,0,0) (0,1,0,0) (0,0,1,0) (10,20,0,1)
skew :: MisoString -> MisoString -> TransformFn Source #
skewX :: MisoString -> TransformFn Source #
skewY :: MisoString -> TransformFn Source #
transitionDelay :: MisoString -> Style Source #
transitionDuration :: MisoString -> Style Source #
transition :: MisoString -> Style Source #
transitionProperty :: MisoString -> Style Source #
userSelect :: MisoString -> Style Source #
verticalAlign :: MisoString -> Style Source #
visibility :: MisoString -> Style Source #
whiteSpace :: MisoString -> Style Source #
willChange :: MisoString -> Style Source #
wordBreak :: MisoString -> Style Source #
xAutoFontSize :: MisoString -> Style Source #
xHandleColor :: Color -> Style Source #
xHandleSize :: MisoString -> Style Source #
Colors
module Miso.CSS.Color
Units
px :: Int -> MisoString Source #
Font sizing in terms of *px*
>>> px 10 "10px"
ppx :: Double -> MisoString Source #
Physical pixel unit (ppx), used in some native/mobile rendering contexts.
>>> ppx 2.0 "2.0ppx"
pct :: Double -> MisoString Source #
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 #
Wraps a value in the CSS url() function, used for background images and similar.
>>> url "dog.png" "url(dog.png)"
backgroundImage (url "banner.png")
Arguments
| :: Double | a — scale x |
| -> Double | b — skew y |
| -> Double | c — skew x |
| -> Double | d — scale y |
| -> Double | tx — translate x |
| -> Double | ty — translate y |
| -> MisoString |
Constructs a 2D CSS transformation matrix string: matrix(a, b, c, d, tx, ty).
The six parameters define a 2D affine transformation: a and d scale,
b and c skew, and tx/ty translate.
transform (matrix 1 0 0 1 50 100) -- translate by (50, 100)
https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix
Animation
keyframes_ :: MisoString -> [KeyframeStop] -> Styles Source #
Constructs a CSS @keyframes animation rule.
The first argument is the animation name; the second is a list of
(keyframe-selector, [Style]) pairs. Keyframe selectors are either
"from"/"to" or a percentage string produced by pct.
slideIn :: Styles slideIn = keyframes_ "slide-in" [ from_ [ transform "translateX(-100%)" ] , at (pct 50) [ opacity 0.5 ] , to_ [ transform "translateX(0)" ] ]
from_ :: [Style] -> KeyframeStop Source #
The from stop in a 'keyframes' rule (equivalent to 0%@).
to_ :: [Style] -> KeyframeStop Source #
The to stop in a 'keyframes' rule (equivalent to 100%@).
at :: MisoString -> [Style] -> KeyframeStop Source #
A keyframe stop at a given position, typically built with pct.
at (pct 50) [ opacity 0.5 ]
Media Queries
media_ :: MediaQuery -> [MediaRule] -> Styles Source #
Constructs a CSS @media query rule.
The first argument is the media condition string; the second is a list of
(selector, [Style]) pairs scoped to that query.
responsive ::Stylesresponsive =media_(screen_`and_`minWidth_(px 480)) [rule_"header" [height"auto" ] ,rule_"ul" [display"block" ] ]
rule_ :: MisoString -> [Style] -> MediaRule Source #
A selector rule inside a media_ block.
rule_ "header" [ height "auto" ]
Media query combinators
screen_ :: MediaQuery Source #
The screen media type.
print_ :: MediaQuery Source #
The print media type.
all_ :: MediaQuery Source #
The all media type (matches all devices).
and_ :: MediaQuery -> MediaQuery -> MediaQuery Source #
Logical and for media queries.
screen_ \`and_\` minWidth_ (px 480)
or_ :: MediaQuery -> MediaQuery -> MediaQuery Source #
Logical or for media queries (comma-separated).
screen_ \`or_\` print_
not_ :: MediaQuery -> MediaQuery Source #
Logical not for media queries.
not_ print_
minWidth_ :: MisoString -> MediaQuery Source #
maxWidth_ :: MisoString -> MediaQuery Source #
max-width media feature.
minHeight_ :: MisoString -> MediaQuery Source #
min-height media feature.
maxHeight_ :: MisoString -> MediaQuery Source #
max-height media feature.
orientation_ :: MisoString -> MediaQuery Source #
orientation media feature. Use "portrait" or "landscape".
prefersColorScheme_ :: MisoString -> MediaQuery Source #
prefers-color-scheme media feature. Use "light" or "dark".
prefersReducedMotion_ :: MisoString -> MediaQuery Source #
prefers-reduced-motion media feature. Use "reduce" or "no-preference".
hover_ :: MisoString -> MediaQuery Source #
hover media feature. Use "hover" or "none".