Skip to main content
Login

Sign in to access your account

Helper Classes - National Design System

Single-purpose CSS classes for the markup you write around NDS components, covering centering, spacing resets, direction isolation, brand-colored text, and small notes

Overview

Helper classes are six CSS classes for the markup you write yourself: a wrapper, a custom panel, a line of text. Each class does one thing. nds-center centers, and nds-flush removes spacing, nds-flush-inline and nds-flush-block remove only the side or the top and bottom padding. nds-color-primary sets the brand text color. nds-note makes a small line of secondary text.

Pick another component when:

  • the items sit in a row or a column: Flex
  • the items sit in columns that change with the screen width: Grid
  • the element hides at one screen size: Hidden
  • long text stops after a number of lines: Truncate Text
  • the message needs an icon, a box or a close button: Feedback Icons or Alert

Markup

Preview
تم استلام طلبك

رقم الطلب REQ-2026-4417، وسيصلك رد خلال يومي عمل.

للاستفسار اتصل على +966 11 456 7890

احتفظ برقم الطلب لمتابعة حالته.

<div dir="rtl" lang="ar"> <div class="nds-flex nds-center"> <div class="nds-card nds-stroke" id="helpers-card"> <div class="nds-card-content"> <div class="nds-card-text"> <span class="nds-card-title">تم استلام طلبك</span> <p class="nds-card-description">رقم الطلب <span id="helpers-number" dir="ltr">REQ-2026-4417</span>، وسيصلك رد خلال يومي عمل.</p> <p class="nds-card-description">للاستفسار اتصل على <span dir="ltr">+966 11 456 7890</span></p> </div> </div> <p class="nds-note">احتفظ برقم الطلب لمتابعة حالته.</p> </div> </div> </div>

Built-in Features

  • One Centering Class

    nds-center works on your markup and on components. A card centers its content, a flex or a grid centers its items, and a section centers its head.

  • Priority Over Component Styles

    nds-center, nds-flush, nds-flush-inline and nds-flush-block use !important, so they apply on any element, even one a component styles, with no extra selector.

  • Palette Colors

    Brand text and the four note statuses read the text color tokens, so a custom palette changes them with the rest of the page.

  • Note in Any Place

    A note sets only its color and text size, with no margin. It fits in a label or a legend as a hint, or stands alone as a paragraph.

  • CSS Only

    Every helper class is CSS only. There is nothing to initialize.

Best Practices

  • Use a component’s own options first. Use a helper class where no option does what you need.
  • Put one nds-center on a wrapper, not on every child. Text alignment inherits.
  • nds-center centers the element itself only when it is narrower than its parent, such as an element with a max-width.
  • A card with nds-center centers its content, not the card. To center the card, center its container: nds-flex nds-center.
  • On a right-to-left page, write dir="ltr" on a span around a left-to-right value, never dir="ltr" or dir="auto" on the element that holds it, such as a table cell or row, a dd, a list item, a paragraph or a field: there it moves the value to the left edge, out of line with the rest of the page. NDS email, phone, URL and formatted fields already read left to right on the right side, so they take no dir. Inside a right-to-left sentence, wrap every left-to-right value. Alone in a cell or a detail value, wrap only a value the page would reorder: one that starts or ends with a sign or mark (+966…, -5, a trailing /), digits in groups (050 123 4567), or a time with AM or PM. An email, a URL, an IBAN, a code, a date or a plain number needs nothing. For right-to-left text in a left-to-right page, write dir="rtl" and lang. Browsers, screen readers and translation tools read the attributes, so NDS has no class for direction.
  • Do not use nds-flush for small spacing changes. It clears four properties with !important, so a later change is harder. Set the component’s own custom property instead.
  • Do not build a layout from these classes. Use Flex or Grid.
  • There are no margin or padding classes. Set --gap on the flex or grid that holds the items, or use a spacing token in your own CSS.
  • For a note under a table or a form, put nds-block on the element above it. The block’s gap separates them.
  • Keep a required-fields note to one line above the first field. data-required on each field container marks the field.
  • Links are primary already. Use nds-color-primary only on text that is not a link.

API

Classes

Class Element Effect
nds-center Any element Centers the text with !important, and sets margin-inline: auto
nds-flush Any element Sets padding, margin, border and corner radius to 0, with !important
nds-flush-inline Any element Sets the start and end padding to 0, with !important.
nds-flush-block Any element Sets the top and bottom padding to 0, with !important.
nds-color-primary Any element Sets the brand text color, --text-primary
nds-note A text element Small text in the secondary paragraph color. No margin

Data Attributes

Attribute Element Effect
data-status .nds-note Sets the note color: error, warning, success or info. Set it yourself
Last Modified Date: 17/11/2026 - 09:38 AM
Was this page useful?
60% of users said Yes from 2843 Feedbacks