hydroxy

Virtual list

A listbox that only renders the rows in view, so 100,000 rows scroll as smoothly as 100. Rows can be a fixed height or measured as they render, group headers stick until the next group pushes them off, and the keyboard moves through every row with the active one always announced.

Nothing selected
22:09The Gym Group£49.19
21:38Amazon Marketplace£3.18
21:10Sainsbury's£15.14
20:39Transport for London£63.13
20:11Boots£75.09
19:40Deliveroo£29.08
Tom FletcherCan someone with access to the billing account check whether the October invoice went out? I paired with Priya on the flaky search test. It was a timezone assumption in the fixture, not the code, so the fix is a one-liner in the test data.
Lena BrandtLooks good to me.
Tom FletcherMoved the release to Thursday so QA has a full day on the payments flow. The import job retried three times overnight and then succeeded; I've added an alert so we hear about it next time rather than finding out from the dashboard.
Lena BrandtShipped.
Tom FletcherCan someone with access to the billing account check whether the October invoice went out? I paired with Priya on the flaky search test. It was a timezone assumption in the fixture, not the code, so the fix is a one-liner in the test data.
Lena BrandtLooks good to me.
Tom FletcherMoved the release to Thursday so QA has a full day on the payments flow. The import job retried three times overnight and then succeeded; I've added an alert so we hear about it next time rather than finding out from the dashboard.

Usage

use hydroxy_leptos::button::{Button, ButtonSize, ButtonVariant};
use hydroxy_leptos::virtual_list::{Align, VirtualList};
use leptos::prelude::*;

/// A date header, then 40 card payments.
const GROUP: usize = 41;
/// Days of history: 100,040 rows in all.
const DAYS: usize = 2440;
const MERCHANTS: [&str; 12] = [
    "Pret A Manger",
    "Transport for London",
    "Sainsbury's",
    "Waterstones",
    "Deliveroo",
    "Boots",
    "Spotify",
    "Uber",
    "Tesco Express",
    "Caffè Nero",
    "Amazon Marketplace",
    "The Gym Group",
];
const NOTES: [&str; 6] = [
    "Moved the release to Thursday so QA has a full day on the payments flow.",
    "Looks good to me.",
    "The import job retried three times overnight and then succeeded; I've added an alert so we hear about it next time rather than finding out from the dashboard.",
    "Can someone with access to the billing account check whether the October invoice went out?",
    "Shipped.",
    "I paired with Priya on the flaky search test. It was a timezone assumption in the fixture, not the code, so the fix is a one-liner in the test data.",
];
const PEOPLE: [&str; 5] = ["Amara Okafor", "Priya Shah", "Tom Fletcher", "Lena Brandt", "Jonah Reyes"];

fn mix(i: usize) -> usize {
    i.wrapping_mul(2_654_435_761) % 1_000_003
}

/// `Wed 28 Oct 2026`, `back` days before 28 October 2026.
fn date(back: usize) -> String {
    const MONTHS: [&str; 12] = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
    const WEEKDAYS: [&str; 7] = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
    // Days since 1970-01-01, then the civil date (Howard Hinnant's algorithm).
    let days = 20_754 - back;
    let z = days + 719_468;
    let era = z / 146_097;
    let doe = z - era * 146_097;
    let yoe = (doe - doe / 1460 + doe / 36_524 - doe / 146_096) / 365;
    let doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
    let mp = (5 * doy + 2) / 153;
    let day = doy - (153 * mp + 2) / 5 + 1;
    let month = if mp < 10 { mp + 3 } else { mp - 9 };
    let year = yoe + era * 400 + usize::from(month <= 2);
    format!("{} {day} {} {year}", WEEKDAYS[(days + 4) % 7], MONTHS[month - 1])
}

/// Merchant, time and amount for payment row `i`.
fn payment(i: usize) -> (&'static str, String, String) {
    let h = mix(i);
    let minutes = 1380 - (i % GROUP) * 32 - h % 20;
    let pence = 120 + h % 9_400;
    (
        MERCHANTS[h % MERCHANTS.len()],
        format!("{:02}:{:02}", minutes / 60, minutes % 60),
        format!("£{}.{:02}", pence / 100, pence % 100),
    )
}

