pub struct Table { /* private fields */ }Available on crate feature
yew only.Expand description
A fully featured table component with pagination, sorting, and search support.
This component renders a complete <table> element, including headers (<thead>), body (<tbody>),
and optional features such as client-side sorting, pagination, and search input.
It is built using Yew and supports flexible styling and customization.
§Arguments
props- The properties passed to the component.data- AVec<HashMap<&'static str, String>>representing the table’s row data.columns- AVec<Column>defining the structure and behavior of each column.page_size- Ausizedefining how many rows to show per page.loading- Aboolindicating whether the table is in a loading state.classes- ATableClassesstruct for customizing class names of elements.styles- AHashMap<&'static str, &'static str>for inline style overrides.paginate- Aboolcontrolling whether pagination controls are displayed.search- Aboolenabling a search input above the table.texts- ATableTextsstruct for customizing placeholder and fallback texts.
§Features
- Client-side search with URL hydration via
?search= - Column sorting (ascending/descending toggle)
- Pagination controls
- Custom class and inline style support
- Displays a loading row or empty state message when appropriate
§Returns
(Html): A complete, styled and interactive table component rendered in Yew.
§Examples
use yew::prelude::*;
use maplit::hashmap;
use table_rs::yew::table::Table;
use table_rs::yew::types::{Column, TableClasses, TableTexts};
#[function_component(App)]
pub fn app() -> Html {
let data = vec![
hashmap! { "name" => "Ferris".into(), "email" => "ferris@opensass.org".into() },
hashmap! { "name" => "Ferros".into(), "email" => "ferros@opensass.org".into() },
];
let columns = vec![
Column { id: "name", header: "Name", sortable: true, ..Default::default() },
Column { id: "email", header: "Email", sortable: false, ..Default::default() },
];
html! {
<Table
data={data}
columns={columns}
page_size={10}
loading={false}
paginate={true}
search={true}
classes={TableClasses::default()}
texts={TableTexts::default()}
/>
}
}§See Also
Trait Implementations§
Source§impl BaseComponent for Tablewhere
Self: 'static,
impl BaseComponent for Tablewhere
Self: 'static,
Source§type Properties = TableProps
type Properties = TableProps
The Component’s Properties.
Source§fn update(&mut self, _ctx: &Context<Self>, _msg: Self::Message) -> bool
fn update(&mut self, _ctx: &Context<Self>, _msg: Self::Message) -> bool
Updates component’s internal state.
Source§fn changed(
&mut self,
_ctx: &Context<Self>,
_old_props: &Self::Properties,
) -> bool
fn changed( &mut self, _ctx: &Context<Self>, _old_props: &Self::Properties, ) -> bool
React to changes of component properties.
Source§fn view(&self, ctx: &Context<Self>) -> HtmlResult
fn view(&self, ctx: &Context<Self>) -> HtmlResult
Returns a component layout to be rendered.
Source§fn rendered(&mut self, _ctx: &Context<Self>, _first_render: bool)
fn rendered(&mut self, _ctx: &Context<Self>, _first_render: bool)
Notified after a layout is rendered.
Source§fn prepare_state(&self) -> Option<String>
fn prepare_state(&self) -> Option<String>
Prepares the server-side state.
Source§impl FunctionProvider for Table
impl FunctionProvider for Table
Source§type Properties = TableProps
type Properties = TableProps
Properties for the Function Component.
Source§fn run(ctx: &mut HookContext, props: &Self::Properties) -> HtmlResult
fn run(ctx: &mut HookContext, props: &Self::Properties) -> HtmlResult
Auto Trait Implementations§
impl !Freeze for Table
impl !RefUnwindSafe for Table
impl !Send for Table
impl !Sync for Table
impl Unpin for Table
impl !UnwindSafe for Table
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> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Create an instance of this type from an initialization function
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Source§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
Convert
self to a value of a Properties struct.Source§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Source§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
Convert
self to a value of a Properties struct.Source§impl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.