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:
| Layer | Import | What 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
| Page | Components |
|---|---|
| Button | hlmBtn |
| Badge | hlmBadge |
| Card | hlmCard and its parts |
| Form controls | hlmInput, hlmLabel, hlmTextarea, hlm-checkbox, hlm-switch, hlm-radio-group |
| Tabs | hlmTabs and its parts |
| Accordion | hlm-accordion and its parts |
| Dialog | hlm-dialog and its parts |
| Alert | hlmAlert |
| Progress, skeleton, avatar and separator | hlm-progress, hlmSkeleton, hlm-avatar, hlmSeparator |
| Picker | hlm-picker |
| Select | hlm-select and its parts |
| Slider | hlm-slider |
| Popover | hlm-popover and its parts |
| Dropdown menu | hlmDropdownMenuTrigger, hlm-dropdown-menu and its parts |
| Sheet | hlm-sheet and its parts |
| Drawer | hlm-drawer and its parts |
| Table | hlmTable and its parts |
| Calendar | hlm-calendar, hlm-calendar-multi, hlm-calendar-range |
| Tooltip | hlmTooltip |
| Toast | hlm-toaster and toast() |
| More components | toggle, 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.
| Component | Android | Notes |
|---|---|---|
| Button | Works | A link styled as a button navigates. |
| Badge | Works | |
| Card | Works | Ring and shadow are drawn. |
| Form controls | Works | |
| Tabs | Works | |
| Accordion | Works | |
| Dialog | Works | Opens as the platform's dialog. See Native elements. |
| Alert | Works | |
| Picker | Works | Opens full screen with ModalDialogService. The list scrolls under the search field. |
| Select | Works | Opens in a native popover window. The list does not scroll, so a long list runs to the window's edge. |
| Slider | Works | One value is Material's slider (UISlider on iOS). A range is helm's track and thumbs, moved by touch. Keyboard steps are web only. |
| Popover | Works | Opens in a native popover window. |
| Dropdown menu | Works | Opens the platform menu, with labels, separators, shortcuts and submenus. |
| Sheet | Works | Bottom sheets open in a native bottom sheet, other sides in a side drawer. |
| Drawer | Works | Opens in a native bottom sheet. |
| Table | Works | colspan is ignored: each cell takes an equal share of its row. |
| Calendar | Works | |
| Tooltip | Works | Opens on a tap or long press and closes itself. There is no arrow. |
| Toast | Works | A native toaster draws the toasts where it sits in the layout. |
| Toggle, toggle group, collapsible, breadcrumb, alert dialog, kbd, spinner | Works | The alert dialog opens as the platform's dialog. See Native elements. |
| Hover card | Works | Opens on a tap instead of a hover. |
| Native select | Works | Opens the platform menu. |
| Separator, avatar, skeleton | Works | |
| Progress | Partial | The 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';