pub enum Color {
Default,
Accent,
Success,
Warning,
Danger,
}Expand description
Color theme applied to the [Badge] component.
Each variant maps to a distinct palette across all three visual variants
(primary, secondary, soft).
ยงDefault
Color::Default is the default variant.
ยงExamples
use badges_rs::Color;
let style = Color::Danger.to_primary_style();
assert!(style.contains("#dc2626"));
let cls = Color::Accent.to_class();
assert_eq!(cls, "badge--accent");Variantsยง
Default
Neutral gray.
Accent
Accent purple: #7c3aed.
Success
Success green: #16a34a.
Warning
Warning amber: #d97706.
Danger
Danger red: #dc2626.
Implementationsยง
Sourceยงimpl Color
impl Color
Sourcepub fn to_class(self) -> &'static str
pub fn to_class(self) -> &'static str
Returns the BEM modifier CSS class for this color.
ยงReturns
One of "badge--default", "badge--accent", "badge--success",
"badge--warning", or "badge--danger".
Sourcepub fn to_primary_style(self) -> &'static str
pub fn to_primary_style(self) -> &'static str
Returns the filled (primary variant) inline CSS for this color.
Uses a saturated background with white text.
Sourcepub fn to_secondary_style(self) -> &'static str
pub fn to_secondary_style(self) -> &'static str
Returns the outlined (secondary variant) inline CSS for this color.
Uses a white background with a coloured border and matching text.
Sourcepub fn to_soft_style(self) -> &'static str
pub fn to_soft_style(self) -> &'static str
Returns the tinted (soft variant) inline CSS for this color.
Uses a lightly tinted background with the full-strength text color.
Trait Implementationsยง
impl Copy for Color
impl StructuralPartialEq for Color
Auto Trait Implementationsยง
impl Freeze for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnsafeUnpin for Color
impl UnwindSafe for Color
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.