Skip to main content

LayoutTheme

Struct LayoutTheme 

Source
#[non_exhaustive]
pub struct LayoutTheme {
Show 19 fields pub spacing: Pixels, pub radius: Pixels, pub field_radius: Pixels, pub border_width: Pixels, pub field_border_width: Pixels, pub disabled_opacity: f32, pub ring_offset_width: Pixels, pub surface_shadow: Vec<BoxShadow>, pub overlay_shadow: Vec<BoxShadow>, pub field_shadow: Vec<BoxShadow>, pub skeleton_animation: SkeletonAnimation, pub tooltip_delay_ms: u64, pub tooltip_close_delay_ms: u64, pub overlay_hairline: Option<Hsla>, pub cursor_interactive: CursorStyle, pub tabs_hover_opacity: f32, pub tooltip_cooldown_ms: u64, pub long_press_ms: u64, pub hover_fade_ms: u64,
}
Expand description

Spacing, radius, border and shadow tokens shared by all components.

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.
§spacing: Pixels

--spacing: 0.25rem

§radius: Pixels

--radius: 0.5rem — the base every other radius is calculated from.

§field_radius: Pixels

--field-radius: calc(var(--radius) * 1.5)

§border_width: Pixels

--border-width: 1px

§field_border_width: Pixels

--field-border-width: 0px

§disabled_opacity: f32

--disabled-opacity: 0.5

§ring_offset_width: Pixels

--ring-offset-width: 2px

§surface_shadow: Vec<BoxShadow>

--surface-shadow — cards, accordions and other inline containers.

§overlay_shadow: Vec<BoxShadow>

--overlay-shadow — tooltips, popovers, modals and menus.

§field_shadow: Vec<BoxShadow>

--field-shadow — inputs and other form controls.

§skeleton_animation: SkeletonAnimation

--skeleton-animation

§tooltip_delay_ms: u64

--tooltip-delay: 1500ms

§tooltip_close_delay_ms: u64

--tooltip-close-delay: 500ms

§overlay_hairline: Option<Hsla>

The hairline a floating panel draws instead of a border.

v3 gives its panels no border at all: light mode separates them with --overlay-shadow, and dark mode adds 0 0 1px 0 rgba(255,255,255,.3) **inset** – a one-pixel highlight just inside the edge. gpui has no inset shadow, so the closest reproduction is a one-pixel border in that colour, and in light mode there is none.

§cursor_interactive: CursorStyle

The cursor an interactive control shows while the pointer is over it.

v3 gives every clickable control cursor: pointer, so the default is gpui::CursorStyle::PointingHand — the variant GPUI’s own Styled::cursor_pointer() sets, which keeps stock rendering identical. A theme that wants the platform arrow everywhere sets gpui::CursorStyle::Arrow once here instead of restyling components.

§tabs_hover_opacity: f32

The opacity a hovered Tabs item drops to.

v3 hardcodes opacity: 0.7 on an unselected .tabs__tab:hover; this port names it so a theme can soften or disable the dim. Not a v3 CSS variable, and not consumed by Link: its root hover draws an underline.

§tooltip_cooldown_ms: u64

The warm window after the pointer leaves a tooltip during which the next tip opens without its delay.

The cooldown starts when the tooltip is dismissed (hover exit) and lasts max(this, close_delay), so a per-tooltip close delay extends the window. React Aria uses the same 500 ms.

§long_press_ms: u64

How long a DropdownTrigger::LongPress waits before it opens.

React Aria uses 500 ms.

§hover_fade_ms: u64

The background fade duration anim::hover_fade eases between two colors. The default is the button’s own 100ms (anim::TRANSITION_MS); zero resolves immediately, like reduced motion.

Implementations§

Source§

impl LayoutTheme

Source

pub fn light() -> Self

Source

pub fn dark() -> Self

Source

pub fn radius_xs(&self) -> Pixels

--radius-xs: calc(var(--radius) * 0.25)

Source

pub fn radius_sm(&self) -> Pixels

--radius-sm: calc(var(--radius) * 0.5)

Source

pub fn radius_md(&self) -> Pixels

--radius-md: calc(var(--radius) * 0.75)

Source

pub fn radius_lg(&self) -> Pixels

--radius-lg: calc(var(--radius) * 1)

Source

pub fn radius_xl(&self) -> Pixels

--radius-xl: calc(var(--radius) * 1.5)

Source

pub fn radius_2xl(&self) -> Pixels

--radius-2xl: calc(var(--radius) * 2)

Source

pub fn radius_3xl(&self) -> Pixels

--radius-3xl: calc(var(--radius) * 3)

Source

pub fn radius_4xl(&self) -> Pixels

--radius-4xl: calc(var(--radius) * 4)

Source

pub fn capped(&self, radius: Pixels) -> Pixels

A radius capped the way v3 caps its own: min(32px, ..).

v3 wraps every rounded-* and rounded-full in min() so a theme with an oversized --radius cannot distort a component — the corner stops growing before it swallows the box.

Trait Implementations§

Source§

impl Clone for LayoutTheme

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 LayoutTheme

Source§

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

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

impl Default for LayoutTheme

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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