Skip to main content
Login

Sign in to access your account

Feedback Icons - National Design System

A feedback icon shows a status as a colored icon, alone or before a short message.

Overview

Feedback is a nds-feedback element with a data-status. It holds a status icon (nds-feedback-icon) and an optional short message (nds-feedback-message).

Pick another component when:

  • the message is about a form field: NDS.Form.setStatus() in Forms, which also marks the field
  • the message is for the whole page or needs a title or actions: Alert
  • the status is a label on an item, such as “Approved”: Tags

Markup

Options
Structure
Status
Size
Style
Preview
Enter a valid email address
<span class="nds-feedback nds-outline" data-status="error"> <span class="nds-feedback-icon"> <i class="nds-icon" aria-hidden="true"></i> </span> <span class="nds-feedback-message">Enter a valid email address</span> </span>

Behavior

Permanent Message

A permanent message is a hint that stays in place, such as “Use 8 characters or more”. Mark it with data-permanent, or permanent: true in create(). When a newer message arrives in the same place, the hint hides instead of being removed. When that newer message is dismissed, the hint shows again.

Built-in Features

  • Auto Icon by Status

    The status picks the icon: a check for success, an exclamation mark for warning and critical, a cross for error, "i" for info and neutral, and a question mark for help. The icon element stays empty in the markup.

  • Parent Status Inheritance

    A feedback icon inside any element with a data-status takes that status, with no attribute of its own. This is how an alert, a form field and a progress bar color their icons.

  • Screen Reader Announcement

    create() marks the message so that a screen reader reads it when it appears. An error is read at once, and any other status after the screen reader finishes what it is reading.

  • One Message per Place

    A new message replaces the one already in the same place, so messages never pile up. A group's message leaves the messages of the fields inside the group. A target with hidden shows while a message is in it, and hides again when the last one is dismissed.

Best Practices

  • Match the status to the message: error for a failure, success for a confirmation, warning for a risk, info for news, neutral for a general hint and help for help text.
  • Keep the message to one short sentence.
  • Use an icon alone only where the text around it already says the status. The icon has no text for screen readers.
  • Add a message from a script with NDS.Feedback.create(), not with your own markup, so a screen reader reads it.
  • Use SM in forms and in text. Use MD for a status that stands alone, and LG for the main status of a page or a panel.
  • Keep Solid and Ring for a status that must stand out. Outline suits most messages.

API

Data Attributes

Attribute Element Effect
data-status .nds-feedback, or any parent error, critical, success, warning, info, neutral or help. Sets the icon and the colors
data-permanent .nds-feedback Makes the message permanent. See Behavior

CSS Custom Properties

Set these on the .nds-feedback-icon, on the .nds-feedback, or on a parent. Each status sets its own colors and shapes.

Property Default Controls
--feedback-size 16px, 24px with nds-md, 32px with nds-lg Size of the icon. It wins over a size class wherever you set it. A message with no size class takes its parent’s size, such as 20px in a tooltip
--feedback-color var(--icon-neutral) Color of the outline icon. It changes in dark mode
--feedback-icon-color var(--feedback-icon-fill-neutral) Fill of the solid disc. On color it takes the light status shade. In dark mode it stays, except neutral, which turns white
--feedback-ring var(--icon-neutral-ring) Color of the ring halo
--feedback-symbol-color The status’s --feedback-icon-symbol-* token: white, black on a light disc Color of the symbol on the solid disc
--feedback-icon-symbol the “i” in a .nds-feedback, none elsewhere Shape of the symbol, as an icon mask
--feedback-icon-stroke var(--nds-icon-information-circle) Shape of the outline icon, as an icon mask
--feedback-icon-disc var(--nds-icon-disc) Shape of the solid disc, as an icon mask
--feedback-ring-inset 6% of the size Inner edge of the ring, which closes the gap between the disc and the halo. 0 with nds-outline

Tokens

Set a token at :root, or on a wrapper to reach every feedback icon inside it. Give a token with a Dark mode value a dark override too: see Tokens.

Source: the feedback group in _sass/tokens/_components.scss.

