Skip to main content

ListItem

Struct ListItem 

Source
pub struct ListItem { /* private fields */ }
Expand description

A list item

Implementations§

Source§

impl ListItem

Source

pub fn new() -> ListItem

Create a new list item

Source

pub fn child(self, child: impl ElementBuilder + 'static) -> ListItem

Add content to the list item

Source

pub fn child_box(self, child: Box<dyn ElementBuilder>) -> ListItem

Add a boxed child element (for dynamic element types)

Methods from Deref<Target = Div>§

Source

pub fn element_id(&self) -> Option<&str>

Get the element ID if set

Source

pub fn classes(&self) -> &[String]

Get the element’s class list

Source

pub fn stateful_context_key(&self) -> Option<&str>

Get the stateful context key if set

Source

pub fn swap(&mut self) -> Div

Swap this Div with a default, returning the original

This is a convenience method for use in state callbacks where you need to consume self to chain builder methods, then assign back.

Note: This takes ownership of the current Div and leaves a default in its place. All properties are preserved in the returned Div. You must assign the result back to complete the update.

For updating specific properties without the swap pattern, consider using the setter methods directly (e.g., set_bg(), set_transform()).

§Example
.on_state(|state, div| match state {
    ButtonState::Idle => {
        *div = div.swap().bg(Color::BLUE).rounded(4.0);
    }
    ButtonState::Hovered => {
        *div = div.swap().bg(Color::CYAN).rounded(8.0);
    }
})
Source

pub fn set_bg(&mut self, color: impl Into<Brush>)

Set the background color/brush without consuming self

This is useful in state callbacks where you want to update properties without using the swap pattern.

Source

pub fn set_rounded(&mut self, radius: f32)

Set the corner radius without consuming self

Source

pub fn set_transform(&mut self, transform: Transform)

Set the transform without consuming self

Source

pub fn set_shadow(&mut self, shadow: Shadow)

Set the shadow without consuming self

Source

pub fn set_opacity(&mut self, opacity: f32)

Set the opacity without consuming self

Source

pub fn set_border(&mut self, width: f32, color: Color)

Set border with width and color without consuming self

Source

pub fn set_overflow_clip(&mut self, clip: bool)

Set overflow clip without consuming self

Source

pub fn set_padding_x(&mut self, px: f32)

Set horizontal padding without consuming self

Source

pub fn set_padding_y(&mut self, px: f32)

Set vertical padding without consuming self

Source

pub fn set_child(&mut self, child: impl ElementBuilder + 'static)

Clear all children and add a single child

Source

pub fn clear_children(&mut self)

Clear all children

Source

pub fn set_w(&mut self, px: f32)

Set width in pixels without consuming self

This is useful in state callbacks where you want to update layout properties without using the swap pattern.

Source

pub fn set_h(&mut self, px: f32)

Set height in pixels without consuming self

Source

pub fn set_h_auto(&mut self)

Set height to auto without consuming self

Source

pub fn set_style(&mut self, style: &ElementStyle)

Apply an ElementStyle without consuming self

This is useful in state callbacks where you want to update styling without using the swap pattern.

§Example
.on_state(|state, div| {
    div.set_style(&hover_style);
})
Source

pub fn merge(&mut self, other: Div)

Merge properties from another Div into this one

This applies the other Div’s non-default properties on top of this one. Useful in on_state callbacks to apply changes without reassignment:

.on_state(|state, div| {
    div.merge(div().bg(color).child(label));
})
Source

pub fn style_mut(&mut self) -> &mut Style

Get direct access to the taffy style for advanced configuration

Source

pub fn event_handlers(&self) -> &EventHandlers

Get a reference to the event handlers

Source

pub fn event_handlers_mut(&mut self) -> &mut EventHandlers

Get a mutable reference to the event handlers

Trait Implementations§

Source§

impl Default for ListItem

Source§

fn default() -> ListItem

Returns the “default value” for a type. Read more
Source§

impl Deref for ListItem

Source§

type Target = Div

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<ListItem as Deref>::Target

Dereferences the value.
Source§

impl DerefMut for ListItem

Source§

fn deref_mut(&mut self) -> &mut <ListItem as Deref>::Target

Mutably dereferences the value.
Source§

impl ElementBuilder for ListItem

Source§

fn build(&self, tree: &mut LayoutTree) -> LayoutNodeId

Build this element into a layout tree, returning the node ID
Source§

fn render_props(&self) -> RenderProps

Get the render properties for this element
Source§

fn children_builders(&self) -> &[Box<dyn ElementBuilder>]

Get children builders (for recursive traversal)
Source§

fn element_type_id(&self) -> ElementTypeId

Get the element type identifier
Source§

fn semantic_type_name(&self) -> Option<&'static str>

Semantic HTML-like tag name for CSS type selectors (e.g., “button”, “a”, “ul”) Read more
Source§

fn element_id(&self) -> Option<&str>

Get the element ID for selector API queries Read more
Source§

fn element_classes(&self) -> &[String]

Get the element’s CSS class list for selector matching
Source§

fn text_render_info(&self) -> Option<TextRenderInfo>

Get text render info if this is a text element
Source§

fn styled_text_render_info(&self) -> Option<StyledTextRenderInfo>

Get styled text render info if this is a styled text element (rich_text)
Source§

fn svg_render_info(&self) -> Option<SvgRenderInfo>

Get SVG render info if this is an SVG element
Source§

fn image_render_info(&self) -> Option<ImageRenderInfo>

Get image render info if this is an image element
Source§

fn canvas_render_info( &self, ) -> Option<Rc<dyn Fn(&mut dyn DrawContext, CanvasBounds)>>

Get canvas render info if this is a canvas element
Source§

fn event_handlers(&self) -> Option<&EventHandlers>

Get event handlers for this element Read more
Source§

fn scroll_info(&self) -> Option<ScrollRenderInfo>

Get scroll render info if this is a scroll element
Source§

fn scroll_physics(&self) -> Option<Arc<Mutex<ScrollPhysics>>>

Get scroll physics handle if this is a scroll element
Source§

fn motion_animation_for_child( &self, _child_index: usize, ) -> Option<MotionAnimation>

Get motion animation config for a child at given index Read more
Source§

fn motion_bindings(&self) -> Option<MotionBindings>

Get motion bindings for continuous animation Read more
Source§

fn motion_stable_id(&self) -> Option<&str>

Get stable ID for motion animation tracking Read more
Source§

fn motion_should_replay(&self) -> bool

Check if this motion should replay its animation Read more
Source§

fn motion_is_suspended(&self) -> bool

Check if this motion should start in suspended state Read more
Source§

fn motion_is_exiting(&self) -> bool

👎Deprecated since 0.1.0:

Use query_motion(key).exit() to explicitly trigger motion exit

DEPRECATED: Check if this motion should start its exit animation Read more
Source§

fn layout_style(&self) -> Option<&Style>

Get the layout style for this element Read more
Source§

fn layout_bounds_storage(&self) -> Option<Arc<Mutex<Option<ElementBounds>>>>

Get layout bounds storage for this element Read more
Source§

fn layout_bounds_callback( &self, ) -> Option<Arc<dyn Fn(ElementBounds) + Send + Sync>>

Get layout bounds change callback for this element Read more
Source§

fn set_auto_id(&mut self, _id: String) -> bool

Set an auto-generated element ID (used by stateful containers for stable child IDs). Read more
Source§

fn children_builders_mut(&mut self) -> &mut [Box<dyn ElementBuilder>]

Get mutable access to children for auto-ID assignment
Source§

fn bound_scroll_ref(&self) -> Option<&ScrollRef>

Get the bound ScrollRef for programmatic scroll control Read more
Source§

fn motion_on_ready_callback( &self, ) -> Option<Arc<dyn Fn(ElementBounds) + Send + Sync>>

Get the on_ready callback for this motion container Read more
Source§

fn layout_animation_config(&self) -> Option<LayoutAnimationConfig>

Get layout animation configuration for this element Read more
Source§

fn visual_animation_config(&self) -> Option<VisualAnimationConfig>

Get visual animation config for new FLIP-style animations (read-only layout) Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more