Expand description
Design tokens and the built-in light and dark themes.
Every component resolves its colours through Tokens::of, so any
iced::Theme works. light and dark are tuned for the library,
and Config builds a theme with your own colours on top of either.
Modules§
- radius
- Corner radii in logical pixels.
- space
- Spacing scale in logical pixels.
- text_
size - Text sizes in logical pixels.
Structs§
- Config
- Builds a
Themefrom your own colours, starting from the light or dark defaults. Text on coloured surfaces, such as a primary button’s label, is picked automatically withon. - Swatch
- A small filled circle of colour, for colour pickers, legends and the
options of a select. Convert it into an
Elementto render. - Tokens
- Semantic colours resolved from a theme.
Enums§
- Tone
- A theme colour that marks what something signals, shared by components that colour items by meaning: calendar entries, timeline steps and spans, and image compare outlines.
Constants§
- SWATCH_
SIZE - Default diameter of a
Swatchin logical pixels. - TEXT_
CONTRAST - The contrast ratio body text needs against its background.
Functions§
- contrast
- The WCAG contrast ratio between two colours, from 1 to 21.
- dark
- The library’s dark theme.
- fade
- Returns
colorwith its alpha multiplied byalpha. - font
- The registered base font, or iced’s default when none is set.
- light
- The library’s light theme.
- luminance
- The relative luminance of
colour, from 0 for black to 1 for white, as the WCAG contrast formula uses it. - mix
- Linearly blends
atowardsbbyt(0.0 isa, 1.0 isb). - on
- Near-black or near-white, whichever has the higher contrast ratio on
background. - readable
colour, moved just far enough towards near-white or near-black, whichever stands out frombackground, for text in it to reachTEXT_CONTRAST. A colour that already reads is left as it is.- semibold
- The base font at semibold weight.
- set_
font - Registers the font components use for emphasised text, such as card and
toast titles. Pass the same font you give iced’s
default_font, before the first view. Returnsfalseif a font was already set. - swatch
- Creates a swatch whose colour is resolved from the theme each time it is drawn, so it follows theme changes.
- swatch_
color - Creates a swatch of one fixed colour, whatever the theme.