pub struct Class<T>(pub T);Expand description
A space-separated list of HTML classes.
Prefer constructing Class with the class!
macro. The entries live inline in the value (a single entry, a tuple, an
array, or a Vec), so building a class list performs no allocation of
its own; the entries are written directly into the surrounding view when
the attribute value is emitted.
A Class is used in the attribute value position of an element, where a
class list without present entries omits the whole attribute:
view! {
<button class=(class!("btn", "active" if is_active))>"Save"</button>
}Tuple Fields§
§0: TTrait Implementations§
Source§impl<T> AttributeValueViewParts for Class<T>where
T: ClassEntries,
impl<T> AttributeValueViewParts for Class<T>where
T: ClassEntries,
Source§fn attribute_present(&self) -> bool
fn attribute_present(&self) -> bool
Returns whether the containing attribute should be rendered. Read more
Source§fn into_view_parts(self, cx: &Cx, parts: &mut PartsWriter<'_>)
fn into_view_parts(self, cx: &Cx, parts: &mut PartsWriter<'_>)
Appends this attribute value to the view being built.
Source§impl<T> ClassViewParts for Class<T>where
T: ClassEntries,
impl<T> ClassViewParts for Class<T>where
T: ClassEntries,
Source§fn is_present(&self) -> bool
fn is_present(&self) -> bool
Returns whether this value contributes to the class list. Read more
Source§fn into_view_parts(self, cx: &Cx, parts: &mut PartsWriter<'_>)
fn into_view_parts(self, cx: &Cx, parts: &mut PartsWriter<'_>)
Appends this value to the class list being built.
impl<T: Copy> Copy for Class<T>
Auto Trait Implementations§
impl<T> Freeze for Class<T>where
T: Freeze,
impl<T> RefUnwindSafe for Class<T>where
T: RefUnwindSafe,
impl<T> Send for Class<T>where
T: Send,
impl<T> Sync for Class<T>where
T: Sync,
impl<T> Unpin for Class<T>where
T: Unpin,
impl<T> UnsafeUnpin for Class<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Class<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more
Source§impl<T> ClassEntries for Twhere
T: ClassViewParts,
impl<T> ClassEntries for Twhere
T: ClassViewParts,
Source§fn any_present(&self) -> bool
fn any_present(&self) -> bool
Returns whether any entry contributes to the class list.
Source§fn write_entries(self, cx: &Cx, writer: &mut ClassWriter<'_, '_>)
fn write_entries(self, cx: &Cx, writer: &mut ClassWriter<'_, '_>)
Writes every entry through
writer.