Skip to main content

SizeClass

Enum SizeClass 

Source
pub enum SizeClass {
    Compact,
    Medium,
    Expanded,
}
Expand description

How much screen there is, independent of what is pointing at it.

The second axis, and the one Density kept being asked to carry. A phone is small and touch; a tablet and a touchscreen laptop are big and touch; a half-width window on a desktop is small and pointer. Those are four real combinations and one axis cannot name them, which is what made the old Touch preset tighten shells it had no business tightening.

Boundaries are quoted, not derived, for the same reason the Gap values are: a derived boundary is one nobody can check. They are Material 3’s window size classes, the best-known three-tier split with published numbers. Apple’s size classes are two-tier and expressed as regular/compact per axis, which does not give a middle to aim at.

Source: https://m3.material.io/foundations/layout/applying-layout/window-size-classes

This enum carries the boundaries only. What appears, disappears or reflows at each is a product decision and belongs to makeover-touch, not here. Deliberately absent for now: size class does not feed Gap::step_at. Whether shells should tighten on a compact window is a look call of exactly the kind that produced the 2026-07-29 demolition, so it waits for an eyeball rather than being derived a second time.

Variants§

§

Compact

Under 600px. Phones in either orientation, and any window narrowed to phone width regardless of what is pointing at it.

§

Medium

600px to 839px. Small tablets, split-screen panes, half-width windows.

§

Expanded

840px and up. Laptops, desktops, tablets in landscape.

Implementations§

Source§

impl SizeClass

Source

pub const fn min_px(self) -> u16

Lower bound in CSS pixels, inclusive. Self::Compact starts at zero.

Source

pub fn media_condition(self) -> String

The media condition selecting exactly this class, without the @media.

Bounded on both sides for the middle class, so the three are mutually exclusive and a rule cannot land in two of them. max-width is one below the next class’s min_px, because CSS width ranges are inclusive.

Source

pub const fn token(self) -> &'static str

The CSS class name an app may hang off this, without the leading dot.

Source

pub const fn all() -> [Self; 3]

Every class, narrowest first.

Source

pub const fn at_width(px: u16) -> Self

The class a given viewport width falls in.

Trait Implementations§

Source§

impl Clone for SizeClass

Source§

fn clone(&self) -> SizeClass

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 Copy for SizeClass

Source§

impl Debug for SizeClass

Source§

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

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

impl Default for SizeClass

Source§

fn default() -> SizeClass

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

impl Eq for SizeClass

Source§

impl Hash for SizeClass

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for SizeClass

Source§

fn cmp(&self, other: &SizeClass) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for SizeClass

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl PartialOrd for SizeClass

Source§

fn partial_cmp(&self, other: &SizeClass) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for SizeClass

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<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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.