hydroxy

Dashboard layout

Widget tiles on a column grid. Drag a tile by its handle, resize it from the corner, or do both from the keyboard. Tiles in the way make room.

Press Enter or Space to pick up the widget. Use the arrow keys to move it and Shift with the arrow keys to resize it. Press Enter or Space to drop it, or Escape to cancel.

Revenue

This month

£48.2k

+8%

Signups

This week

312

−3%

Churn

Last 30 days

1.9%

steady

Weekly active

PointValue112214313417516621724823928

Notes

Resize a tile from its corner. Shift with the arrow keys resizes from the keyboard.

Drag a tile by its handle, or focus a handle and press Enter.

Usage

use hydroxy_leptos::dashboard_layout::{DashboardItem, DashboardLayout, Widget};
use hydroxy_leptos::sparkline::Sparkline;
use hydroxy_leptos::stat_card::{DeltaTone, Jewel, StatCard};
use leptos::prelude::*;

fn revenue() -> impl IntoView {
    view! { <StatCard label="This month" value="£48.2k" delta="+8%" delta_tone=DeltaTone::Up jewel=Jewel::Emerald /> }
}

fn signups() -> impl IntoView {
    view! { <StatCard label="This week" value="312" delta="−3%" delta_tone=DeltaTone::Down jewel=Jewel::Sapphire /> }
}

fn churn() -> impl IntoView {
    view! { <StatCard label="Last 30 days" value="1.9" unit="%" caption="steady" jewel=Jewel::Amethyst /> }
}

fn trend() -> impl IntoView {
    let values = Signal::stored(vec![12.0, 14.0, 13.0, 17.0, 16.0, 21.0, 24.0, 23.0, 28.0]);
    view! { <Sparkline values=values label="Weekly active users" width=420 height=80 area=true /> }
}

fn notes() -> impl IntoView {
    view! { <p style="margin: 0;">"Resize a tile from its corner. Shift with the arrow keys resizes from the keyboard."</p> }
}

#[component]
pub fn Demo() -> impl IntoView {
    let (last, set_last) = signal(String::from("Drag a tile by its handle, or focus a handle and press Enter."));
    let widgets = vec![
        Widget::new("revenue", "Revenue", revenue),
        Widget::new("signups", "Signups", signups),
        Widget::new("churn", "Churn", churn),
        Widget::new("trend", "Weekly active", trend),
        Widget::new("notes", "Notes", notes),
    ];
    let items = vec![
        DashboardItem::new("revenue", 0, 0, 4, 3),
        DashboardItem::new("signups", 4, 0, 4, 3),
        DashboardItem::new("churn", 8, 0, 4, 3),
        DashboardItem::new("trend", 0, 3, 8, 3),
        DashboardItem::new("notes", 8, 3, 4, 3),
    ];

    let on_change = move |items: Vec<DashboardItem>| {
        let line: Vec<String> = items.iter().map(|i| format!("{} ({}, {}) {}×{}", i.id, i.x, i.y, i.w, i.h)).collect();
        set_last.set(line.join(" · "));
    };

    view! {
        <div style="display: grid; gap: var(--space-4);">
            <DashboardLayout
                widgets=widgets
                default_items=items
                on_layout_change=on_change
            />
            <p style="margin: 0; font: var(--text-label); color: var(--text-3);">{last}</p>
        </div>
    }
}

Anatomy

Componentdata-partRenders
DashboardLayoutrootWrapper for the board and its screen reader text
boardrole=group CSS grid. --ox-dashboard-columns, --ox-dashboard-row and --ox-dashboard-gap set by inline style. data-dragging during a pointer drag
item<article> per widget, placed with grid-column and grid-row. data-active while moving
handle<button> in the tile header. aria-pressed while picked up with the keyboard
resizeCorner grip for pointers. Hidden from assistive tech
instructionsVisually hidden keyboard help, linked from every handle by aria-describedby
liverole=status region that announces pick-up, moves, drop and cancel

Keyboard

KeyDoes
Enter / SpaceOn a handle: picks the tile up, or drops it
Arrow keysWhile carrying: move the tile one cell
Shift + Arrow keysWhile carrying: resize the tile one cell
EscapePuts the tile back where it started
TabMoves between handles; leaving a carried tile drops it

Props

