Skip to main content

Radius

Enum Radius 

Source
pub enum Radius {
    Square,
    Fine,
    Control,
    Panel,
    Round,
}
Expand description

How rounded a corner is, named for what the corner belongs to.

The third axis to make the same move as Gap and Text: name the thing and let the value follow. Whether a corner should be 3px or 4px is unanswerable in isolation, and answering it once per component is how a stylesheet ends up with 2, 3, 4, 6, 8 and 12 all meaning “slightly rounded”.

§Rounding is an affordance

The scale is deliberately short, because a corner radius carries one bit of meaning: whether the thing is meant to be pressed. Self::Square exists as a named rung rather than as the absence of a radius so that a container states that it is square, and a reader can tell a deliberate zero from a rule nobody wrote.

Variants§

§

Square

No rounding. Containers: cards, panels, dropdowns, page shells.

§

Fine

An eighth of the base. The tightest corner still visible: inline code, small badges, status chips.

§

Control

A quarter of the base. Controls: buttons, inputs, selects.

§

Panel

Half the base. Surfaces that round rather than sit square: media covers, callout boxes, feature cards.

§

Round

A circle, whatever the element’s size.

Implementations§

Source§

impl Radius

Source

pub const fn ratio(self) -> Option<Ratio>

This corner as a fraction of the base unit.

Self::Round has none, and that is not an oversight: 50% is a proportion of the element’s own box rather than of the base, so it does not scale with --geometry-base and cannot be written as a Ratio. Use Self::css, which spells every rung.

Source

pub const fn px(self) -> Option<u16>

Size in CSS pixels at the default base, or None for Self::Round.

Source

pub fn css(self) -> String

The CSS value for this rung.

Square emits a bare 0 rather than a calc() that multiplies the base by nothing, and Round emits the percentage.

Source

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

The CSS custom-property name, without the leading --.

Source

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

Every rung, squarest first.

Trait Implementations§

Source§

impl Clone for Radius

Source§

fn clone(&self) -> Radius

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 Radius

Source§

impl Debug for Radius

Source§

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

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

impl Eq for Radius

Source§

impl Hash for Radius

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 PartialEq for Radius

Source§

fn eq(&self, other: &Radius) -> 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 Radius

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.