Module dioxus

Source
Available on crate feature dio only.
Expand description

§🧬 Table RS Dioxus Usage

Adding Table RS to your project is simple:

  1. Make sure your project is set up with Dioxus. Refer to the Dioxus Getting Started Guide for setup instructions.

  2. Add the table-rs library to your dependencies by including it in your Cargo.toml file:

    cargo add table-rs --features=dio
  3. Import the Table component into your Dioxus application.

§🛠️ Usage

Incorporating Table RS into your Dioxus app involves just a few steps:

  1. Import the Table component and types:

    use dioxus::prelude::*;
    use table_rs::dioxus::table::Table;
    use table_rs::dioxus::types::Column;
    use maplit::hashmap;
  2. Use the Table component in your Dioxus app:

    use dioxus::prelude::*;
    use table_rs::dioxus::table::Table;
    use table_rs::dioxus::types::Column;
    use maplit::hashmap;
    
    
    fn App() -> Element {
        let data = vec![
            hashmap! { "name" => "Ferris".to_string(), "email" => "ferris@opensass.org".to_string() },
            hashmap! { "name" => "Ferros".to_string(), "email" => "ferros@opensass.org".to_string() },
            hashmap! { "name" => "Crab".to_string(), "email" => "crab@opensass.org".to_string() },
        ];
    
        let columns = vec![
            Column {
                id: "name",
                header: "Name",
                sortable: true,
                ..Default::default()
            },
            Column {
                id: "email",
                header: "Email",
                sortable: false,
                ..Default::default()
            },
        ];
    
        rsx! {
            Table {
                data: data,
                columns: columns,
            }
        }
    }

§🔧 Props

§Table Component Props

PropTypeDescriptionDefault
dataVec<HashMap<&'static str, String>>The row data to render.[]
columnsVec<Column>Column definitions.[]
page_sizeusizeNumber of rows per page.10
loadingboolShow loading state if true.false
paginateboolEnable pagination.false
searchboolEnable global search input.false
classesTableClassesCSS class overrides.Default
stylesHashMap<&'static str, &'static str>Inline style overrides.{}
textsTableTextsText customization for UI labels.Default

§Column Props

PropTypeDescriptionDefault
id&'static strColumn key (used to fetch from row data).""
header&'static strDisplay name in the table header.""
sortableboolAllow sorting on this column.false
styleOption<&'static str>Inline CSS for the header.Some(“padding: 8px; font-weight: 600; text-align: left;”)
classOption<&'static str>Optional class name for this column.Some(“table-header-cell”)

§TableClasses

PropTypeDescriptionDefault
container&'static strOuter container class."table-container"
table&'static strMain table class."table"
thead&'static strTable head (<thead>) class."thead"
tbody&'static strTable body (<tbody>) class."tbody"
row&'static strRow (<tr>) class."tr"
header_cell&'static strHeader cell (<th>) class."th"
body_cell&'static strBody cell (<td>) class."td"
loading_row&'static strRow shown when loading."loading-row"
empty_row&'static strRow shown when no data is available."empty-row"
search_input&'static strSearch input field class."search-input"
pagination&'static strPagination controls wrapper."pagination-controls"
pagination_button&'static strPagination buttons."pagination-button"

§TableTexts

PropTypeDescriptionDefault
loading&'static strText shown when loading."Loading..."
empty&'static strText when no data is present."No results found"
search_placeholder&'static strPlaceholder for search input."Search..."
previous_button&'static strLabel for previous page button."Previous"
next_button&'static strLabel for next page button."Next"
page_indicator&'static strFormat string for page indicator."Page {current} of {total}"

§🧱 Style/Layout Structure

+-------------------------------------------------------------+
|                      [container]                            |  <-- class: "table-container"
|                                                             |
|   +-----------------------------------------------------+   |
|   |                    [search_input]                   |   |  <-- class: "search-input"
|   |          (optional search <input> element)          |   |
|   +-----------------------------------------------------+   |
|                                                             |
|   +-----------------------------------------------------+   |
|   |                       [table]                       |   |  <-- class: "table"
|   |   +--------------------[thead]--------------------+ |   |  <-- class: "thead"
|   |   |   Column Headers (e.g., Name, Email)          | |   |
|   |   +-----------------------------------------------+ |   |
|   |   +--------------------[tbody]--------------------+ |   |  <-- class: "tbody"
|   |   |  Data rows (from `data` prop, each row = <tr>)| |   |
|   |   +-----------------------------------------------+ |   |
|   +-----------------------------------------------------+   |
|                                                             |
|   +-----------------------------------------------------+   |
|   |                  [pagination]                       |   |  <-- class: "pagination-controls"
|   |   Page selector / next-prev buttons (if enabled)    |   |
|   +-----------------------------------------------------+   |
+-------------------------------------------------------------+

§💡 Notes

  • The data must match the id values defined in each Column.
  • The search prop enables input-based filtering across all columns.
  • Pagination is controlled using the page_size and paginate props.
  • Sorting is column-specific via sortable = true and on_sort_column.
  • All style classes can be customized via TableClasses.
  • All texts are configurable via TableTexts.
  • The component handles loading and empty states out-of-the-box.
  • You can inject additional per-column styling via Column.style and Column.class.

Modules§

body
controls
header
table
types