Skip to main content

ThemeTokens

Struct ThemeTokens 

Source
#[non_exhaustive]
pub struct ThemeTokens {
Show 54 fields pub appearance: ThemeAppearance, pub touch: bool, pub base: SemanticThemeTokens, pub selected: Hsla, pub link: Hsla, pub tooltip: Hsla, pub tooltip_foreground: Hsla, pub scrim: Hsla, pub dialog_overlay: Hsla, pub sidebar: Hsla, pub sidebar_border: Hsla, pub sidebar_accent: Hsla, pub sidebar_selected: Hsla, pub sidebar_muted_foreground: Hsla, pub text_control: TextStyleToken, pub text_heading: TextStyleToken, pub text_title: TextStyleToken, pub metrics: MetricTokens, pub disabled_opacity: f32, pub terminal_cursor_opacity: f32, pub switch_track_on: Hsla, pub switch_track_off: Hsla, pub switch_thumb: Hsla, pub success: Hsla, pub warning: Hsla, pub info: Hsla, pub destructive_solid: Hsla, pub success_solid: Hsla, pub warning_solid: Hsla, pub info_solid: Hsla, pub solid_foreground: Hsla, pub destructive_tint: Hsla, pub success_tint: Hsla, pub warning_tint: Hsla, pub info_tint: Hsla, pub progress_track: Hsla, pub popover: Hsla, pub popover_foreground: Hsla, pub popover_border: Hsla, pub popover_accent: Hsla, pub popover_separator: Hsla, pub popover_muted_foreground: Hsla, pub select_indicator: Hsla, pub select_trigger: Hsla, pub select_trigger_border: Hsla, pub tab_separator: Hsla, pub field: Hsla, pub field_border: Hsla, pub field_focus_border: Hsla, pub text_textarea: TextStyleToken, pub dock_drop: Hsla, pub dock_handle: Hsla, pub dock_handle_hover: Hsla, pub dock_unfocused: Hsla,
}
Expand description

Everything a component reads: base’s semantic tokens plus the few roles gpui-cn components need that base does not define. Derived from a ThemeConfig when the theme resolves. It is never edited by hand except through Theme::update.

Roles are added here only when a component reads them. The skill color stays on the config until then.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§appearance: ThemeAppearance

Light or dark.

§touch: bool

Whether a finger is the pointer. Components show no hover state and keep their row actions visible when it is.

§base: SemanticThemeTokens

Colors, radius, spacing, typography, and shadow shared with base.

§selected: Hsla

The persistent selected surface: a sidebar row, a segmented choice, a pressed toggle. Stronger than the hover surface (accent).

§link: Hsla

Link text. The accent, lifted toward the ink on a dark surface so it reads as text. The focus ring (ring) keeps the accent itself.

§tooltip: Hsla

The tooltip pill: a step above the window surface on dark, the ink on light.

§tooltip_foreground: Hsla

Text on a tooltip.

§scrim: Hsla

The dim over the content behind a sheet, such as the sidebar on a phone: black at half opacity in both appearances, shadcn’s bg-black/50 sheet overlay.

§dialog_overlay: Hsla

The dim behind a dialog: black at 25% alpha in both appearances. Measured from the reference app on dark: the backdrop is #121212 over the #181818 window, which is 25% black. The light value is derived from the same alpha and was not sampled.

§sidebar: Hsla

The sidebar surface: a step above the window on dark, a hair below it on light, so the rail reads as a different plane.

§sidebar_border: Hsla

The hairline between the sidebar and the content beside it.

§sidebar_accent: Hsla

The hover surface of a row on the sidebar: a step above the sidebar, short of the selected row, so a hovered row beside the selected one reads as two rows. The reference app paints both the same.

§sidebar_selected: Hsla

The selected row on the sidebar.

§sidebar_muted_foreground: Hsla

Group labels and other quiet text on the sidebar.

§text_control: TextStyleToken

The text of controls and rows: 13px at the default font size, the control size of the reference app, between base’s xs and sm.

§text_heading: TextStyleToken

A section heading or a sidebar title: 15px medium.

§text_title: TextStyleToken

A page title: 24px semibold.

