Skip to content
Navigation

Primary

SIMAI Framework ui.* components

The ui.* Smart components are ready-made interface elements from SIMAI Framework: a button, an alert, an input field and others. In Markdown you call them with a :::ui.name block with parameters in JSON. Docara checks the parameters against the component description already at build time, and in the browser the component works the same way as in other products on SIMAI Framework.

How they differ from regular Docara components:

  • a regular component, for example the alert :::alert, is written as Markdown text and suits most pages;
  • a Smart component takes parameters exactly as the Framework describes them and is needed when the page must have a real Framework element: a button with a loading state, an alert with a heading and supporting text and so on.

How a site allows components

A site can call only the Smart components listed in the simai-framework.lock.json file next to docara.json, in the manifests section. For each component it pins the provider, the exact version and the checksum of its description, and also the restrictions for a static site:

JSON
{
  "manifests": {
    "ui.button": {
      "provider_revision": "4b055d09926fec4c32f2ae43b2e7e0a6f64d7663",
      "sha256": "235e049d…"
    },
    "ui.alert": {
      "provider_revision": "4b055d09926fec4c32f2ae43b2e7e0a6f64d7663",
      "sha256": "056329bb…",
      "consumer_policy": {
        "blocked": [
          {"prop": "closable", "value": true, "code": "FRAMEWORK_PROP_UNSUPPORTED_IN_BOUNDED_RUNTIME"},
          {"prop": "type", "value": "success", "code": "FRAMEWORK_PROP_UNSUPPORTED_IN_BOUNDED_RUNTIME"}
        ]
      }
    }
  }
}

docara init creates the file; a Docara update does not change it. The build checks the checksums against the component descriptions that ship with Docara: if a component is not in the lock or the description does not match, the build stops. This site’s lock allows ui.button, ui.alert, ui.badge, ui.tag, ui.tooltip, ui.avatar, ui.progress-bar, ui.reference-link and ui.button-copy — the same ones a new project gets. The lock fields are described in detail in the Framework lock reference.

The ui.button button

Markdown
:::ui.button
{"preset":"primary","text":"Continue","aria-label":"Continue the setup"}
:::

Result:

preset picks a ready-made style: primary, secondary, tonal_on_surface, outline, outline_on_surface, link, link_on_surface or on_surface. The other parameters:

Parameter Value
text The button label, up to 120 characters
aria-label The label for screen readers, up to 120 characters
size 1/3, 1/2, 1, 2 or 3
loading true — the button shows loading
disabled true — the button is unavailable
native-type button, submit or reset

ui.button is an action button in an interface, not a link. To make a button lead to another page, use a button link :button[...] or the cta block.

The ui.alert alert

Markdown
:::ui.alert
{"type":"info","variant":"default","title":"The build checks parameters","supporting-text":"An unknown parameter or value stops the build before publishing.","closable":false,"aria-label":"The build checks parameters"}
:::

Result:

Parameter Value
type clear, info, warning or danger
variant default, flat or outlined
title The heading, up to 160 characters
supporting-text The supporting text, up to 500 characters
closable Only false: an alert cannot be closed on a static site
aria-label The label for screen readers

This site’s lock forbids type=success and closable=true: a static site has nothing to support them with. Such a call stops the build with FRAMEWORK_PROP_UNSUPPORTED_IN_BOUNDED_RUNTIME. Docara sets the id identifier itself.

The ui.badge badge

A short label: a status, a type or a number.

Markdown
:::ui.badge
{"text":"Paid","status":"success"}
:::

Result:

Parameter Value
text The label, up to 80 characters
status info, success, warning or error — what the badge reports
appearance tonal (the default), outline or main. main is only for a count with the error status
scheme neutral, primary, secondary, tertiary or on-surface
size 1/3 (the default), 1/2 or 1
line 1/2, 1, 2 or text — the line height, so the badge does not change the height of a table row or a line of text
activity Where a run stands: running, waiting, done, stopped, failed, paused or queued. The badge adds its own icon and word in the page language
icon, icon-position The icon name and its place: start or end
icon-only true — only the icon is visible; the text stays for screen readers
tight true — narrow side room for dense places
aria-label The label for screen readers, up to 120 characters

For a badge inside a line of text the inline Docara badge :badge[...] is handier.

The ui.tag tag

A tag marks content with a short word. The checkbox kind is a filter toggle: pressing it checks or unchecks it.

Markdown
:::ui.tag
{"text":"Components","kind":"checkbox","count":"12"}
:::

Result:

Parameter Value
text The label, up to 80 characters
kind default (the default) — a plain label, checkbox — a toggle
status info, success, warning or error
appearance default, outline or ghost
size 1/3, 1/2 (the default), 1, 2 or 3
height low, default, high or highest
inline true — the tag sits on the line of another control
count A number after the label, such as 12 or 99+
disabled true — the tag is unavailable
aria-label The label for screen readers

Tags that are removed with a cross or open a menu are not needed on this page: a static site has nothing to handle their action, so Docara does not accept them.

The ui.tooltip tooltip

The Framework tooltip bubble itself: a short text, a second line and a key combination. Here it is shown as it is, without the element it usually appears over.

