pub struct ThemeData {Show 33 fields
pub background: Color,
pub foreground: Color,
pub primary: Color,
pub accent: Color,
pub surface: Color,
pub error: Color,
pub high_contrast: bool,
pub border: Color,
pub divider: Color,
pub hover: Color,
pub disabled: Color,
pub selection: Color,
pub icon: Color,
pub radius_sm: f32,
pub radius_md: f32,
pub radius_lg: f32,
pub spacing: f32,
pub space: SpacingScale,
pub text: TextTheme,
pub button: ButtonStyle,
pub button_variants: ButtonVariants,
pub avatar: AvatarStyle,
pub control: ControlStyle,
pub scrollbar: ScrollbarStyle,
pub input: InputStyle,
pub tooltip: TooltipStyle,
pub menu: MenuStyle,
pub tab: TabStyle,
pub nav: NavStyle,
pub feedback: FeedbackStyle,
pub dropdown: DropdownStyle,
pub dialog: DialogStyle,
pub list: ListStyle,
}Expand description
主题色板 + 子主题。
所有 update_should_notify 走 PartialEq 派生自动比较。
风格基准:AWS Cloudscape Design System(Visual Refresh)
(cloudscape_dark() / cloudscape_light(),cloudscape(bool) 按开关选择;
dark() / light() 为同一套主题的别名)。
通用令牌(border / divider / hover)供全部组件共享,做到“一次改主题、全局换肤“。
Fields§
§background: Color§foreground: Color§primary: Color§accent: Color§surface: Color§error: Color§high_contrast: bool高对比度变体标记(由 ThemeData::high_contrast 设置)。
border: Color§divider: Color§hover: Color§disabled: Color§selection: Color§icon: Color§radius_sm: f32§radius_md: f32§radius_lg: f32§spacing: f32§space: SpacingScale4pt 间距刻度与组件默认间距
text: TextTheme按钮语义变体色板(Primary/Normal/Tertiary/Success/Warning/Error/Info)
avatar: AvatarStyleAvatar 首字头像样式
control: ControlStyle表单控件令牌(Checkbox/Radio/Toggle/Slider)
scrollbar: ScrollbarStyle§input: InputStyle§tooltip: TooltipStyle§tab: TabStyle§feedback: FeedbackStyle§dropdown: DropdownStyle§dialog: DialogStyle§list: ListStyleImplementations§
Source§impl ThemeData
impl ThemeData
Sourcepub fn cloudscape_light() -> Self
pub fn cloudscape_light() -> Self
AWS Cloudscape Design System(Visual Refresh)— 浅色。
Sourcepub fn cloudscape_dark() -> Self
pub fn cloudscape_dark() -> Self
AWS Cloudscape Design System(Visual Refresh)— 深色。
Sourcepub fn cloudscape(dark: bool) -> Self
pub fn cloudscape(dark: bool) -> Self
按 dark 选择 Cloudscape 主题。
色值取自 Cloudscape design-tokens(visual refresh)官方明/暗令牌:
主操作蓝 #006CE0 / #42B4FF、正文 #0F141A / #C6C6CD、
容器 #FFFFFF / #161D26、分割线 #C6C6CD / #424650、
控件圆角 8、容器圆角 16、主按钮胶囊 20。
Sourcepub fn high_contrast(dark: bool) -> Self
pub fn high_contrast(dark: bool) -> Self
高对比度主题(Windows 高对比度/强制对比模式的通用替代)。
在 Cloudscape 色板骨架上强制:
- 前景/背景 ≥ 7:1,边框/背景 ≥ 3:1,主色/背景 ≥ 4.5:1;
- 关键文本使用纯黑/纯白,边框与分割线使用前景色;
- 圆角归零、焦点环 3px,便于低视力用户辨识。
dark=true 为黑底白字/金黄主色;false 为白底黑字/深蓝主色。
系统高对比度色板由平台提供时,应用仍可自行替换核心令牌。