Data tables
Comparison table
A bounded feature matrix with semantic values and sticky context.
Starts when it scrolls into view
NORD FROST · DARK · RADIUS 6/10 · BASE 16PX · SHADOW
- Type
ComparisonTable- Source
comparison_table.rs- Story
comparison-table- Demo height
- 432 px
- Events
- ComparisonTableEvent
Code
Cut from the gallery story this page runs. The states above change what the demo is given rather than how it is built, so they share this code.
fn comparison_story_snapshot(item_states: &[ComparisonItemState]) -> ComparisonSnapshot {
let labels = [
"Starter",
"Business",
"Enterprise with dedicated regional support",
];
let items = labels.into_iter().enumerate().map(|(index, label)| {
ComparisonItem::new(format!("plan-{index}"), label)
.description(format!("Plan {} details", index + 1))
.state(
item_states
.get(index)
.copied()
.unwrap_or(ComparisonItemState::Default),
)
});
ComparisonSnapshot::try_new(
items,
[
ComparisonFeature::new("price", "Monthly price").values([
ComparisonValue::new("plan-0", "$12"),
ComparisonValue::new("plan-1", "$24"),
ComparisonValue::new("plan-2", "Custom"),
]),
ComparisonFeature::new("seats", "Included team seats").values([
ComparisonValue::new("plan-0", "3"),
ComparisonValue::new("plan-1", "25"),
ComparisonValue::new("plan-2", "Unlimited"),
]),
ComparisonFeature::new("support", "Priority support").values([
ComparisonValue::included("plan-0", false),
ComparisonValue::included("plan-1", true),
ComparisonValue::included("plan-2", true),
]),
],
)
.expect("gallery comparison fixture must satisfy the bounded contract")
}
let mut table = ComparisonTable::new(id, label, window, cx);
table.set_snapshot(snapshot, window, cx);
if let Some(selected) = selected {
table.set_selected_item(selected, window, cx);
}
table
Events and ownership
- Who owns the state
- ComparisonTable renders state supplied by the application; it does not own durable work.
- What it emits
- Interactive intent is reported through the typed ComparisonTableEvent contract and stable application IDs.
- What it means
- A bounded feature matrix with semantic values and sticky context.
- Overflow and motion
- Wide content retains context in a bounded surface; reduced motion preserves a useful state.
Event types
- ComparisonTableEvent
What the demo does and does not show
The demo above is the same Rust as the native component, compiled to WebAssembly and drawn on a WebGPU canvas — not a mock-up, a recording, or a re-implementation. What it paints is what the component paints: layout, colour from the live theme, and motion.
The live browser specimen requires WebGPU; the native component remains the authoritative runtime.
A canvas cannot stand in for the platform, so treat everything that goes through the operating system as unproven here: keyboard handling and shortcuts, screen reader semantics, text input and IME, the clipboard, file drops, and the frame rate you would get on your own GPU. Judge those in a native build. If your browser has no WebGPU, the frame says so rather than showing an empty box.