pub fn demo() -> AnyView {
    let rows = DAYS * GROUP;
    let headers: Vec<usize> = (0..DAYS).map(|d| d * GROUP).collect();
    let (jump, set_jump) = signal(None::<(usize, Align)>);
    let (picked, set_picked) = signal(None::<usize>);
    let summary = move || {
        picked.get().map_or_else(
            || "Nothing selected".to_string(),
            |i| {
                let (merchant, time, amount) = payment(i);
                format!("{merchant}, {amount} at {time} on {}", date(i / GROUP))
            },
        )
    };

    view! {
        <div style="display: grid; gap: 24px; max-width: 760px;">
            <div style="display: grid; gap: 10px;">
                <div style="display: flex; flex-wrap: wrap; align-items: center; gap: 8px;">
                    <Button variant=ButtonVariant::Secondary size=ButtonSize::Sm on_click=move |_| set_jump.set(Some((0, Align::Start)))>
                        "Today"
                    </Button>
                    <Button variant=ButtonVariant::Secondary size=ButtonSize::Sm on_click=move |_| set_jump.set(Some((365 * GROUP, Align::Start)))>
                        "A year ago"
                    </Button>
                    <Button variant=ButtonVariant::Secondary size=ButtonSize::Sm on_click=move |_| set_jump.set(Some((50_001, Align::Center)))>
                        "Row 50,001"
                    </Button>
                    <span style="font-size: 13px; color: var(--text-3);" aria-live="polite">{summary}</span>
                </div>
                <div style="height: 360px;">
                    <VirtualList
                        label="Card payments"
                        count=rows
                        headers=headers
                        row_height=40.0
                        header_height=32.0
                        scroll_to=jump
                        on_select=move |i: usize| set_picked.set(Some(i))
                        row=move |i: usize| {
                            if i.is_multiple_of(GROUP) {
                                view! { <span>{date(i / GROUP)}</span> }.into_any()
                            } else {
                                let (merchant, time, amount) = payment(i);
                                view! {
                                    <span style="width: 3.2em; color: var(--text-3); font-variant-numeric: tabular-nums;">{time}</span>
                                    <span style="flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;">{merchant}</span>
                                    <span style="font-variant-numeric: tabular-nums;">{amount}</span>
                                }
                                .into_any()
                            }
                        }
                    />
                </div>
            </div>
            <div style="height: 320px;">
                <VirtualList
                    label="Team notes"
                    count=5000_usize
                    measure=true
                    row_height=64.0
                    row=move |i: usize| {
                        let h = mix(i + 7);
                        let note = NOTES[h % NOTES.len()];
                        let more = h.is_multiple_of(3).then(|| NOTES[(h / 3) % NOTES.len()]);
                        view! {
                            <div style="display: grid; gap: 2px; min-width: 0; padding: 4px 0;">
                                <strong style="font-size: 12.5px;">{PEOPLE[h % PEOPLE.len()]}</strong>
                                <span style="white-space: normal; color: var(--text-2);">{note}{more.map(|m| format!(" {m}"))}</span>
                            </div>
                        }
                        .into_any()
                    }
                />
            </div>
        </div>
    }
    .into_any()
}

Anatomy

Componentdata-partRenders
VirtualListrootFrame around the list; carries the focus ring
viewportThe scrolling role=listbox. Holds focus; aria-activedescendant names the active row. data-measured when measuring
spacerSized to the whole list so the scrollbar is true
grouprole=group box spanning one group's rows, labelled by its header
group-labelThe header. position: sticky inside its group
itemrole=option with aria-setsize and aria-posinset for the whole list. data-active, data-selected, data-index
emptyShown when there are no rows

Keyboard

KeyDoes
Arrow Down / Arrow UpNext or previous option, skipping headers
Page Down / Page UpAbout a screen further or back
Home / EndFirst or last option
Enter / SpaceSelect the active option

Props

PropTypeNotes
countusizeNumber of rows, headers included
rowCallback<usize, AnyView>Renders row index, option or header
labelStringAccessible name for the listbox
row_heightf64Exact row height, or the first guess when measuring. Default 36
header_heightOption<f64>Header height. Defaults to row_height
headersVec<usize>Indexes of sticky group header rows
measureboolMeasure rows as they render, for content-sized rows
overscanusizeRows kept rendered beyond each edge. Default 6
default_selectedOption<usize>Option selected at first
on_selectCallback<usize>Called when an option is chosen
scroll_toOption<(usize, Align)>Set to scroll a row into view: Start, Center, End or Auto
emptyStringText when there are no rows
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