PropTypeNotes
widgetsVec<Widget>Required. Widget::new(id, title, content). Each id needs an item in the layout
itemsOption<Vec<DashboardItem>>Controlled layout. Pair with on_layout_change
default_itemsVec<DashboardItem>Initial layout when uncontrolled. DashboardItem::new(id, x, y, w, h)
columnsu32Columns in the grid. Default 12
row_heightf64Row height in px. Default 72
gapf64Gap between tiles in px. Default 12
disabledboolBlock every move and resize
on_layout_changeCallback<Vec<DashboardItem>>Called with the whole layout when a gesture ends in a change
labelStringAccessible name for the board
Actions
Button
Icon button
Toolbar
Theme menu
Display
Avatar
Badge
Card
Chip
Code block
Markdown
Doc card
Due pill
Kbd
Priority mark
Source chip
Space icon
Status diamond
Tag
Value diff
Carousel
Reveal
Media timeline
QR code
Transcript viewer
Audio waveform
Audio player
Forms
Calendar
Checkbox
Combobox
Date picker
Color picker
Cron builder
Theme editor
Mention input
Signature pad
Image cropper
Date field
Date range picker
Duration field
Quantity stepper
Filter chip
Input
Markdown editor
Radio group
Search field
Segmented control
Select
Slider
Range slider
Rating
Toggle button
File dropzone
Upload queue
Attachment
Switch
Tags input
Number field
Money field
Phone field
Time field
OTP input
Password field
Questionnaire
Availability picker
Voice input
Recording control
Inline edit
Async validated input
Shortcut recorder
Data
Spreadsheet grid
Week scheduler
Virtual list
Stat card
Step track
Kanban board
Sortable list
Filter builder
Data table
Grid
Access editor
File manager
Gantt chart
Log stream
Diff viewer
JSON inspector
Terminal
Node editor
Whiteboard
Navigation
Table of contents
Breadcrumb
Tabs
Wizard
Nav item
Nav section
Tree view
Pagination
Menubar
Navigation menu
Saved views
Layout
Master detail
App shell
Sidebar layout
Resizable panels
Dashboard layout
Dock layout
Feedback
Callout
Check list
Empty state
Progress bar
Toast
Approval card
Skeleton
Notification center
Bars
Bar chart
Diverging bar chart
Span chart
Pictogram chart
Stacked bar chart
Funnel chart
Bullet chart
Waffle chart
Marimekko chart
Dot plot chart
Error bar chart
Pareto chart
Waterfall chart
Lollipop chart
Grouped bar chart
Bar race chart
KPIs and frames
Chart frame
Metric card
Sparkline
Points
Scatter chart
Smith chart
Strip plot
Beeswarm chart
Parallel coordinates
Ternary chart
Bland-Altman chart
Quiver chart
Connected scatter chart
Grids and tables
Heatmap chart
Chart table
Cohort chart
Radial
Radial charts
Radar chart
Polar area chart
Stat ring
Clock chart
Spiral chart
Lines and areas
Bump chart
Slope chart
Line chart
Composed chart
Small multiples
Cycle plot chart
Horizon chart
Stacked area chart
Threshold chart
Split line chart
Linked charts
Confidence band chart
Forecast fan chart
Step chart
Range area chart
Distributions
Contour chart
Histogram
Box plot
Density chart
Ridgeline chart
Violin chart
Q-Q chart
Survival chart
ECDF chart
Raincloud plot
Forest plot
Maps
Geo map
Bubble map
Hexbin map
Cartogram
Flow map
Parts of a whole
Donut chart
Voronoi treemap
Nested donut chart
Treemap chart
Sunburst chart
Bubble pack chart
Icicle chart
Flame graph chart
Pie chart
Word cloud
Relationships
Sankey chart
Network chart
Chord chart
UpSet chart
Venn chart
Alluvial chart
Adjacency matrix chart
Dependency graph chart
Tree chart
Arc diagram
Hive plot
Edge bundling
Finance
Candlestick chart
OHLC chart
Depth chart
Renko chart
Time
Timeline chart
Calendar heatmap chart
Spectrogram chart
Marey chart
Overlays
Tour
Lightbox
Alert dialog
Command palette
Dialog
Menu
Popover
Tooltip
Sheet
Hover card
Context menu
Utilities
Pacer
Hotkeys
Disclosure
Accordion
Collapsible
Chat
Chat bubble
Voice session
Composer
Thread
Thread list
Assistant composer
Assistant MCP
Assistant modal
Assistant thread
Assistant thread list
Message scroller
Insight note
Emoji picker
Tool trace
Model picker
Citation popover
Activity
Activity feed
Comment thread
Timeline
Presence bar
Live cursors
Reaction bar
Guides
Getting started
All components
All charts