A theme is defined of a color palette made of six semantic color scales. These scales are the "variants" of a theme and represent different things like a "base" or "neutral" color, a "primary" brand color, status-focused colors like "success", "warning" and "danger", and a "secondary" color used for increased expresiveness.
A ColorScale is made of a number of color shades. But don't worry! There is dozens of handmade scales ready to be used through elm-theme-colors.
Instead of using the common 100-900 scale found in systems like TailwindCSS or Material Design, we went for a more semantic approach based on what you would find on Radix UI. However, W Theme names colors directly instead of relying on a numeric scale. It also provides more variations than Radix, so no default use cases fall outside the provided scale.
Accent colors are not made for background or text usage as they're not guaranteed to have proper contrast, they should be used for colored elements.
Solid colors should use solid-text as their text color for proper accessibility.
Both text colors are guaranteed to be accessible over any background and tint colors.
Shadows are usually used with alpha values.
You should mostly use colors according to the current variant. This will make your styles more dynamic. Each html element can easily set its own variant, like so:
Html.div
[ W.Theme.Color.asPrimary
, W.Theme.styleList
[ ( "background", W.Theme.Color.bg )
, ( "border-color", W.Theme.Color.accent )
, ( "color", W.Theme.Color.text )
]
]
[ ... ]However, if you wish to specify variant-specific colors regardless of context you can also access its values:
Html.button
[ W.Theme.styleList
[ ( "background", W.Theme.Color.dangerSolid )
, ( "color", W.Theme.Color.dangerText )
]
]
[ ... ]There are a few utility components that can be used to quickly apply some styles to your elements.
Shadow colors receive an alpha value as they're meant to be used with transparency.
Html.div
[ W.Theme.styleList
[ ( "box-shadow"
, "0 0 8px " ++ W.Theme.Color.shadow 0.1 )
]
]
[ ... ]These colors will be related to the currently available variant.
By default, the base variant is selected.