#[repr(C)]pub struct Chip {
pub chip_state: ChipStateWrapper,
pub label: AzString,
pub kind: ChipKind,
pub removable: bool,
pub container_style: CssPropertyWithConditionsVec,
}Expand description
A compact rounded pill holding a label plus an optional removable “x”.
Fields§
§chip_state: ChipStateWrapperRuntime state (visible) plus the optional remove callback.
label: AzStringThe text shown inside the pill.
kind: ChipKindThe colour variant.
removable: boolWhether to render the “x” remove affordance (hides the chip on click).
container_style: CssPropertyWithConditionsVecThe computed inline style for the pill container.
Implementations§
Source§impl Chip
impl Chip
Sourcepub fn create(label: AzString) -> Self
pub fn create(label: AzString) -> Self
Creates a new chip with the given label and the default (light-grey) kind.
Sourcepub fn with_kind(label: AzString, kind: ChipKind) -> Self
pub fn with_kind(label: AzString, kind: ChipKind) -> Self
Creates a new chip with the given label and colour variant.
Sourcepub fn set_kind(&mut self, kind: ChipKind)
pub fn set_kind(&mut self, kind: ChipKind)
Sets the colour variant, recomputing the container style.
Sourcepub fn with_chip_kind(self, kind: ChipKind) -> Self
pub fn with_chip_kind(self, kind: ChipKind) -> Self
Builder-style setter for the colour variant.
Sourcepub const fn set_removable(&mut self, removable: bool)
pub const fn set_removable(&mut self, removable: bool)
Sets whether the chip shows a “x” remove affordance.
Sourcepub const fn with_removable(self, removable: bool) -> Self
pub const fn with_removable(self, removable: bool) -> Self
Builder-style setter for the removable flag.
Sourcepub fn set_on_remove<C: Into<ChipOnRemoveCallback>>(
&mut self,
data: RefAny,
on_remove: C,
)
pub fn set_on_remove<C: Into<ChipOnRemoveCallback>>( &mut self, data: RefAny, on_remove: C, )
Sets the remove callback. Implies removable = true so the “x” is rendered.
Sourcepub fn with_on_remove<C: Into<ChipOnRemoveCallback>>(
self,
data: RefAny,
on_remove: C,
) -> Self
pub fn with_on_remove<C: Into<ChipOnRemoveCallback>>( self, data: RefAny, on_remove: C, ) -> Self
Builder-style setter for the remove callback (implies removable).
Sourcepub fn set_on_click<C: Into<ChipOnClickCallback>>(
&mut self,
data: RefAny,
on_click: C,
)
pub fn set_on_click<C: Into<ChipOnClickCallback>>( &mut self, data: RefAny, on_click: C, )
Sets the click callback, invoked when the chip’s label area is clicked.
Sourcepub fn with_on_click<C: Into<ChipOnClickCallback>>(
self,
data: RefAny,
on_click: C,
) -> Self
pub fn with_on_click<C: Into<ChipOnClickCallback>>( self, data: RefAny, on_click: C, ) -> Self
Builder-style setter for the click callback.
Sourcepub fn swap_with_default(&mut self) -> Self
pub fn swap_with_default(&mut self) -> Self
Replaces self with an empty default chip and returns the original.
Trait Implementations§
impl Eq for Chip
impl StructuralPartialEq for Chip
Auto Trait Implementations§
impl Freeze for Chip
impl RefUnwindSafe for Chip
impl Send for Chip
impl Sync for Chip
impl Unpin for Chip
impl UnsafeUnpin for Chip
impl UnwindSafe for Chip
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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