v1.6.x-dev NDS IQ v6

Hidden - National Design System

CSS-only visibility utilities that honor the native hidden attribute over any display value and hide elements inside exact viewport ranges with data-hidden

The hidden Attribute

The native hidden attribute is guaranteed to work on any NDS element, even ones styled with flex or grid display. The markup below ships four tags, and the one carrying hidden never renders

Four tags in the markup, three rendered
Active Beta Archived
<span class="nds-tag" data-status="success"><span class="nds-label">Active</span></span> <span class="nds-tag" data-status="info"><span class="nds-label">Beta</span></span> <span class="nds-tag" data-status="error" hidden><span class="nds-label">Deprecated</span></span> <span class="nds-tag nds-gray"><span class="nds-label">Archived</span></span>

Responsive Hiding with data-hidden

Stamp data-hidden on any element to hide it only inside a named viewport range: sm (600px and below), md (601 to 960px), lg (961 to 1280px). Space-separate tokens to span ranges. Resize the window to watch each tag drop out of its own band

Each tag names the range where it hides
sm md lg sm md always visible
<span class="nds-tag" data-status="error" data-hidden="sm"><span class="nds-label">sm</span></span> <span class="nds-tag" data-status="warning" data-hidden="md"><span class="nds-label">md</span></span> <span class="nds-tag" data-status="info" data-hidden="lg"><span class="nds-label">lg</span></span> <span class="nds-tag" data-status="neutral" data-hidden="sm md"><span class="nds-label">sm md</span></span> <span class="nds-tag" data-status="success"><span class="nds-label">always visible</span></span>

Keep It Readable to Screen Readers

Add the sr token to any data-hidden value and the element is hidden visually but stays in the accessibility tree. Use it on button labels that collapse to icon-only, so the control never loses its accessible name. Resize below 600px: the label disappears, the button keeps its width padding, and screen readers still announce "Search"

Label collapses on mobile, name survives
<button class="nds-btn nds-neutral" type="button"> <i class="nds-icon nds-hgi-search-01" aria-hidden="true"></i> <span class="nds-label" data-hidden="sm sr">Search</span> </button>

Built-in Features

Universal hidden Override

Elements with the hidden attribute stay hidden even when a flex, grid, or utility display rule targets them.

Band-Exact Breakpoints

Each data-hidden token hides an element only inside its own range, so a mid-width gap never leaks into small screens.

Composable Ranges

Space-separate tokens to span ranges, like data-hidden="sm md" for everything below the large breakpoint.

Screen-Reader Preservation

The sr token hides an element visually while assistive technology keeps announcing it, so icon-only collapses never lose their name.

Usage Guidelines

Best Practices

  • Use the hidden attribute for state your JS toggles (panels, menus, wizard steps). It wins over any display value, so no extra CSS is needed
  • Use data-hidden for chrome that has no place at some widths (topbar widgets, secondary metadata) instead of writing one-off media queries
  • Think of the split as: hidden is state ("not right now"), data-hidden is viewport ("not at this width"). Both can sit on one element, and either condition hides it
  • Combine tokens to span ranges: data-hidden="sm md" hides up to 960px, data-hidden="md lg" keeps an element for the smallest and very wide screens only
  • data-hidden="lg" covers 961 to 1280px, so the element shows again on wider screens. There is no token for widths above 1280px
  • The hidden attribute and plain data-hidden remove content from screen readers too. When assistive technology should still announce it, add the sr token: data-hidden="sm sr"
  • Hiding a label with sr does not restyle the control: a button keeps its text padding rather than becoming a square icon button. Sizing stays the component's job
  • Do not hide primary actions on small screens. Collapse them into a Dropmenu so the capability stays reachable
  • Hidden elements still download their images and iframes. Remove heavy content from the markup rather than hiding it

Attributes

AttributeDescription
hiddenNative attribute, any element. Removes it from rendering and assistive technology, and wins over any display value
data-hiddenBand-exact responsive hiding. Tokens: sm (600px and below), md (601 to 960px), lg (961 to 1280px). Space-separate to combine. Add sr to hide visually but keep the element readable to screen readers
Last Modified Date: 26/07/2026 - 09:02 PM
Was this page useful?
60% of users said Yes from 2843 Feedbacks