Components · Navigation
Saved Views
BetaAdded v5.5.0
A menu to switch, save, update and delete saved filter views. Your app stores them.
import { SavedViews } from '@nexub/react';Playground
Props
<SavedViews views={views} activeId={active} onSelect={setActive} onSave={…} onUpdate={() => {}} onDelete={…} />Examples
Views for a deals table
Async, with a default view
Save, rename and delete wait on a request. Saving an existing name fails; deleting asks first.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| viewsrequired | SavedView[] | — | The saved views. |
| activeId | string | — | The view in use; its name shows on the button. |
| onSelectrequired | (id: string) => void | — | Switch to a view: restore its filters, sort and columns. |
| onSave | ((name: string) => MaybeAsync) | — | Adds "Save as new view…", which asks for a name. A returned promise keeps the dialog busy; a rejection shows its message. |
| onUpdate | ((id: string) => MaybeAsync) | — | Add "Update" and "Delete" for the active view. A returned promise holds the control busy; a rejection shows its message. |
| onDelete | ((id: string) => MaybeAsync) | — | Add "Update" and "Delete" for the active view. A returned promise holds the control busy; a rejection shows its message. |
| onRename | ((id: string, name: string) => MaybeAsync) | — | 11.5: adds "Rename" for the active view, which asks for a new name. |
| confirmDelete | boolean | false | 11.5: ask in an AlertDialog before deleting. |
| defaultView | string | — | 11.5: the default view’s id. Tagged "Default" in the menu, and applied once on mount when activeId is undefined. |
| maxLength | number | — | 11.5: the longest name allowed when saving or renaming. |
| className | string | — | |
| sheet | false | true | 'auto' | 'auto' (pass `sheet={false}` to keep a popover on small screens) | The menu as a bottom sheet: see DropdownMenu.Content sheet. |
On iOS & Android
Web only
Saved Views has no @nexub/react-native twin. On phones, follow the platform pattern instead, or compose it from the native components listed on the React Native page.