Skip to main content

CssValue

Enum CssValue 

Source
#[non_exhaustive]
pub enum CssValue {
Show 15 variants Number(FiniteF64), Integer(i32), Length(CssLength), Percent(FiniteF64), Angle(CssAngle), Time(CssTime), Color(CssColor), Fr(NonNegativeFiniteF64), Auto, Zero, Inherit, Initial, Unset, Revert, RevertLayer,
}
Expand description

A closed union of typed CSS component values.

This type is useful for storing heterogeneous primitives. It is not a declaration grammar: property-specific APIs accept narrower types and are the only values that integrate directly with Leptos style attributes.

§Ergonomics

Use the free convenience functions for common values:

use leptos_css::{px, em, rem, pct, deg};

let width = px(100);
let margin = em(0.6);
let offset = pct(50);
let rotation = deg(45);

Arbitrary strings and unchecked function bodies are intentionally absent. Unsupported CSS must be written outside this typed API until its grammar is modeled.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Number(FiniteF64)

A bare floating-point number (e.g., opacity, flex-grow).

§

Integer(i32)

A bare integer (e.g., z-index, order).

§

Length(CssLength)

A CSS length value (px, em, rem, vh, vw, etc.).

§

Percent(FiniteF64)

A percentage value.

§

Angle(CssAngle)

A CSS angle value (deg, rad, turn, grad).

§

Time(CssTime)

A CSS time value (s, ms).

§

Color(CssColor)

A CSS color value (rgb, rgba, hsl, hsla, named).

§

Fr(NonNegativeFiniteF64)

Fractional units for CSS Grid (e.g., 1fr).

§

Auto

The CSS auto keyword.

§

Zero

Zero with unit for calc() compatibility. Renders as "0px".

§

Inherit

The CSS inherit keyword.

§

Initial

The CSS initial keyword.

§

Unset

The CSS unset keyword.

§

Revert

The CSS revert keyword.

§

RevertLayer

The CSS revert-layer keyword.

Trait Implementations§

Source§

impl Clone for CssValue

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 CssWriteTo for CssValue

Source§

fn css_fmt<W: Write>(&self, w: &mut W) -> Result

Write the CSS representation to a fmt::Write target.
Source§

fn write_to(&self, buf: &mut String)

Write the CSS representation directly to a String buffer. Read more
Source§

impl Debug for CssValue

Source§

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

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

impl Display for CssValue

Source§

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

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

impl From<CssAngle> for CssValue

Source§

fn from(a: CssAngle) -> Self

Converts to this type from the input type.
Source§

impl From<CssColor> for CssValue

Source§

fn from(c: CssColor) -> Self

Converts to this type from the input type.
Source§

impl From<CssDimension> for CssValue

Source§

fn from(dim: CssDimension) -> Self

Converts to this type from the input type.
Source§

impl From<CssLength> for CssValue

Source§

fn from(l: CssLength) -> Self

Converts to this type from the input type.
Source§

impl From<CssTime> for CssValue

Source§

fn from(t: CssTime) -> Self

Converts to this type from the input type.
Source§

impl From<CssValue> for String

Source§

fn from(value: CssValue) -> Self

Converts to this type from the input type.
Source§

impl From<CssValue> for Cow<'static, str>

Source§

fn from(value: CssValue) -> Self

Converts to this type from the input type.
Source§

impl From<FiniteF64> for CssValue

Source§

fn from(v: FiniteF64) -> Self

Converts to this type from the input type.
Source§

impl From<GlobalKeyword> for CssValue

Source§

fn from(keyword: GlobalKeyword) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for CssValue

Source§

fn from(v: i32) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for CssValue

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 CssValue

Source§

impl TryFrom<f64> for CssValue

Source§

type Error = InvalidCssNumber

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

fn try_from(v: f64) -> Result<Self, Self::Error>

Performs the conversion.

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> CheckedCssValue for T
where T: CssWriteTo + Sealed,

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<E, T, Request, Encoding> FromReq<Patch<Encoding>, Request, E> for T
where Request: Req<E> + Send + 'static, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_req(req: Request) -> Result<T, E>

Attempts to deserialize the arguments from a request.
Source§

impl<E, T, Request, Encoding> FromReq<Post<Encoding>, Request, E> for T
where Request: Req<E> + Send + 'static, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_req(req: Request) -> Result<T, E>

Attempts to deserialize the arguments from a request.
Source§

impl<E, T, Request, Encoding> FromReq<Put<Encoding>, Request, E> for T
where Request: Req<E> + Send + 'static, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_req(req: Request) -> Result<T, E>

Attempts to deserialize the arguments from a request.
Source§

impl<E, Encoding, Response, T> FromRes<Patch<Encoding>, Response, E> for T
where Response: ClientRes<E> + Send, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_res(res: Response) -> Result<T, E>

Attempts to deserialize the outputs from a response.
Source§

impl<E, Encoding, Response, T> FromRes<Post<Encoding>, Response, E> for T
where Response: ClientRes<E> + Send, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_res(res: Response) -> Result<T, E>

Attempts to deserialize the outputs from a response.
Source§

impl<E, Encoding, Response, T> FromRes<Put<Encoding>, Response, E> for T
where Response: ClientRes<E> + Send, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_res(res: Response) -> Result<T, E>

Attempts to deserialize the outputs from a response.
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<E, T, Encoding, Request> IntoReq<Patch<Encoding>, Request, E> for T
where Request: ClientReq<E>, Encoding: Encodes<T>, E: FromServerFnError,

Source§

fn into_req(self, path: &str, accepts: &str) -> Result<Request, E>

Attempts to serialize the arguments into an HTTP request.
Source§

impl<E, T, Encoding, Request> IntoReq<Post<Encoding>, Request, E> for T
where Request: ClientReq<E>, Encoding: Encodes<T>, E: FromServerFnError,

Source§

fn into_req(self, path: &str, accepts: &str) -> Result<Request, E>

Attempts to serialize the arguments into an HTTP request.
Source§

impl<E, T, Encoding, Request> IntoReq<Put<Encoding>, Request, E> for T
where Request: ClientReq<E>, Encoding: Encodes<T>, E: FromServerFnError,

Source§

fn into_req(self, path: &str, accepts: &str) -> Result<Request, E>

Attempts to serialize the arguments into an HTTP request.
Source§

impl<E, Response, Encoding, T> IntoRes<Patch<Encoding>, Response, E> for T
where Response: TryRes<E>, Encoding: Encodes<T>, E: FromServerFnError + Send, T: Send,

Source§

async fn into_res(self) -> Result<Response, E>

Attempts to serialize the output into an HTTP response.
Source§

impl<E, Response, Encoding, T> IntoRes<Post<Encoding>, Response, E> for T
where Response: TryRes<E>, Encoding: Encodes<T>, E: FromServerFnError + Send, T: Send,

Source§

async fn into_res(self) -> Result<Response, E>

Attempts to serialize the output into an HTTP response.
Source§

impl<E, Response, Encoding, T> IntoRes<Put<Encoding>, Response, E> for T
where Response: TryRes<E>, Encoding: Encodes<T>, E: FromServerFnError + Send, T: Send,

Source§

async fn into_res(self) -> Result<Response, E>

Attempts to serialize the output into an HTTP response.
Source§

impl<T> SerializableKey for T

Source§

fn ser_key(&self) -> String

Serializes the key to a unique string. Read more
Source§

impl<T> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more