A row of tiles
Lay tiles out with NbCardGrid, which wraps them by their own width, so a row of four becomes two rows of two on a phone without a breakpoint.
<NbCardGrid min="150px">
<NbStat label="Created" :value="result.created" status="success" />
<NbStat label="Updated" :value="result.updated" status="warning" />
<NbStat label="Skipped" :value="result.skipped" />
<NbStat label="Errors" :value="result.errors" :status="result.errors ? 'danger' : 'neutral'" />
</NbCardGrid>A status tile is filled with that status's quiet ground and every word on it is set in the matching ink, the pair the theme keeps legible in light and dark. Use a status when the colour is the meaning of the number (created, failed, waiting for review), not to decorate a row.
Tiles that do something
A tile behaves exactly like an NbCard, and picks its element the same way:
torenders a<RouterLink>when the app has vue-router: the tile takes the reader to the list the number counts.hrefrenders a plain<a>.clickablerenders arole="button"and emitsselect, for a tile that changes something in place, such as which metric the chart below plots.selectedmarks the one on show.
<NbStat :label="t('items.total')" :value="total" :to="{ name: 'items' }" />
<NbStat
:label="t('items.needsReview')"
:value="pending"
status="warning"
:to="{ name: 'review' }"
/>Dense row
size="sm" is for a row of figures that sits above a table or a chart and should not outweigh it: tighter padding and a smaller figure, 59px tall without a delta, against 86px for the default. Everything else is the same tile, so a dense tile still takes a status, a delta and a link.
<NbCardGrid min="140px" gap="sm">
<NbStat size="sm" label="Open" :value="counts.open" />
<NbStat size="sm" label="Overdue" :value="counts.overdue" status="warning" />
</NbCardGrid>Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | What the number counts. | |
value | string | number | — | The number, already formatted. |
status | 'neutral' | 'info' | 'success' | 'warning' | 'danger' | 'neutral' | Tints the tile with a status. |
delta | string | — | The change, already formatted. |
trend | 'up' | 'down' | 'flat' | — | Which way the figure moved. Draws the arrow and colours the delta. |
invertTrend | boolean | false | Down is good news. Changes the colour, never the arrow. |
comparison | string | — | What the delta is measured against. |
size | 'sm' | 'md' | 'lg' | 'md' | sm for a dense KPI row, lg for the headline figure. |
loading | boolean | false | Placeholder value, no delta, aria-busy. |
to | string | object | — | Target route. A <RouterLink> with vue-router, a plain link for a string without. |
href | string | — | Renders the tile as a link. |
target | string | — | Link target. _blank also sets rel="noopener". |
clickable | boolean | false | Renders as a button and emits select. Ignored when to or href is set. |
selected | boolean | false | Draws the tile as chosen. |
disabled | boolean | false | Inert and muted. |
hint | string | — | An info button beside the label that explains what the figure counts. |
hintTitle | string | — | Bold heading above the hint's text. |
icon | TIconSource | — | A small, muted icon before the label. |
arrow | boolean | false | An arrow at the trailing edge of a tile that links (to or href). |
Events
| Event | Payload | Description |
|---|---|---|
select | MouseEvent | KeyboardEvent | The tile was activated by a click, Enter or Space. Only fires when clickable. The event carries the modifier keys, for a grid that selects a range with shift. |
Slots
| Slot | Description |
|---|---|
label | Replaces the label prop, for a label with a help icon beside it. |
value | Replaces the value prop. |
delta | Replaces the arrow, delta and comparison. |
Accessibility
- The label comes first in the markup, so a link tile is announced as "Needs review, 12, link".
- The arrow is decorative. Write the sign into
delta(+12%,-3%), so the direction does not depend on the arrow or the colour. - A link or button tile has the focus ring every interactive surface in the library has.
Explaining the figure
hint puts an NbInfoHint beside the label, so a tile can say what it counts without a legend. hintTitle adds a heading to it. icon draws a small muted icon before the label, and arrow marks a tile that links with an arrow at its trailing edge.
<NbStat
icon="tray"
label="Needs review"
:value="pending"
:to="{ name: 'review' }"
arrow
hint="Waiting for someone to approve them."
/>On a tile that links or acts, the hint is not inside the link. The tile becomes a plain container, and the link or button is a sibling of the hint, stretched over the whole tile. Tab reaches the tile and the hint as two stops, clicking the hint opens it without navigating, and the tile is named by its label and figure. A tile without hint is still the link or button itself, as before.