Skip to Content
NSUI

Settings

Settings page with a section rail, rows with fixed lanes and a save bar.

Use nsui-settings for the settings or preferences screen of a Suitelet or SPA. The shell owns the page padding, the rail and the save bar. Each nsui-settings-section holds nsui-setting rows, and each row has one control. For a record form, use form fields. For one to three options, put the controls in a popover.

Layout

  • Rail: the shell builds the rail from the sections: one link per section with an id, under its group label. A section with hidden, or with no id, is not in the rail. The current link follows the scroll position.
  • Rows: each row has three lanes: text, control and status. The status lane is 48px wide and always there, so "Saved" never moves the control. Controls are right-aligned and top-aligned with the label.
  • Narrow: below 720px of the shell's own width, a select replaces the rail. Below 520px of a row's width, the control moves under the text, except a switch or checkbox. The widths come from container queries, so the layout holds in a drawer, an iframe or a narrow Suitelet column.
  • Spacing: sections, heads and rows have no outer margin. Do not add one: the shell owns the page padding.

Set layout="wide" on a row to put the control under the text at full width, for example a table or radio cards. Set indent on a row that depends on the row above. Put section buttons, such as "Reset to defaults", in the section's actions slot.

Saving

A section saves each row at once by default. The page sets the row status:

JavaScript
input.addEventListener('change', async () => {
  row.status = (await saveSetting(input.value)) ? 'saved' : 'error';
});

saved shows "Saved" and clears itself after 1.5s. error shows the error text under the help text.

For a section with save="batched", the page sets status="dirty" on each changed row. Only the page knows the saved value, so the row does not mark itself. The shell shows a save bar while any row in a batched section is dirty:

JavaScript
settings.addEventListener('settingssave', async (e) => {
  settings.saving = true;            // disables Discard and Save
  await saveSections(e.detail.ids);  // ids of the batched sections with dirty rows
  for (const row of settings.querySelectorAll('nsui-setting[status=dirty]')) row.status = 'saved';
  settings.saving = false;
});
settings.addEventListener('settingsdiscard', (e) => {
  restoreSections(e.detail.ids);
  for (const row of settings.querySelectorAll('nsui-setting[status=dirty]')) row.status = '';
});

Set save-label to change the button text, for example "Save for everyone".

  • settingsnav fires with detail.id each time the current section changes, for any reason.
  • Set current to scroll to a section. jumpTo(id) scrolls at once and moves focus to the section heading.
  • A rail link click scrolls smoothly with the pointer and at once with the keyboard or reduced motion, then moves focus to the heading.

Accessibility

  • The rail is a <nav> named by label. The current link has aria-current="true". The jump select has the same name.
  • Each section is a <section> named by its heading. Set level="3" to use an h3.
  • The row writes its label, help and error text into light DOM spans and sets aria-labelledby and aria-describedby on the control, because ARIA id references cannot cross into a shadow root. A control that already has aria-label or aria-labelledby keeps its own name.
  • The status lane is a role="status" region, so "Saved" and errors are announced.
  • The save bar is a region named "Unsaved changes". It does not take focus when it appears.

API

nsui-settings

Attributes

Prop

Type

Events

Prop

Type

Slots

Prop

Type

CSS parts

Prop

Type

nsui-settings-section

Attributes

Prop

Type

Slots

Prop

Type

CSS parts

Prop

Type

nsui-setting

Attributes

Prop

Type

Slots

Prop

Type

CSS parts

Prop

Type

NSUI is a community project. It is not an official Oracle NetSuite product. NetSuite is a trademark of Oracle.

On this page