pub struct ThemeBuilder { /* private fields */ }Expand description
Builder for custom themes. #[must_use]: a chain whose result is never
built is an unused_must_use warning.
Implementations§
Source§impl ThemeBuilder
impl ThemeBuilder
Sourcepub fn components(self, components: ComponentThemes) -> Self
pub fn components(self, components: ComponentThemes) -> Self
Component defaults and named recipes, resolved by renderers on every frame.
Sourcepub fn id(self, id: impl Into<SharedString>) -> Self
pub fn id(self, id: impl Into<SharedString>) -> Self
Sets the theme id.
Sourcepub fn appearance(self, appearance: Appearance) -> Self
pub fn appearance(self, appearance: Appearance) -> Self
Sets the theme’s Appearance (color-scheme).
Sourcepub fn radius(self, radius: Pixels) -> Self
pub fn radius(self, radius: Pixels) -> Self
Sets --radius; --field-radius follows as radius * 1.5 unless it is
overridden afterwards with field_radius.
Sourcepub fn field_radius(self, radius: Pixels) -> Self
pub fn field_radius(self, radius: Pixels) -> Self
Sets --field-radius, overriding the value derived from --radius.
Sourcepub fn border_width(self, width: Pixels) -> Self
pub fn border_width(self, width: Pixels) -> Self
Sets --border-width.
Sourcepub fn disabled_opacity(self, v: f32) -> Self
pub fn disabled_opacity(self, v: f32) -> Self
Sets --disabled-opacity.
Sourcepub fn cursor_interactive(self, cursor: CursorStyle) -> Self
pub fn cursor_interactive(self, cursor: CursorStyle) -> Self
Sets the cursor every interactive control shows on hover. Defaults to
gpui::CursorStyle::PointingHand, v3’s cursor: pointer.
Sourcepub fn tabs_hover_opacity(self, v: f32) -> Self
pub fn tabs_hover_opacity(self, v: f32) -> Self
Sets the opacity a hovered Tabs item drops to. Finite values are
clamped to 0..=1; a non-finite value keeps the default 0.7.
Sourcepub fn tooltip_cooldown_ms(self, ms: u64) -> Self
pub fn tooltip_cooldown_ms(self, ms: u64) -> Self
Sets the warm window after the pointer leaves a tooltip during which
the next tip opens without its delay. A per-tooltip close delay
extends the window via max().
Sourcepub fn long_press_ms(self, ms: u64) -> Self
pub fn long_press_ms(self, ms: u64) -> Self
Sets how long a DropdownTrigger::LongPress waits before it opens.
Sourcepub fn hover_fade_ms(self, ms: u64) -> Self
pub fn hover_fade_ms(self, ms: u64) -> Self
Sets the background fade duration of anim::hover_fade. Zero resolves
immediately, like reduced motion.
Sourcepub fn tooltip_delay_ms(self, ms: u64) -> Self
pub fn tooltip_delay_ms(self, ms: u64) -> Self
--tooltip-delay: how long a hover waits before the tip opens.
Sourcepub fn tooltip_close_delay_ms(self, ms: u64) -> Self
pub fn tooltip_close_delay_ms(self, ms: u64) -> Self
--tooltip-close-delay: the per-tooltip close delay default.
Sourcepub fn background(self, c: Hsla) -> Self
pub fn background(self, c: Hsla) -> Self
Sets --background.
Sourcepub fn foreground(self, c: Hsla) -> Self
pub fn foreground(self, c: Hsla) -> Self
Sets --foreground; the scrollbar color is re-derived from it at 15% alpha.
Sourcepub fn separator(self, c: Hsla) -> Self
pub fn separator(self, c: Hsla) -> Self
Sets --separator. Defaults to the same value as --border.
Sourcepub fn surface(self, background: Hsla, foreground: Hsla) -> Self
pub fn surface(self, background: Hsla, foreground: Hsla) -> Self
Sets --surface and --surface-foreground.
Sourcepub fn surface_levels(self, secondary: Hsla, tertiary: Hsla) -> Self
pub fn surface_levels(self, secondary: Hsla, tertiary: Hsla) -> Self
Sets --surface-secondary and --surface-tertiary.
Sourcepub fn overlay(self, background: Hsla, foreground: Hsla) -> Self
pub fn overlay(self, background: Hsla, foreground: Hsla) -> Self
Sets --overlay and --overlay-foreground.
Sourcepub fn segment(self, background: Hsla, foreground: Hsla) -> Self
pub fn segment(self, background: Hsla, foreground: Hsla) -> Self
Sets --segment and --segment-foreground.
Sourcepub fn role(self, role: Color, color: Hsla, foreground: Hsla) -> Self
pub fn role(self, role: Color, color: Hsla, foreground: Hsla) -> Self
Sets a role’s base value and foreground. Like overriding a CSS
variable, the role’s hover and soft mix weights carry over — only the
inputs change. --focus tracks --accent unless it is overridden
afterwards, and --field-background tracks --default.
The role is the typed Color, so a misspelt role cannot compile.
Parse a name from configuration with name.parse::<Color>(), which
rejects an unknown name instead of falling back to accent.
Sourcepub fn vibrant_palette(self, vibrant: bool) -> Self
pub fn vibrant_palette(self, vibrant: bool) -> Self
HeroUI’s opt-in [data-vibrant-palette="true"] block
(variables.css:317-330): the accent, success, warning and danger
*-soft-foreground mixes become 92% role over 8% page foreground in
both appearances, for more saturated soft text with less contrast.
--default-soft-foreground is not in that block and is left alone.
Off by default, like the attribute.
Sourcepub fn accent(self, color: Hsla) -> Self
pub fn accent(self, color: Hsla) -> Self
Sets --accent and --accent-foreground, deriving the foreground for
readability when it is not supplied.
Sourcepub fn role_hover(self, role: Color, hover: Hsla) -> Self
pub fn role_hover(self, role: Color, hover: Hsla) -> Self
Names a role’s *-hover shade outright, in place of the derived mix.
Upstream mixes a role toward its own foreground for hover, so a design
system whose hover moves the other way has no weight that expresses it.
Naming it here reaches every component that hovers the role, so
Variant::Primary is correct by construction rather than by converting
call sites to a named recipe carrying a
crate::ComponentColor::Literal. *-soft-hover is unaffected.
The role is the typed Color, as for ThemeBuilder::role.
Sourcepub fn accent_hover(self, hover: Hsla) -> Self
pub fn accent_hover(self, hover: Hsla) -> Self
ThemeBuilder::role_hover for accent, the role Variant::Primary
and the focus ring resolve.
Sourcepub fn field(self, background: Hsla, foreground: Hsla) -> Self
pub fn field(self, background: Hsla, foreground: Hsla) -> Self
Sets --field-background and --field-foreground.
Sourcepub fn field_placeholder(self, c: Hsla) -> Self
pub fn field_placeholder(self, c: Hsla) -> Self
Sets --field-placeholder.
Sourcepub fn field_border(self, c: Hsla) -> Self
pub fn field_border(self, c: Hsla) -> Self
Sets --field-border.
Auto Trait Implementations§
impl Freeze for ThemeBuilder
impl RefUnwindSafe for ThemeBuilder
impl Send for ThemeBuilder
impl Sync for ThemeBuilder
impl Unpin for ThemeBuilder
impl UnsafeUnpin for ThemeBuilder
impl UnwindSafe for ThemeBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more