pub struct ClassesBuilder { /* private fields */ }Expand description
Builder for Classes.
Implementations§
Source§impl ClassesBuilder
impl ClassesBuilder
Sourcepub fn with(self, name: impl Into<ClassName>) -> Self
pub fn with(self, name: impl Into<ClassName>) -> Self
Adds one always-active class token to the builder.
Validation policy matches Classes::add.
Sourcepub fn with_reactive(
self,
name: impl Into<ClassName>,
when: impl Into<ClassCondition>,
) -> Self
pub fn with_reactive( self, name: impl Into<ClassName>, when: impl Into<ClassCondition>, ) -> Self
Adds one reactive class token, controlled by when.
Validation policy for name matches Classes::add. See
Classes::add_reactive for the list of accepted when shapes.
Sourcepub fn with_all<I>(self, iter: I) -> Self
pub fn with_all<I>(self, iter: I) -> Self
Adds multiple always-active class tokens to the builder. Same short-circuit panic
behavior as Classes::add_all.
Sourcepub fn with_parsed(self, input: &str) -> Self
pub fn with_parsed(self, input: &str) -> Self
Splits input on Unicode whitespace (str::split_whitespace) and adds each non-empty
token as an always-active class entry. Empty or whitespace-only input is a no-op. Same
duplicate-panic and whitespace-semantic behavior as Classes::add_parsed.
Sourcepub fn with_toggle(
self,
when: impl Into<ClassCondition>,
when_true: impl Into<ClassName>,
when_false: impl Into<ClassName>,
) -> Self
pub fn with_toggle( self, when: impl Into<ClassCondition>, when_true: impl Into<ClassName>, when_false: impl Into<ClassName>, ) -> Self
Adds a pair of mutually exclusive reactive classes. Mirrors Classes::add_toggle.
See Classes::add_reactive for the list of accepted when shapes.
§Example
use leptos::prelude::*;
use leptos_classes::Classes;
let (is_active, _) = signal(true);
let classes = Classes::builder()
.with_toggle(is_active, "active", "inactive")
.build();Sourcepub fn with_merged(self, other: Classes, strategy: MergeStrategy) -> Self
pub fn with_merged(self, other: Classes, strategy: MergeStrategy) -> Self
Merges another Classes value into this builder. See Classes::merge for semantics
and the MergeStrategy variants.
Prefer MergeStrategy::default() (which is
UnionConditions) unless you specifically need
KeepSelf or
PanicOnConflict. It is the only strategy that never
panics on caller input and never silently discards a caller-supplied condition.
Trait Implementations§
Source§impl Clone for ClassesBuilder
impl Clone for ClassesBuilder
Source§fn clone(&self) -> ClassesBuilder
fn clone(&self) -> ClassesBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ClassesBuilder
impl Debug for ClassesBuilder
Source§impl Default for ClassesBuilder
impl Default for ClassesBuilder
Source§fn default() -> ClassesBuilder
fn default() -> ClassesBuilder
Auto Trait Implementations§
impl Freeze for ClassesBuilder
impl RefUnwindSafe for ClassesBuilder
impl Send for ClassesBuilder
impl Sync for ClassesBuilder
impl Unpin for ClassesBuilder
impl UnsafeUnpin for ClassesBuilder
impl UnwindSafe for ClassesBuilder
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more