pub struct StatProps {
pub label: String,
pub value: String,
pub detail: String,
pub detail_icon: Option<IconData>,
pub detail_icon_label: String,
pub accent: String,
pub chart: Vec<f64>,
pub icon: Option<IconData>,
pub href: Option<String>,
pub attrs: Attributes,
}Expand description
One figure for a dashboard: what it counts, the value, and an optional line under it. With an
href the whole tile is a link, such as to the list the figure counts.
Lay several out in a grid of your own:
view! {
<div class="grid gap-4 sm:grid-cols-2 xl:grid-cols-4">
stat(
label: "Posts",
value: "66",
detail: "65 drafts",
icon: icons::FILE_TEXT,
href: "/admin/posts".to_string(),
)
stat(
label: "Comments",
value: "4",
detail: "2 more than last week",
detail_icon: icons::ARROW_UP,
accent: "text-success",
chart: vec![1.0, 3.0, 2.0, 4.0],
)
</div>
}Fields§
§label: StringWhat the value counts, e.g. "Posts".
value: StringThe figure, formatted, e.g. "1,204" or "98%".
detail: StringOptional line under the value, e.g. "12 this week".
detail_icon: Option<IconData>Optional icon before the detail line, such as an arrow for its trend.
detail_icon_label: StringWhat the detail icon says to a screen reader, e.g. "Up"; the icon alone is hidden from
it.
accent: StringThe text-color class of the detail line and the chart, e.g. "text-success"; muted when
empty.
chart: Vec<f64>Optional values the tile draws as a sparkline under the value, oldest first. Fewer than two finite values draw none.
icon: Option<IconData>Optional icon before the label.
href: Option<String>Optional URL the tile links to.
attrs: AttributesExtra attributes for the tile.
Implementations§
Source§impl StatProps
impl StatProps
Sourcepub fn builder() -> StatPropsBuilder<label, value>
pub fn builder() -> StatPropsBuilder<label, value>
Returns a StatPropsBuilder with no properties set.