TokenPreviewValue
--feedback-icon-fill-successvar(--colors-green-700)
--feedback-icon-fill-errorvar(--colors-red-700)
--feedback-icon-fill-warningvar(--colors-yellow-700)
--feedback-icon-fill-infovar(--colors-blue-700)
--feedback-icon-fill-neutral
var(--colors-neutral-700)
Dark mode var(--colors-neutral-500)
--feedback-icon-symbol-successvar(--colors-base-white)
--feedback-icon-symbol-errorvar(--colors-base-white)
--feedback-icon-symbol-warningvar(--colors-base-white)
--feedback-icon-symbol-infovar(--colors-base-white)
--feedback-icon-symbol-neutralvar(--colors-base-white)

It also reads these shared tokens. A change to one also changes other components.

Source: the var() reads in _sass/components/_feedback.scss.

TokenPreviewValue
--text-primary-paragraph
Read by color

var(--colors-neutral-700)
Dark mode var(--colors-neutral-300)
--text-success
Read by color

var(--colors-green-700)
Dark mode var(--colors-green-400)
--text-info
Read by color

var(--colors-blue-700)
Dark mode var(--colors-blue-400)
--text-warning
Read by color

var(--colors-yellow-700)
Dark mode var(--colors-yellow-400)
--text-error
Read by color

var(--colors-red-700)
Dark mode var(--colors-red-400)
--icon-neutral
Read by --feedback-color

var(--colors-neutral-700)
Dark mode var(--colors-neutral-300)
--icon-success
Read by --feedback-color

var(--colors-green-700)
Dark mode var(--colors-green-400)
--icon-info
Read by --feedback-color

var(--colors-blue-700)
Dark mode var(--colors-blue-400)
--icon-warning
Read by --feedback-color

var(--colors-yellow-700)
Dark mode var(--colors-yellow-400)
--icon-error
Read by --feedback-color

var(--colors-red-700)
Dark mode var(--colors-red-400)
--icon-neutral-ring
Read by --feedback-ring

var(--colors-neutral-100)
Dark mode var(--colors-alpha-white-20)
--icon-success-ring
Read by --feedback-ring

var(--colors-green-100)
Dark mode var(--colors-green-900)
--icon-info-ring
Read by --feedback-ring

var(--colors-blue-100)
Dark mode var(--colors-blue-900)
--icon-warning-ring
Read by --feedback-ring

var(--colors-yellow-100)
Dark mode var(--colors-yellow-900)
--icon-error-ring
Read by --feedback-ring

var(--colors-red-100)
Dark mode var(--colors-red-900)

JavaScript

There is no init(): nothing scans the page for feedback. The script only builds messages.

Method Effect
NDS.Feedback.create(options) Builds a message, puts it in place and returns the element. It replaces the message already in the same place, but not a message that belongs to a field inside it
NDS.Feedback.dismiss(elOrSelector) Removes one message, and shows again a permanent message it hid. Returns true when it existed
NDS.Feedback.dismissAll(container, options) Removes every message in a container except the permanent ones, which show again. With { own: true }, it leaves the messages of fields nested in the container. A message has a .nds-feedback-message or a role: a bare status icon, such as an Upload row’s check mark, stays
Option Default Effect
message '' The message text. Leave it out for an icon alone
status 'neutral' The status, as in data-status
target null The element or selector the message goes to
position 'append' 'append' or 'prepend' puts it inside the target, 'before' or 'after' beside it. This is where the message goes in the page, unlike Alert’s position, which is the toast’s screen corner
size none 'sm', 'md' or 'lg'. With none, the message takes no class: SM, or its parent’s size
style 'outline' 'outline', '' for solid, or 'ring'
showIcon true false leaves out the icon
permanent false Makes the message permanent
ariaLive from the status 'assertive' for error, else 'polite'
id, className none An id and more classes for the message
onCreate(el), onDismiss() none Run after the message is built, and when it is dismissed
Event Fired on Detail
nds:feedback:created document { feedback, options }, after the message is in place
nds:feedback:dismiss document { feedback }, before the message is removed
var hint = NDS.Feedback.create({ message: 'Use 8 characters or more', status: 'help', target: '#password-hint', permanent: true }); NDS.Feedback.create({ message: 'The password is too short', status: 'error', target: '#password-hint' }); // Later: the error goes, and the hint shows again NDS.Feedback.dismissAll('#password-hint');

The full API is in the banner of _js/nds-feedback.js.

Last Modified Date: 20/11/2026 - 05:40 PM
Was this page useful?
60% of users said Yes from 2843 Feedbacks