import Color exposing (blue)
import Element
import Element.Font as Font
view =
Element.el
[ Font.color blue
, Font.size 18
, Font.lineHeight 1.3 -- line height is given as a ratio of Font.size.
, Font.family
[ Font.typeface "Open Sans"
, Font.sansSerif
]
]
(Element.text "Woohoo, I'm stylish text")Note: Font.color, Font.size, Font.family, and Font.lineHeight are all inherited, meaning you can set them at the top of your view and all subsequent nodes will have that value.
Font sizes are always given as px.
This is the only unitless value in the library that isn't px.
It's given as a proportion of the Font.size.
This means the final lineHeight in px is:
Font.size * Font.lineHeight == lineHeightInPximport Element
import Element.Font as Font
myElement =
Element.el
[ Font.family
[ Font.typeface "Helvetica"
, Font.sansSerif
]
]
(text "")Font.external can be used to import font files. Let's say you found a neat font on http://fonts.google.com:
import Element
import Element.Font as Font
view =
Element.el
[ Font.family
[ Font.external
{ name = "Roboto"
, url = "https://fonts.googleapis.com/css?family=Roboto"
}
, Font.sansSerif
]
]
(Element.text "Woohoo, I'm stylish text")Align the font to the left.
Align the font to the right.
Center align the font.
In px.
In px.
A glow is just a simplified shadow