Build your personal knowledge base with Trilium Notes
Trilium Dashboard Collections
A dashboard is a collection view that renders each child note as a widget on a drag-and-drop grid, similar to Grafana or a home-automation dashboard. The user can freely place and resize the widgets; the layout is saved automatically.
Creating a dashboard
- Create a note of type
book(create_notewith typebook). - Set the
viewTypelabel todashboardon it (set_attributewith typelabel, nameviewType, valuedashboard).
Every child note of the dashboard becomes a widget.
Widget types
A widget is just a child note, rendered with its normal content. Pick the note type by what the widget should show:
| Widget should show | Child note type |
|---|---|
| Formatted text, checklists, links | text |
| A diagram | mermaid |
| A code snippet | code |
| An embedded web page | webView (content is the URL) |
| A drawing | canvas |
| Dynamic / interactive content | render + a Preact JSX child note (see below) |
After creating a widget note, ALWAYS give it an icon: find a fitting one with search_icons and assign it with set_attribute as the widget note's iconClass label (e.g. bx bx-line-chart). The icon is shown in the widget's title bar. Never prepend an emoji to the widget title instead.
Interactive widgets (Preact render notes) — preferred for dynamic content
For widgets that compute something, fetch data, or respond to clicks, use a render note backed by a Preact JSX component:
- Create a note of type
renderas a child of the dashboard — this is the widget. - Create a
codenote with mimetext/jsxas a child of the render note, exporting a default component. - Call
set_attributeon the render note with the relationrenderNotepointing to the JSX note. Because it enables code execution, it is saved as~disabled:renderNoteand the widget stays inactive until the user enables it. Tell the user exactly what to do, e.g.: "Review '', then open the widget note '' and press Enable render note."
JSX rules (load the frontend_scripting skill for the full API):
- Use top-level ES
importonly; hooks come from"trilium:preact", API methods from"trilium:api". - NEVER use
React,require(), orawait import()— Trilium uses Preact and JSX notes are ES modules. - Export the component as
export default. - To reference the widget's own note (e.g. to read its attributes or store data under it), use
originEntityfrom"trilium:api"— it is the render note hosting the component. Do NOT usegetActiveContextNote(): on a dashboard the active note is the dashboard itself, not the widget.
Example — a widget showing the number of notes created in the last 7 days:
import { useState, useEffect } from "trilium:preact";
import { searchForNotes } from "trilium:api";
export default function RecentNotesWidget() {
const [count, setCount] = useState(null);
useEffect(() => {
searchForNotes("note.dateCreated >= TODAY-7").then(notes => setCount(notes.length));
}, []);
return (
<div style="text-align: center;">
<h3>Notes this week</h3>
<strong style="font-size: 2em;">{count === null ? "…" : count}</strong>
</div>
);
}
Layout behavior
- The grid has 12 columns; one row is about 80 px tall. New widgets default to 4 columns × 3 rows and are placed automatically in the first free spot.
- The user rearranges widgets by dragging the title bar and resizes them from the bottom-right corner. You cannot position widgets programmatically — create them and let auto-placement handle it; the user adjusts afterwards.
- The layout persists in a
dashboard.jsonattachment (roleviewConfig) on the dashboard note. It is managed by the UI and syncs across devices and splits. You cannot alter it — no tool can modify attachments — and there is no need to: the dashboard automatically picks up new child notes as widgets and auto-places them. - On narrow screens (under ~768 px) the dashboard collapses to a single read-only column; the saved layout is unaffected.
Tips
- Keep widget content compact — widgets clip overflowing content with scrollbars.
- Give widgets meaningful titles; the title bar is always visible and doubles as the drag handle.
Anti-patterns (do NOT do this)
- ❌ Putting the JSX code note directly under the dashboard — it would render as a code widget showing its own source. The JSX note belongs under the render note.
- ❌ Telling the user the widget is ready after setting
~renderNote— it is saved as~disabled:renderNoteand renders nothing until the user enables it. - ❌ Directing the user to set
~renderNoteon the dashboard note itself — it belongs on therender-type child. - ❌ Trying to write the
dashboard.jsonattachment (or any view configuration) to lay out widgets — attachments cannot be modified by tools, and the dashboard picks up new widgets automatically; rely on auto-placement. - ❌ Using
getActiveContextNote()inside a widget's JSX to get "this widget's note" — when the dashboard is open, the active note is the dashboard, not the widget. UseoriginEntity(the render note) instead. - ❌ Setting
#viewType=dashboardon atextnote — the view type only applies tobook(and search) notes. - ❌ Prepending an emoji to a widget title to decorate it — find an icon with
search_iconsand set theiconClasslabel instead.