pub fn TableBody(_: TableBodyProps) -> ElementAvailable on crate feature
dio only.Expand description
A table body component that renders rows of data, along with loading and empty states.
This component is responsible for rendering the <tbody> section of a table in a Dioxus application.
It dynamically displays row data, a loading message, or an empty state message based on the provided props.
§Props
columns: AVec<Column>defining which fields to render in each table row. Each column corresponds to a key in the row data.rows: AVec<HashMap<&'static str, String>>representing the data for each row, where keys match column IDs.loading: Aboolflag that, when true, displays a loading message instead of data rows.classes: ATableClassesstruct for customizing the CSS class names of the body, rows, and cells.texts: ATableTextsstruct that provides custom text for the loading and empty states.
§Behavior
- If
loadingistrue, a single row with a loading message is shown spanning all columns. - If
rowsis empty and not loading, an empty message row is displayed. - Otherwise, each data row is rendered in a
<tr>, with one<td>per column.
§Returns
A Dioxus Element representing the <tbody> of a table, with dynamic row content.
§Example
use dioxus::prelude::*;
use maplit::hashmap;
use table_rs::dioxus::table::Table;
use table_rs::dioxus::types::{Column, TableClasses, TableTexts};
use table_rs::dioxus::body::TableBody;
fn App() -> Element {
let rows = vec![
hashmap! { "name" => "Ferris".to_string(), "email" => "ferris@opensass.org".to_string() },
hashmap! { "name" => "Rustacean".to_string(), "email" => "rust@opensass.org".to_string() },
];
let columns = vec![
Column { id: "name", header: "Name", ..Default::default() },
Column { id: "email", header: "Email", ..Default::default() },
];
rsx! {
TableBody {
columns: columns,
rows: rows,
loading: false,
classes: TableClasses::default(),
texts: TableTexts::default(),
}
}
}§See Also
§Props
For details, see the props struct definition.