Skip to content

Repository files navigation

New UI Foundations

What is New UI?

New UI is a modern, semantic UI framework for building beautiful, accessible websites and apps. It gives you all the core design foundations you need—colors, typography, spacing and sizing, reset, grid and layouts, and layering and elevations. It's designed to grow with you, from your first launch to millions of users. Thoughtfully designed for makers and teams who value scalability and function.

Install

To set up the project, open your terminal and run the following command:

npm i -D @new-ui/foundations

Note: This command installs all New UI foundation packages, which include reset, colors, effects, spacings, and typography. If you need to install only specific packages, refer to the New UI docs for instructions.

Import

Import the New UI foundations by adding the following line at the top of your SCSS file:

@use'@new-ui/foundations'; // Use `@import` for CSS

Set the theme

Set the theme by adding the data-new-ui-theme attribute to your HTML wrapper element, for example:

<htmldata-new-ui-theme="light"></html>
Available themesValue
Light (Default)light
Light warmlight--warm
Light coldlight--cold
Dark (Default)dark
Dark warmdark--warm
Dark colddark--cold

Utility classes, naming convention

  • All classes associated with the New UI are prefixed with a global namespace followed by a hyphen: nu-
  • In addition to a global namespace, we added prefixes to each class to make it more apparent what job that class is doing using BEM syntax.
    • c- for UI components.
    • l- for layout-related styles.
    • u- for utilities.
    • is- and has- for state-based classes.
    • js- for targeting JavaScript-specific functionality.

Design tokens

Colors

BackgroundRole
--backgroundDefault app background
--background-secondarySecondary app background
--background-hoverBackground hover
--background-selectedUI element background
--background-selected-hoverUI element background hovered
--background-high-contrastHigh contrast background
BorderRole
--border-mutedMuted strokes and separators
--borderDefault strokes and separators
--border-strongStrong strokes and separators
--border-inkedInked strokes and separators
--border-inverseInverse strokes and separators
--border-focusFocus outline
ButtonRole
--buttonPrimary button background
--button-hoverPrimary button hover
--button-activePrimary button active
--button-disabledDisabled button background
LinkRole
--linkPrimary link
--link-hoverHover state for primary link
--link-subtleSecondary link
--link-visitedLink visited
SupportRole
--support-errorError
--support-warningWarning
--support-successSuccess
--support-infoInformation
ContentRole
--content-primaryPrimary body copy
--content-secondarySecondary text color
--content-secondary-altSecondary text color alt
--content-placeholderPlaceholder text color
--content-on-colorText on interactive color
--content-errorError message
--content-successSuccess message
--content-inkedInked text

Effects

ShadowsRole
--dialog-strongModals, sidebar overlays, toasts
--dialogDropdown, tooltip, popover
--contentContent area, buttons, controls, cards, pills
--canvasBackground
--keyboard-keyKeyboard key component
FocusRole
--focus-defaultDefault focus
--focus-accentAccent focus
--focus-inverseFocus inverse

Spacings

TokenSourceSize (px/rem)
--spacing-zero--spacing-000 / 0
--spacing-xs--spacing-024 / 0.25
--spacing-s--spacing-048 / 0.5
--spacing-m--spacing-0512 / 0.75
--spacing-l--spacing-0616 / 1
--spacing-xl--spacing-0824 / 1.5
--spacing-xxl--spacing-0932 / 2
--spacing-xxxl--spacing-1148 / 3

Sizing

TokenSourceSize (px/rem)
--size-xs--spacing-0616 / 1
--size-s--spacing-0824 / 1.5
--size-m--spacing-0932 / 2
--controls-size-default--spacing-0932 / 2
--controls-size-small--spacing-0824 / 1.5

Typography

Heading (Desktop)Heading (Mobile)Role
--desktop-heading-01--mobile-heading-01Heading 01
--desktop-heading-02--mobile-heading-02Heading 02
--desktop-heading-03--mobile-heading-03Heading 03
--desktop-heading-04--mobile-heading-04Heading 04
--desktop-heading-05--mobile-heading-05Heading 05
--desktop-heading-06--mobile-heading-06Heading 06
Body (Desktop)Body (Mobile)Role
--desktop-body-xl--mobile-body-xlBody large
--desktop-body--mobile-bodyBody copy
--desktop-body-sm--mobile-body-smBody small
Utility (Desktop)Utility (Mobile)Role
--desktop-caption--mobile-captionCaption
--desktop-helper-text--mobile-helper-textHelper text
--desktop-code--mobile-codeCode

Note: To set line height, simply add the prefix --lh to the font size variables. For instance, --desktop-body-xl becomes --lh-desktop-body-xl.

Releases

Used by

Contributors

Languages