Skip to content
NativeScript Unified

Components

Components

These pages show the Spartan helm components that live in packages/ui/helm. Build new UI with them. They are plain HTML elements and attributes, styled with Tailwind classes and the shared theme tokens.

Every example is a real Angular template. The code in the Code tab is the code that renders in the Preview tab, compiled at run time against the helm components in this workspace. That happens in your browser on the web, and on the device in the native app.

How it works

Spartan has two layers, and both live in packages/ui:

LayerImportWhat it does
brain@spartan-ng/brain/*Headless primitives. They handle ARIA attributes, keyboard navigation, focus and open and closed state, and render no styles.
helm@spartan-ng/helm/*Styled directives and small components on top of brain, written with Tailwind classes that read the theme tokens.

You mostly use helm. A helm component is usually an attribute on an element you already know:

<button hlmBtn variant="outline">A button element with the hlmBtn attribute</button>

Variants, such as variant="outline", are inputs on the directive. Colours come from the tokens in packages/ui/styles/tokens.css, so every component follows Theming and dark mode. Both layers are consumed from source, so you can read and change any component in packages/ui.

Pages

PageComponents
ButtonhlmBtn
BadgehlmBadge
CardhlmCard and its parts
Form controlshlmInput, hlmLabel, hlmTextarea, hlm-checkbox, hlm-switch, hlm-radio-group
TabshlmTabs and its parts
Accordionhlm-accordion and its parts
Dialoghlm-dialog and its parts
AlerthlmAlert
Progress, skeleton, avatar and separatorhlm-progress, hlmSkeleton, hlm-avatar, hlmSeparator
Pickerhlm-picker
Selecthlm-select and its parts
Sliderhlm-slider
Popoverhlm-popover and its parts
Dropdown menuhlmDropdownMenuTrigger, hlm-dropdown-menu and its parts
Sheethlm-sheet and its parts
Drawerhlm-drawer and its parts
TablehlmTable and its parts
Calendarhlm-calendar, hlm-calendar-multi, hlm-calendar-range
TooltiphlmTooltip
Toasthlm-toaster and toast()
More componentstoggle, toggle group, collapsible, hover card, kbd, spinner, breadcrumb, native select, alert dialog

Native status

The native app renders these pages too, and compiles each demo on the device against the same helm components. This table records what each demo does there.

ComponentAndroidNotes
ButtonWorksA link styled as a button navigates.
BadgeWorks
CardWorksRing and shadow are drawn.
Form controlsWorks
TabsWorks
AccordionWorks
DialogWorksOpens as the platform's dialog. See Native elements.
AlertWorks
PickerWorksOpens full screen with ModalDialogService. The list scrolls under the search field.
SelectWorksOpens in a native popover window. The list does not scroll, so a long list runs to the window's edge.
SliderWorksOne value is Material's slider (UISlider on iOS). A range is helm's track and thumbs, moved by touch. Keyboard steps are web only.
PopoverWorksOpens in a native popover window.
Dropdown menuWorksOpens the platform menu, with labels, separators, shortcuts and submenus.
SheetWorksBottom sheets open in a native bottom sheet, other sides in a side drawer.
DrawerWorksOpens in a native bottom sheet.
TableWorkscolspan is ignored: each cell takes an equal share of its row.
CalendarWorks
TooltipWorksOpens on a tap or long press and closes itself. There is no arrow.
ToastWorksA native toaster draws the toasts where it sits in the layout.
Toggle, toggle group, collapsible, breadcrumb, alert dialog, kbd, spinnerWorksThe alert dialog opens as the platform's dialog. See Native elements.
Hover cardWorksOpens on a tap instead of a hover.
Native selectWorksOpens the platform menu.
Separator, avatar, skeletonWorks
ProgressPartialThe indicator is sized but its fill is not painted.

The pages under NativeScript views are web polyfills of NativeScript's own views. On a device those tags are NativeScript's real views, so their demos can look different there, and a demo written in markup only the polyfills understand shows its code only. A few causes affect every component on native. See Known native limitations.

More in the workspace

packages/ui/helm holds more components than these pages cover, for example carousel, chart, command, combobox, context-menu, date-picker, menubar and sidebar. The Spartan docs describe them. The Charts and Chart gallery examples use chart.

Imports in your own code

In an app, import from the helm entry point for each component:

import { HlmButton } from '@spartan-ng/helm/button';
import { HlmCardImports } from '@spartan-ng/helm/card';