pub enum Variant {
Transparent,
Default,
Secondary,
Tertiary,
Custom(&'static str),
}Expand description
Semantic prominence level of a [Card] component.
Each variant maps to a distinct background-color class so that themes can interpret โprominenceโ differently without hard-coding specific palettes into component logic.
ยงDefault
Variant::Default is the default variant.
ยงExamples
use card_rs::Variant;
let cls = Variant::Tertiary.to_class();
assert_eq!(cls, "card--tertiary");
let style = Variant::Transparent.to_style();
assert!(style.contains("transparent"));Variantsยง
Transparent
Minimal prominence, transparent background.
Use for less important content or for cards nested inside other cards.
Default
Standard card appearance (bg-surface). This is the default.
Suitable for most use cases.
Secondary
Medium prominence (bg-surface-secondary).
Use to draw moderate attention.
Tertiary
Higher prominence (bg-surface-tertiary).
Use for primary or featured content.
Custom(&'static str)
Arbitrary inline CSS styling for the variant.
E.g. "background: linear-gradient(...);".
Implementationsยง
Sourceยงimpl Variant
impl Variant
Sourcepub fn to_class(self) -> &'static str
pub fn to_class(self) -> &'static str
Returns the BEM modifier CSS class for this variant.
ยงReturns
One of "card--transparent", "card--default", "card--secondary",
or "card--tertiary".
Sourcepub fn to_style(self) -> &'static str
pub fn to_style(self) -> &'static str
Returns the inline CSS background/border style for this variant.
These values mirror the HeroUI design token mapping:
transparentโ no backgrounddefaultโ#ffffffsurface with a subtle bordersecondaryโ light gray surfacetertiaryโ slightly warmer surface
Trait Implementationsยง
impl Copy for Variant
impl StructuralPartialEq for Variant
Auto Trait Implementationsยง
impl Freeze for Variant
impl RefUnwindSafe for Variant
impl Send for Variant
impl Sync for Variant
impl Unpin for Variant
impl UnsafeUnpin for Variant
impl UnwindSafe for Variant
Blanket Implementationsยง
impl<Token, Builder, How> AllPropsFor<Builder, How> for Tokenwhere
Builder: Buildable<Token>,
<Builder as Buildable<Token>>::WrappedToken: HasAllProps<<Builder as Buildable<Token>>::Output, How>,
Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DependencyElement for T
impl<T> HasAllProps<(), T> for T
Sourceยงimpl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Sourceยงfn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Sourceยงimpl<T> Instrument for T
impl<T> Instrument for T
Sourceยงfn instrument(self, span: Span) -> Instrumented<Self> โ
fn instrument(self, span: Span) -> Instrumented<Self> โ
Sourceยงfn in_current_span(self) -> Instrumented<Self> โ
fn in_current_span(self) -> Instrumented<Self> โ
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self> โ
fn into_either(self, into_left: bool) -> Either<Self, Self> โ
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 moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
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 moreSourceยงimpl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Sourceยงfn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
self to a value of a Properties struct.Sourceยงimpl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Sourceยงfn into_prop_value(self) -> T
fn into_prop_value(self) -> T
self to a value of a Properties struct.