hydroxy

Saved views

A dropdown of saved filter presets. Pick one, save the current filters under a name, rename or delete the active one, or make it the view to open with. It keeps ids and names; you keep the filters.

  • Import September tickets · open
  • Tag the Q3 interviews · open
  • Export interview notes · open

Usage

use std::collections::HashMap;

use hydroxy_leptos::saved_views::*;
use leptos::prelude::*;

#[derive(Clone, PartialEq)]
struct Filter {
    status: &'static str,
    query: String,
}

const TICKETS: [(&str, &str); 6] = [
    ("Import September tickets", "open"),
    ("Tag the Q3 interviews", "open"),
    ("Draft the weekly digest", "closed"),
    ("Check sources on the board update", "closed"),
    ("Export interview notes", "open"),
    ("Archive 2025 notes", "closed"),
];

pub fn demo() -> AnyView {
    let filter = RwSignal::new(Filter { status: "open", query: String::new() });
    // The component keeps names and ids; the filters behind each id live here.
    let stored = StoredValue::new(HashMap::from([
        ("open".to_string(), Filter { status: "open", query: String::new() }),
        ("closed".to_string(), Filter { status: "closed", query: String::new() }),
    ]));

    let on_change = move |command: SavedViewsCommand| match command {
        SavedViewsCommand::Created(view) => stored.update_value(|m| {
            m.insert(view.id, filter.get_untracked());
        }),
        SavedViewsCommand::ActiveChange(Some(id)) => {
            if let Some(f) = stored.with_value(|m| m.get(&id).cloned()) {
                filter.set(f);
            }
        }
        SavedViewsCommand::Deleted(id) => stored.update_value(|m| {
            m.remove(&id);
        }),
        _ => {}
    };

    let shown = move || {
        let f = filter.get();
        TICKETS
            .iter()
            .filter(|(title, status)| {
                (f.status == "all" || *status == f.status) && title.to_lowercase().contains(&f.query.to_lowercase())
            })
            .map(|(title, status)| view! { <li>{*title} " · " {*status}</li> })
            .collect_view()
    };

    view! {
        <div style="display: grid; gap: var(--space-4); max-width: 520px;">
            <div style="display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3);">
                <SavedViews
                    default_views=vec![SavedView::new("open", "Open tickets"), SavedView::new("closed", "Closed tickets")]
                    default_active="open"
                    default_view="open"
                    on_change=on_change
                />
                <select
                    aria-label="Status"
                    prop:value=move || filter.get().status
                    on:change=move |ev| {
                        let status = match event_target_value(&ev).as_str() {
                            "open" => "open",
                            "closed" => "closed",
                            _ => "all",
                        };
                        filter.update(|f| f.status = status);
                    }
                >
                    <option value="all">"All"</option>
                    <option value="open">"Open"</option>
                    <option value="closed">"Closed"</option>
                </select>
                <input
                    type="search"
                    aria-label="Search tickets"
                    placeholder="Search"
                    prop:value=move || filter.get().query
                    on:input=move |ev| filter.update(|f| f.query = event_target_value(&ev))
                />
            </div>
            <ul style="margin: 0; padding-left: var(--space-5); font: var(--text-sm); color: var(--text-2);">{shown}</ul>
        </div>
    }
    .into_any()
}

Anatomy

Componentdata-partRenders
SavedViewsrootWrapper
Menutrigger, content, itemThe view list and actions, from the Menu component
(inside)currentThe active view's name in the trigger, or "Views"
(inside)check, name, default-markIn each view row: a check on the active one, its name, and a Default mark
(inside)separator, emptyDivider before the actions; a note when there are no views
Dialogcontent, title, description, actionsThe save-as, rename and delete prompt, from the Dialog component
(inside)form<form>: Enter in the name field submits

Keyboard

KeyDoes
ArrowDown / ArrowUpMoves through the views and actions in the open menu
Enter / SpacePicks the highlighted view or runs the action
EscapeCloses the menu, or the prompt
Enter (in the name field)Saves or renames

Props

PropTypeNotes
viewsOption<Vec<SavedView>>Controlled views. Pair with on_change and apply
default_viewsVec<SavedView>Initial views when uncontrolled. Each has an id and a name
activeOption<String>Controlled active view id
default_activeOption<String>Initially active view id when uncontrolled
default_viewOption<String>The view to open with, such as one loaded from storage
on_changeCallback<SavedViewsCommand>Created(view), Renamed, Deleted, ActiveChange(Option<id>) and DefaultChange(Option<id>)
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