Markdown
:::ui.tooltip
{"text":"Copy the address","shortcut":"mod+c","arrow":"top-center"}
:::

Result:

Parameter Value
text The main text, up to 160 characters
supporting-text The second line, up to 300 characters
shortcut A key combination, such as mod+c or shift+/
appearance dark (the default) or light
arrow Where the tail is: none (the default), top-center, bottom-center, inline-start, inline-end, bottom-inline-start or bottom-inline-end

A tooltip has no size: in SIMAI Framework every tooltip is the same size, so the build does not accept a size parameter and stops with FRAMEWORK_PROP_UNKNOWN.

The ui.avatar avatar

An avatar shows a person or an organisation: initials from the name, an icon and a mark in the corner.

Markdown
:::ui.avatar
{"heading":"Anna Smirnova","hue":"auto","status":"online"}
:::

Result:

Parameter Value
heading The name: the initials and the screen reader label come from it
text Your own initials instead of the ones from the name, up to 8 characters
icon An icon instead of the initials, for example for a bot or a service
size 1/4, 1/3, 1/2, 1 (the default), 2 or 3
shape circle (the default) — a person, square — an organisation, a project, a group
hue The colour of the initials: auto — from the name, or a colour name: red, teal, indigo and others
status The mark in the corner: online, away, offline, company, verified or none
badge-count, badge-dot A count or a dot on the avatar
line 1/2, 1 or 2 — the line height when the avatar stands next to text
aria-label The label for screen readers

Progress bar ui.progress-bar

A progress bar shows how much of a task is done, or how full a known range is, such as a disk.

Markdown
:::ui.progress-bar
{"value":40,"label":"Upload","text-position":"top"}
:::

Result:

Parameter Value
value How much is done, in per cent: from 0 to 100
label The caption: what is running
value-text Your own value text for screen readers, such as “3 of 8 files”
text-position Where the percentage stands: none (default), top above the bar, inline-end at the end of the row
status The colour: empty is the theme’s main colour, or neutral, info, success, warning or error
warning-at, error-at Thresholds in per cent: from this value on, the bar turns into a warning or an error by itself
indeterminate The work runs but its size is not known yet: a segment crosses the bar
paused The work is paused
meter Not a task’s progress but an amount in a range: a quota, a disk
inline A short bar at the end of a row, such as a table cell; use it with meter
size 1/3, 1/2, 1 (default), 2 or 3
aria-label A label for screen readers

A reference link leads to another page: a name, a short note beside it and a type icon. Use it when a link should stand out more than a line of text.

Markdown
:::ui.reference-link
{"label":"Component model","href":"/en/start/component-model/","text":"Start"}
:::

Result:

Parameter Value
label The link’s name
href Where the link leads: an address on the site (/…, ./…, #…) or an external https://… address
text A short note beside the name: a section, a source or a number
appearance card (default) is a card of its own, inline a link in running text, plain a link on its own line
icon The icon before the name; without it a card shows an arrow
target _self (default) or _blank to open in a new tab
state The page is gone: missing (deleted) or forbidden (no access); the link does not work then
disabled The link is unavailable
size, line 1/2, 1 or 2: the form field size or the line height, such as for a table cell
aria-label A label for screen readers

Copy button ui.button-copy

A copy button copies a value or the text of an element on the page, shows a check for a moment and tells screen readers the result.

Markdown
:::ui.button-copy
{"value":"composer require simai/docara","label":"Copy the command"}
:::

Result:

Parameter Value
value The text to copy
target Instead of value: the #id of an element on the page whose text or field value is copied. Do not give it together with value
text A visible label; without it the button is an icon only
label What is copied, for screen readers, such as “Copy the command”; “Copy” without it
size 1/3, 1/2, 1 (default), 2 or 3
appearance ghost (default), outline, tonal or plain, an icon without a plate
icon, success-icon The icon before the press (content_copy) and after a successful copy (check)
success-text, error-text Your own success and error text
duration How many milliseconds the result stays shown, 2000 by default

Other components

  • ui.input, ui.checkbox, ui.dropdown and ui.list-item (only the text variant inside ui.dropdown) also ship with Docara. The site’s own components use them, for example the install command builder — see the extension examples. Directly in Markdown they can be called only on a site whose lock allows them.
  • ui.tabs and ui.dataview are not accepted yet. Use the Docara tabs and table instead.

The php vendor/bin/docara atlas --json command shows which components are available to your site, and php vendor/bin/docara inspect smart ui.button --json the details of one component. How Smart components work inside and how to write your own is described in the Docara Smart components section.

Errors

An incorrect call stops the build. The most common ones:

Code Cause
FRAMEWORK_DIRECTIVE_JSON_INVALID The parameters are not valid JSON
FRAMEWORK_PROP_UNKNOWN The component has no such parameter
FRAMEWORK_PROP_ENUM_INVALID The value is not in the list of allowed values
FRAMEWORK_PROP_MANAGED Docara sets the parameter itself, for example id
FRAMEWORK_PROP_UNSUPPORTED_IN_BOUNDED_RUNTIME The lock forbids the value for a static site

The causes and fixes for all codes are in the page error reference.