§metrics: MetricTokens

The sizes of controls, rows, and window chrome.

§disabled_opacity: f32

The strength a disabled control keeps: 55%, measured from the reference app’s disabled button fill. A button applies it to its fill and a card to the whole. The reference app’s disabled switch measures 60%; gpui-cn keeps one strength for every control.

§terminal_cursor_opacity: f32

The strength of a terminal’s block cursor over the cell it covers: 55%, chosen so the glyph under the cursor stays readable without a second color.

§switch_track_on: Hsla

The color of a switch that is on and a radio that is chosen: the accent, as the reference app paints a switch that is on (#539af8 on dark). Only the switch and the radio read it, as macOS paints both in controlAccentColor; no other component paints in the accent.

§switch_track_off: Hsla

The track of a switch that is off.

§switch_thumb: Hsla

The thumb of a switch: the lighter of the surface and the ink, so it is white in both appearances of the built-in themes, as the reference app paints it.

§success: Hsla

Positive status, such as a success tag. The config’s success.

§warning: Hsla

Caution status, such as a warning tag. The config’s warning.

§info: Hsla

Neutral information, such as an info tag. The accent, so it is the theme’s own blue.

§destructive_solid: Hsla

The solid fill of a destructive mark, such as an alert count: the destructive color stepped toward the darker end of surface and ink until solid_foreground on it reaches 4.5:1, WCAG AA for text.

§success_solid: Hsla

The solid fill of a success mark, derived as destructive_solid.

§warning_solid: Hsla

The solid fill of a warning mark, derived as destructive_solid.

§info_solid: Hsla

The solid fill of an info mark, derived as destructive_solid.

§solid_foreground: Hsla

Text on a solid status fill: the lighter of surface and ink.

§destructive_tint: Hsla

The fill of a destructive status, such as a danger tag: one step from the surface toward the destructive color, scaled by contrast.

§success_tint: Hsla

The fill of a success status: the destructive_tint step toward success.

§warning_tint: Hsla

The fill of a warning status: the destructive_tint step toward warning.

§info_tint: Hsla

The fill of an info status: the destructive_tint step toward info.

§progress_track: Hsla

The track of a progress bar: primary at 20%, shadcn’s bg-primary/20. The indicator is primary itself.

§popover: Hsla

The surface of a menu or popover: #2d2d2d on dark, sampled from the reference app’s select menus, a larger step above the window than a card takes. The window surface on light, as shadcn’s popover.

§popover_foreground: Hsla

Text on a popover: the ink itself. The reference app paints menu rows white on dark where the window’s text is #dfdfdf.

§popover_border: Hsla

The hairline around a popover: #444444 on dark, sampled from the reference app’s menu edge. The border token on light.

§popover_accent: Hsla

The highlighted row of a menu: #3d3d3d on dark, sampled from the reference app’s hovered menu row. On light the same step as a hovered sidebar row.

§popover_separator: Hsla

A separator inside a popover: #3e3e3e on dark, sampled from the reference app’s menus. The border step on light.

§popover_muted_foreground: Hsla

A description under a menu row’s label: #b5b5b5 on dark, sampled from the reference app, a step brighter than muted_foreground. The muted_foreground step on light.

§select_indicator: Hsla

The check beside a selected menu row and the chevron on a select trigger: #cacaca on dark, sampled from the reference app, the ink a step toward the surface.

§select_trigger: Hsla

The fill of a select trigger: #2a2a2a on dark as sampled from the reference app on the window surface (it is #343434 on a #232323 card, the same step). The derivation gives #292929, one step off the sample, and the test asserts the derived value. The window surface on light, as shadcn’s bg-transparent trigger.

§select_trigger_border: Hsla

The hairline around a select trigger: #3b3b3b on dark as sampled from the reference app. The derivation gives #3a3a3a, one step off the sample, and the test asserts the derived value. The input token on light, as shadcn’s border-input.

§tab_separator: Hsla

The hairline between two unselected tabs: the muted text at 60%, which the tab reference app paints #707070 over its #181818 bar.

§field: Hsla

The fill of a text field: #2c2c2c on dark, sampled from the reference app’s settings textarea at 2x on the #181818 window. The window surface on light, as shadcn’s bg-transparent input.

§field_border: Hsla

The hairline around a text field at rest: #3b3b3b on dark, sampled from the reference app’s select trigger, the same family. The input token on light, as shadcn’s border-input.

§field_focus_border: Hsla

The hairline around a text field while the caret is inside: #799ec8 on dark, sampled from the reference app’s focused textarea at 2x, the link color most of the way over the fill. One pixel, no spread. The ring itself on light, as shadcn’s border-ring.

§text_textarea: TextStyleToken

The text of a multi-line field: 13px on an 18.5px line, the pitch measured from the reference app’s settings textarea at 2x (37px), looser than text_control so lines of prose read apart.

§dock_drop: Hsla

The slot a lifted pane of a dock leaves and the place it will land: the accent at 30%, the drop overlay of Ghostty’s splits (Color.accentColor.opacity(0.3) in macos/Sources/Features/Splits/TerminalSplitTreeView.swift).

§dock_handle: Hsla

The ellipsis on a pane’s grab handle at rest: the text color at 30%, Ghostty’s .primary.opacity(0.3) in macos/Sources/Ghostty/Surface View/SurfaceGrabHandle.swift.

§dock_handle_hover: Hsla

The ellipsis on a hovered grab handle: the text color at 80%, Ghostty’s .primary.opacity(0.8) in the same file.

§dock_unfocused: Hsla

The fill over a pane of a split that does not have focus: the background at 30%, Ghostty’s default unfocused-split-opacity of 0.7 with unfocused-split-fill left to the background (src/config/Config.zig).

Implementations§

Source§

impl ThemeTokens

Source

pub fn is_dark(&self) -> bool

Whether the tokens are the dark set.

Source

pub fn colors(&self) -> &ColorTokens

The color tokens shared with base.

Source

pub fn background(&self) -> Hsla

The window background.

Source

pub fn foreground(&self) -> Hsla

Default text.

Source

pub fn primary(&self) -> Hsla

High-emphasis actions: the default button.

Source

pub fn primary_foreground(&self) -> Hsla

Text on a primary surface.

Source

pub fn secondary(&self) -> Hsla

Lower-emphasis filled actions and supporting surfaces.

Source

pub fn secondary_foreground(&self) -> Hsla

Text on a secondary surface.

Source

pub fn muted(&self) -> Hsla

Subtle surfaces.

Source

pub fn muted_foreground(&self) -> Hsla

Descriptions, placeholders, helper text.

Source

pub fn accent(&self) -> Hsla

Hover, focus, and active surfaces.

Source

pub fn accent_foreground(&self) -> Hsla

Text on an accent surface.

Source

pub fn destructive(&self) -> Hsla

Destructive actions and error emphasis.

Source

pub fn destructive_foreground(&self) -> Hsla

Text on a destructive surface.

Source

pub fn border(&self) -> Hsla

Default borders and separators.

Source

pub fn input(&self) -> Hsla

Form control borders.

Source

pub fn ring(&self) -> Hsla

Focus rings.

Source

pub fn focus_ring(&self) -> Hsla

The keyboard focus ring a control paints outside its box: the ring color at half strength, shadcn’s ring/50.

Source

pub fn selection(&self) -> Hsla

Selected text background.

Source

pub fn font_family(&self) -> &SharedString

Interface font family.

Source

pub fn mono_font_family(&self) -> &SharedString

Code font family.

Source

pub fn radius_sm(&self) -> Pixels

Radius for small controls: badges, checkboxes, menu items.

Source

pub fn radius_md(&self) -> Pixels

Radius for buttons, inputs, and menu rows.

Source

pub fn radius_lg(&self) -> Pixels

The base radius: cards, popovers, dialogs.

Source

pub fn radius_xl(&self) -> Pixels

Radius for large surfaces: sheets and window panels.

Source

pub fn radius_full(&self) -> Pixels

As round as the shape allows: circles and pills.

Trait Implementations§

Source§

impl Clone for ThemeTokens

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ThemeTokens

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ThemeTokens

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ThemeTokens

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more