#[repr(u8)]pub enum SystemColor {
Show 16 variants
Accent = 0,
Text = 1,
SecondaryText = 2,
Background = 3,
Surface = 4,
TertiaryText = 5,
Placeholder = 6,
Link = 7,
Separator = 8,
ControlFill = 9,
GroupedBackground = 10,
ElevatedSurface = 11,
Selection = 12,
Destructive = 13,
Success = 14,
Warning = 15,
}Expand description
A platform color role: what a color means, which each toolkit answers with its own
palette (docs/color.md “System colors”). Pass a role wherever a color is taken
(.background(SystemColor::Surface), label(..).color(SystemColor::Link)) and the view
follows the appearance, the accent and the contrast setting.
Every role maps to a real platform color on every toolkit, or to the documented
light/dark pair in SystemColor::fallback where a platform has none.
Variants§
Accent = 0
The app’s accent: selection, the prominent button, a focus ring.
Text = 1
Primary text.
SecondaryText = 2
De-emphasized text: a caption, a detail line.
Background = 3
The window’s content background.
Surface = 4
A region set off from the background: a panel, a card, a sidebar.
TertiaryText = 5
Text a step quieter than secondary: a disabled-looking hint, a footnote.
Placeholder = 6
A text field’s placeholder.
Link = 7
A link in running text.
Separator = 8
A hairline between items: a rule, a list separator, a grid line.
ControlFill = 9
The fill of a control’s track or well: a slider’s track, a segmented control’s background, a search field.
GroupedBackground = 10
The background behind grouped sections (an inset grouped list, a settings page).
ElevatedSurface = 11
A surface raised above the content: a popover, a menu, a sheet in dark appearance.
Selection = 12
The highlight behind selected text or selected content the app draws itself. Text keeps its own color on it.
Destructive = 13
A destructive action or an error.
Success = 14
Success, a value that rose.
Warning = 15
A warning, something to notice.
Implementations§
Source§impl SystemColor
impl SystemColor
Sourcepub const COUNT: usize = 16
pub const COUNT: usize = 16
How many roles there are: the length of SystemColor::ALL and of a Palette.
Sourcepub const ALL: [Self; 16]
pub const ALL: [Self; 16]
All roles, in discriminant order (the wire order: a role crosses JNI, C++ and JS as its position here).
Sourcepub const fn wire(self) -> u8
pub const fn wire(self) -> u8
The role as its wire number: its position in SystemColor::ALL.
Sourcepub const fn from_wire(n: u8) -> Option<SystemColor>
pub const fn from_wire(n: u8) -> Option<SystemColor>
The role with wire number n, if there is one.
Sourcepub const fn with_alpha(self, alpha: f64) -> Ink
pub const fn with_alpha(self, alpha: f64) -> Ink
This role at opacity alpha, replacing the role’s own alpha: a wash of the accent
behind a selected chip (SystemColor::Accent.with_alpha(0.14)).
Sourcepub const fn fallback(self, dark: bool) -> Color
pub const fn fallback(self, dark: bool) -> Color
Day’s own light/dark pair for the role: what a toolkit answers where its platform has
no such color, and what Palette::fallback holds. Fixed sRGB colors, close to the
Apple system palette, not an approximation of a user-chosen accent.