# Badge (/docs/components/badge)
Use a badge to show a short status, such as the status of a transaction.
DraftPending ApprovalApprovedOn HoldRejectedNew
```html
DraftPending ApprovalApprovedOn HoldRejectedNew
```
## Tones [#tones]
`neutral` is the default: dark text on a grey tint. `info`, `success`, `warning` and `danger` use a soft tint with text in the tone colour. `accent` uses the accent colour on its soft tint. Every tone has square corners and no dot, and its text passes 4.5:1 contrast.
Use `neutral` for ordinary states such as Draft. Keep colour for a state that needs attention.
## In the data grid [#in-the-data-grid]
A data grid column with `type: 'badge'` shows the same label. `tones` maps each value to a tone. See [Data grid](/docs/components/data-grid).
## API [#api]
# Button (/docs/components/button)
Use a button for actions in forms, toolbars and dialogs.
SaveCancelExportMoreDelete
```html
SaveCancelExportMoreDelete
```
## Sizes [#sizes]
SmallMediumLarge
```html
SmallMediumLarge
```
## States [#states]
SavingDisabled
```html
SavingDisabled
```
## In a form [#in-a-form]
`type="submit"` submits the closest `
```
## API [#api]
# Card and Grid (/docs/components/card)
Use a card to group related content. Use a grid inside it to lay out fields in columns, like a NetSuite record header.
EditCancelSave
```html
EditCancelSave
```
## Card header and footer [#card-header-and-footer]
The header shows when the card has a `heading` or content in the `actions` slot. The footer shows only when the `footer` slot has content.
A card with no heading and no footer.
```html
A card with no heading and no footer.
```
## Flush [#flush]
`flush` removes the body padding. Use it for content that must touch the card edges, such as a data grid.
```html
```
## Grid columns [#grid-columns]
The grid has 3 columns by default. Set `columns` to change it. The grid measures its own width, not the window. It changes to 2 columns when it is 720px wide or less, and to 1 column at 460px or less. A grid in a narrow card collapses even on a wide screen.
```html
```
## Spanning cells [#spanning-cells]
Put `span="2"` on a child to fill two columns. Put `span="full"` on a child to fill the whole row.
```html
```
## API [#api]
### nsui-card [#nsui-card]
### nsui-grid [#nsui-grid]
# Checkbox (/docs/components/checkbox)
Use a checkbox for a yes or no value. Add `switch` for a toggle switch.
```html
```
## Switch [#switch]
```html
```
## Disabled [#disabled]
```html
```
## Form value [#form-value]
When checked, the checkbox submits `value`, which is `T` by default. When unchecked, it submits nothing.
```html
```
## In NetSuite [#in-netsuite]
Set `field` to bind the checkbox to a native body field.
```html
```
The label, the checked state and the disabled state come from the record. Each change writes back with `setValue`.
## API [#api]
# Data Grid (/docs/components/data-grid)
Use a data grid for sublist lines, search results and any list of records.
It sorts, searches, selects, pages, totals and edits in place.
Bind it to a native sublist with `sublist="item"`.
```html
```
Set `columns` and `rows` as properties from script. The attributes also accept JSON, which suits server-rendered HTML.
Click a column header to sort: ascending, descending, then off.
## Column types and alignment [#column-types-and-alignment]
`type` sets the format and the default alignment. `number`, `currency`, `percent` and `actions` align right; all other types align left. Set `align` to `left`, `right` or `center` to override it.
| Type | Output |
| --- | --- |
| `text` | Plain text. An empty value shows a dash. |
| `number` | `Intl.NumberFormat`, up to 4 decimals. |
| `currency` | `Intl.NumberFormat` in the grid's `currency` (default `USD`). |
| `percent` | `0.25` shows as `25%`. |
| `date` | `YYYY-MM-DD` or any date string, in medium date style. |
| `badge` | The same label as `nsui-badge`. `tones` maps a value to `success`, `warning`, `danger` or `info`. A value with no tone is `neutral`. |
| `link` | A link. `href` is a row field name, or `(row) => url`. Only `http`, `https`, `mailto` and relative URLs become links; any other URL shows as plain text. `target: '_blank'` adds `rel="noopener noreferrer"`. |
| `mono` | Monospace text, for SKUs and IDs. |
| `actions` | Icon buttons from `actions`. See [Row actions](#row-actions). |
`number`, `currency` and `percent` cells and totals use tabular figures in one colour. A column with `format` or `options` shows its own text.
```js
grid.columns = [
{ key: 'sku', label: 'SKU', type: 'mono' },
// href names a row field. A function (row) => url also works.
{ key: 'item', label: 'Item', type: 'link', href: 'url' },
{ key: 'status', label: 'Status', type: 'badge', tones: { Committed: 'success', Backordered: 'danger', 'Partially Fulfilled': 'warning' } },
{ key: 'qty', label: 'Qty', type: 'number' },
{ key: 'rate', label: 'Rate', type: 'currency' },
{ key: 'amount', label: 'Amount', type: 'currency' },
];
```
`format: (value, row) => string` replaces the text of any column. Search matches the formatted text.
Set `currency` and `locale` on the grid to change the currency code and the number and date format.
```html
```
## Search, column toggle and density [#search-column-toggle-and-density]
`searchable` adds a search box. It matches the text of the visible columns.
`column-toggle` adds a **Columns** menu to show and hide columns. A column with `hidden: true` never shows and is not in the menu.
`density-toggle` adds a button that switches `density` between `default` and `compact`.
```html
```
Put your own actions in the `toolbar` slot. They sit on the right side of the toolbar.
```html
Remove
```
## Filters [#filters]
Set `filter: true` on a column to add a filter button for it to the toolbar. The button opens a panel with the column's distinct values and a count for each.
Tick values to filter the rows. Values in one column combine with OR. Filters on different columns combine with AND.
Each count shows how many rows would match that value, under the search and the other columns' filters.
```html
```
- The panel lists the column's labels: from `options`, then `format`, else the formatted value. It filters by the raw values.
- A search box appears when a column has more than 8 values.
- **Clear** empties one column's filter. **Reset filters** appears in the toolbar when any filter is active, and empties them all.
- A change goes back to page 1. Selected rows that no longer pass the filters leave the selection, and `selectionchange` fires.
- A column with `hidden: true`, or one hidden with the column menu, still filters.
`filters` holds the active filters: an object of column key to an array of values. Set it as a property, or as JSON in the attribute. The grid sets a new object each time the user changes a filter. It does not write the attribute back.
```html
```
The property also accepts a JSON string, as `columns` and `rows` do.
Keyboard: Enter or Space on a filter button opens its panel and moves focus to the first value (or the search box). Arrow keys move between values. Space ticks a value. Escape closes the panel and returns focus to the button.
## Selection [#selection]
`selectable` adds a checkbox column. The header checkbox selects all rows on the current page.
Each change fires `selectionchange` with the selected keys and rows. Keys come from the `row-key` field (default `id`), or the row index when that field is missing.
```html
```
When `rows` changes, the grid drops selected keys that no longer exist.
## Paging [#paging]
`page-size` turns on paging. `0` (the default) shows all rows. The pager has a rows-per-page select (10, 25, 50, 100) and page buttons.
Search and sort apply to all rows before paging.
```html
```
## Totals [#totals]
`totals` adds a footer row. Each column with a `total` shows a value: `sum`, `avg`, `count`, or a function `(rows) => value`. The first column shows "Total" when it has no total of its own.
Totals use all rows that match the search, not only the current page.
```js
grid.columns = [
{ key: 'item', label: 'Item' },
{ key: 'qty', label: 'Qty', type: 'number', total: 'sum' },
{ key: 'rate', label: 'Rate', type: 'currency', total: 'avg' },
{ key: 'amount', label: 'Amount', type: 'currency', total: 'sum' },
];
```
## Inline editing [#inline-editing]
Set `editable: true` on a column. Click a cell, or focus it and press Enter or F2, to open the editor.
The editor is a number input for numeric types, a date input for `date`, a select when the column has `options`, and a text input otherwise.
| Key | Action |
| --- | --- |
| Enter | Commit and close. |
| Escape | Close without a change. |
| Tab / Shift+Tab | Commit and open the next or previous editable cell. |
| Blur | Commit and close. |
A changed value fires `cellchange`. If you do not cancel it, the grid writes the value to the row object and marks the cell with a corner flag. Call `markClean()` after a save to clear the flags. Call `preventDefault()` to reject the value.
```html
```
The grid does not compute other columns. Update them in your `cellchange` handler, as above.
If you mutate `rows` in place outside an edit, call `refresh()`. Assign a new array to `rows` to re-render and clear the dirty flags.
## Pinned columns [#pinned-columns]
`pin: 'start'` keeps a column on the left during horizontal scroll. `pin: 'end'` keeps it on the right. Pinned columns move to the start or end of the column order. The selection checkbox pins too when any column pins to the start.
```js
grid.columns = [
{ key: 'line', label: '#', type: 'number', width: 48, pin: 'start' },
{ key: 'sku', label: 'SKU', type: 'mono', pin: 'start' },
{ key: 'item', label: 'Item', width: 260 },
// ...more columns
{ key: 'amount', label: 'Amount', type: 'currency', pin: 'end' },
];
```
Set `--nsui-grid-max-height` to scroll the body vertically. The header and the totals row stay in place.
## Row status [#row-status]
A row with `_status` set to `new`, `changed` or `deleted` gets a green, amber or red tint. A `deleted` row also shows its text struck through.
Set `status-key` to read the status from another field.
```js
grid.rows = [
{ id: '1', item: 'Steel Bracket 40mm', qty: 12 },
{ id: '2', item: 'Hex Bolt M8 (box/100)', qty: 40, _status: 'changed' },
{ id: '4', item: 'Gasket Kit GK-7', qty: 6, _status: 'deleted' },
{ id: '5', item: 'Bearing 6204-2RS', qty: 24, _status: 'new' },
];
```
## Expandable rows [#expandable-rows]
`expandable` adds a chevron button to each row. It opens a detail row directly under that row. Put the detail content in light DOM with `slot="detail-"`: your page styles, forms and NSUI components work inside it.
- `expanded` lists the open row keys. Set it to open rows from code; the grid updates it when a user toggles a row.
- `detail-mode="single"` (the default) closes the open row when another opens. `multi` keeps several open.
- The detail stays in view when the columns scroll sideways.
- Keyboard: Enter or Space toggles the focused chevron; Right Arrow opens and Left Arrow closes.
Committed 12 · Fulfilled 12 · Billed 12
Committed 40 · Fulfilled 0 · Billed 0 · Ship date Dec 9, 2026
Backordered 1 · Next receipt Dec 14, 2026
```html
Committed 40 · Fulfilled 0 · Billed 0
```
Detail content is your own markup, never an HTML string from data, so it cannot inject script.
## Cell marks, tones and weight [#cell-marks-tones-and-weight]
Three column fields change how a cell looks. None of them takes HTML.
- `mark: (value, row) => name | { name, label, tone } | null` puts a 16px mark before the text. `tone` replaces the mark's default colour. Names: `locked` (padlock), `blocked` (slash), `edited` (ring), `new` (plus), `warning` (triangle). The label is the mark's accessible name and tooltip; each name has a default. Any other name shows nothing.
- `tones` colours the cell text on any column that is not a `badge`, with the same map or function as a badge: `success`, `warning`, `danger` or `info`.
- `weight`: `regular` (default), `medium` or `semibold`, or `(value, row) => weight` for one cell at a time.
```js
grid.columns = [
{ key: 'item', label: 'Item', weight: 'semibold' },
{ key: 'avail', label: 'Available', type: 'number',
tones: (v) => (v === 0 ? 'danger' : undefined),
// A function, so set columns as a property to use marks.
mark: (v, row) => (row.locked ? 'locked' : v === 0 ? { name: 'blocked', label: 'Out of stock' } : null) },
];
```
## Row actions [#row-actions]
A column with `type: 'actions'` shows icon buttons in each row. `actions` lists them: `{ name, icon, label, disabled?, hidden? }`. `icon` is `trash` or `restore`. `label` is the button's accessible name and tooltip. `disabled` and `hidden` are `(row) => boolean`: a disabled button shows dimmed, a hidden one is left out for that row. A click fires `rowaction` with `{ name, key, row, index }`; `rowclick` does not fire. The column does not sort and search skips it. Pin it with `pin: 'end'` to keep it in view.
```js
grid.columns = [
{ key: 'item', label: 'Item' },
{ key: 'act', label: '', type: 'actions', pin: 'end', actions: [
{ name: 'delete', icon: 'trash', label: 'Delete line', disabled: (row) => row.fulfilled > 0, hidden: (row) => row._status === 'deleted' },
{ name: 'restore', icon: 'restore', label: 'Restore line', hidden: (row) => row._status !== 'deleted' },
] },
];
grid.addEventListener('rowaction', (e) => {
e.detail.row._status = e.detail.name === 'delete' ? 'deleted' : undefined;
grid.refresh();
});
```
## Theming [#theming]
Set these tokens on the grid or on any ancestor. Each one defaults to the look above.
| Token | Sets | Default |
| --- | --- | --- |
| `--nsui-grid-header-bg` | Header row background | `--nsui-bg` |
| `--nsui-grid-header-fg` | Header text colour | `--nsui-fg` |
| `--nsui-grid-header-weight` | Header font weight | `500` |
| `--nsui-grid-divider` | 1px rule between columns | none |
| `--nsui-grid-stripe` | Background of every second line (detail rows do not count) | none |
| `--nsui-grid-edited-bg` | Fill of an edited cell, under the corner mark | none |
| `--nsui-grid-max-height` | Height after which the body scrolls | none |
For anything else in the header, style `::part(header)`.
```css
.order-lines {
--nsui-grid-header-bg: var(--nsui-bg-subtle);
--nsui-grid-header-weight: 600;
--nsui-grid-divider: var(--nsui-border);
--nsui-grid-stripe: var(--nsui-bg-subtle);
}
```
## Loading [#loading]
`loading` replaces the body with skeleton rows while you fetch data. The totals row hides while it loads.
```html
```
When no rows match, the body shows `empty-text` (default "No results.").
## Events [#events]
All events bubble and cross the shadow boundary.
| Event | Detail | Cancel effect |
| --- | --- | --- |
| `sort` | `{ key, dir }`, `dir` is `'asc'`, `'desc'` or `null` | Keeps the current sort. |
| `selectionchange` | `{ keys, rows }` | None. |
| `cellchange` | `{ row, key, value, oldValue, index }` | Keeps the old value. |
| `filterchange` | `{ key, values, filters }`. `key` is `null` for **Reset filters**. | Keeps the current filters. |
| `rowclick` | `{ row, index }` | None. |
| `rowtoggle` | `{ key, row, open }` | Keeps the row open or closed. |
| `rowaction` | `{ name, key, row, index }` | None. |
`index` is the position in `rows`, not in the sorted or paged view. `rowclick` does not fire for clicks on checkboxes, links, buttons or editable cells.
## In NetSuite [#in-netsuite]
Add `sublist="item"` to bind the grid to a native sublist on a record page. Each column `key` is a sublist field ID. Set `field` on a column when the key differs from the field ID, and `text: true` to show the field's display text instead of its value.
```html
```
- The native record stays the source of truth. The grid reads every line with `getLineCount` and `getSublistValue` (or `getSublistText`).
- An edit cancels the grid's own write. The binding then calls `selectLine`, `setCurrentSublistValue` and `commitLine`, so NetSuite runs `fieldChanged`, sourcing and `validateLine` as usual.
- If `commitLine` throws, or the committed value differs from the new value, the binding calls `cancelLine`. It fires a cancelable `nserror` event and, if not cancelled, shows a "Line not saved" toast. The grid then re-reads the record, so the cell reverts.
- The grid polls the sublist about every 1.2 seconds. It skips a poll while a cell editor is open. Call `NSUI.sync()` from a client script for an instant refresh.
- In view mode, all columns become read-only.
## API [#api]
# Date picker (/docs/components/date-picker)
The date picker is not a separate element. Use `nsui-input type="date"`: it shows a text field in the locale's date format and a calendar button that opens a month grid below the field. The full reference is in [Input › Date](/docs/components/input#date).
```html
```
## What it does [#what-it-does]
- **Value:** always ISO `YYYY-MM-DD`, in events, in form data and for NetSuite. The field shows the date in the locale format.
- **Typing:** type a date in the locale format (`12/24/2026` in en-US) or as ISO. Text that is not a date shows the error style and blocks form submission.
- **Limits:** days before `min` and after `max` are struck through and cannot be picked.
- **Locale:** `locale` sets the format, the month and weekday names, and the first day of the week.
## Keyboard [#keyboard]
Alt+ArrowDown in the field, or Enter on the calendar button, opens the calendar. In the calendar, the arrow keys move by day and week, PageUp and PageDown move by month (with Shift, by year), Home and End go to the week edges, Enter picks the day, and Escape closes and returns to the field.
## Not available yet [#not-available-yet]
There is no calendar without a field (always open on the page) and no date range picker. Ask for them if a page needs them.
# Dialog (/docs/components/dialog)
Use a dialog to ask for a decision or show a short form on top of the page. It uses the native `