Skip to main content

Component

Trait Component 

pub trait Component:
    ComponentKey
    + PartialEq
    + 'static {
    // Required method
    fn render(&self) -> impl IntoElement;

    // Provided method
    fn render_key(&self) -> DiffKey { ... }
}
Expand description

Encapsulate reusable pieces of UI by using the Component trait. Every Component creates a new layer of state in the app, meaning that implementors of Component can make use of hooks in their Component::render method.

#[derive(PartialEq)]
struct ReusableCounter {
    pub init_number: u8,
}

impl Component for ReusableCounter {
    fn render(&self) -> impl IntoElement {
        let mut number = use_state(|| self.init_number);
        label()
            .on_press(move |_| {
                *number.write() += 1;
            })
            .text(number.read().to_string())
    }
}

Required Methods§

fn render(&self) -> impl IntoElement

Provided Methods§

fn render_key(&self) -> DiffKey

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Component for CameraViewer

§

impl Component for CodeEditor

§

impl Component for EditorLineUI

§

impl Component for Accordion

§

impl Component for Activable

§

impl Component for ArrowIcon

§

impl Component for Attached

§

impl Component for Button

§

impl Component for ButtonSegment

§

impl Component for Calendar

§

impl Component for Card

§

impl Component for Checkbox

§

impl Component for Chip

§

impl Component for CircularLoader

§

impl Component for ColorPicker

§

impl Component for CursorArea

§

impl Component for Draggable

§

impl Component for DraggableCanvas

§

impl Component for FloatingTab

§

impl Component for GifViewer

§

impl Component for ImageViewer

§

impl Component for Input

§

impl Component for MarkdownViewer

§

impl Component for OverflowedContent

§

impl Component for Popup

§

impl Component for PopupBackground

§

impl Component for PopupButtons

§

impl Component for PopupContent

§

impl Component for PopupTitle

§

impl Component for ProgressBar

§

impl Component for RadioItem

§

impl Component for ResizableContainer

§

impl Component for ResizableDraggable

§

impl Component for ResizableHandle

§

impl Component for ResizablePanel

§

impl Component for ScrollView

§

impl Component for SegmentedButton

§

impl Component for Select

§

impl Component for SelectableText

§

impl Component for SideBarItem

§

impl Component for Skeleton

§

impl Component for Slider

§

impl Component for Switch

§

impl Component for Table

§

impl Component for TableArrow

§

impl Component for TableBody

§

impl Component for TableCell

§

impl Component for TableHead

§

impl Component for TableRow

§

impl Component for TickIcon

§

impl Component for Tile

§

impl Component for TitlebarButton

§

impl Component for Tooltip

§

impl Component for TooltipContainer

§

impl Component for Ripple

§

impl Component for RippleButton

§

impl Component for RippleFloatingTab

§

impl Component for RippleMenuItem

§

impl Component for RippleSideBarItem

§

impl Component for RippleTile

§

impl Component for WebView

§

impl Component for AppComponent

§

impl<D, B> Component for VirtualScrollView<D, B>
where D: PartialEq + 'static, B: Fn(usize, &D) -> Element + 'static,

§

impl<M> Component for DockingArea<M>
where M: DockingModel,

§

impl<R> Component for AnimatedRouter<R>
where R: Routable + 'static + PartialEq,

Provide a mechanism for freya_router::prelude::Outlet to animate between route changes.

See the animated_router.rs example to see how to use it.

§

impl<R> Component for Outlet<R>
where R: Routable,

§

impl<R> Component for Router<R>
where R: Routable + Clone,

§

impl<T> Component for ActivableRoute<T>
where T: PartialEq + Clone + 'static + Routable,

§

impl<T> Component for DragZone<T>
where T: Clone + PartialEq,

§

impl<T> Component for DropZone<T>
where T: Clone + PartialEq + 'static,

§

impl<T> Component for Portal<T>
where T: PartialEq + 'static + Clone + Hash + Eq + Debug,

§

impl<T> Component for T