Views and components

A view is a tree of components. Every component has a type and can have a tooltip. Send a whole tree each time; Nook keeps what the user typed or toggled until you send a different value.

Layout rules

  • column stacks its children downward and row places them left to right. gap sets the space between them (default 6).
  • A spacer with no size pushes everything after it to the far end. [title, spacer, button] puts the button on the right.
  • align (start, center, end) aligns children on the other axis. On a column, justify places the whole column at the top, middle or bottom of the space.
  • Add "scroll": true to a column on a page when it may be taller than the space.
json
{ "type": "tile", "view":
  { "type": "row", "align": "center", "gap": 10, "children": [
    { "type": "icon", "icon": "cloud-sun", "size": 28, "color": "accent" },
    { "type": "column", "gap": 0, "children": [
      { "type": "text", "text": "Tbilisi", "size": "small", "color": "dim" },
      { "type": "text", "text": "21°  Sunny", "size": "title" } ] } ] } }

Components

Layout

typeFieldsNotes
columnchildren gap align justify scrollTop to bottom.
rowchildren gap alignLeft to right.
gridcolumns children gapEqual-width cells, good for dashboards.
cardchildren padding gapA glass panel that groups its children.
spacersize?A fixed gap, or with no size, pushes what follows to the end.
dividerA thin line.

Content

typeFieldsNotes
texttext size color bold wrap monosize is small body title big huge. Long text ends in "…" unless wrap.
iconicon size color fillDefault size 18.
imagepath or base64, width height roundingPNG, JPG or BMP. Reloaded when the file changes; scaled down past 1024 px.
progressvalue color widthA thin bar. value is 0 to 1.
ringvalue label size colorA circular progress ring with a short label inside.
sparklinevalues max color width heightAn area chart; the newest value is on the right.
listitems: [{id title subtitle icon trailing selected}]Clickable rows. A click sends an event with the item's id.
canvasheight width id shapesFree drawing, see Canvas.

Controls

Each control sends event messages carrying its id.

typeFieldsSends
buttonid label icon primary widthclick. With no label it's a round icon button. width: 0 fills the row.
toggleid value labelchange with true or false.
sliderid value min max step widthchange while dragging and commit when released.
inputid value hint width livesubmit on Enter. With live, also change on every edit.
chipsid options selectedchange with {"index", "label"}.
Controls update right away. A toggle flips and an input keeps what the user typed before your program answers. If you later send a different value for the same id, your value replaces the user's. Keep ids stable across redraws.

Colors

Theme names follow the user's light or dark theme and accent color: text, dim, faint, accent, on_accent. Fixed colors: red orange yellow green teal blue purple pink white black transparent. You can also use #RGB, #RRGGBB or #RRGGBBAA. Prefer the theme names so your plugin looks right in both themes.

Icons

Use any of the 1,530 Phosphor names, such as "cloud-sun", "cloud_sun" or "CloudSun". "fill": true draws the filled style. An unknown name shows a question mark.