Skip to content

About

Angular directives for ui-sdk: keyboard, focus, popups and ARIA on your own elements

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

51 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ngx-ui-sdk

Angular directives for ui-sdk. Built on @ui-sdk/core 0.1.0-beta.10, for Angular 22.

Demo · Documentation · npm

ui-sdk handles keyboard navigation, focus, dismissal, popups and ARIA. This package brings that to Angular. Each part of a component is a directive on your own element. You write the markup and the styles.

The package is experimental. Expect breaking changes until 1.0.

Getting started

Install it with @ui-sdk/core:

npm install @ngx-ui-sdk/core @ui-sdk/core

Each component has its own entry point, like @ngx-ui-sdk/core/dialog, so your app only bundles what it imports. Import the directives into a standalone component:

import { Component, signal } from "@angular/core"
import {
  UiDialog,
  UiDialogBackdrop,
  UiDialogClose,
  UiDialogContent,
  UiDialogDescription,
  UiDialogTitle,
  UiDialogTrigger,
} from "@ngx-ui-sdk/core/dialog"

@Component({
  selector: "app-edit-profile",
  imports: [
    UiDialog,
    UiDialogBackdrop,
    UiDialogClose,
    UiDialogContent,
    UiDialogDescription,
    UiDialogTitle,
    UiDialogTrigger,
  ],
  template: `
    <ng-container uiDialog [(open)]="open">
      <button uiDialogTrigger>Edit profile</button>
      <div *uiDialogBackdrop class="backdrop"></div>
      <div *uiDialogContent class="dialog">
        <h2 uiDialogTitle>Edit profile</h2>
        <p uiDialogDescription>Make changes to your profile.</p>
        <button uiDialogClose>Close</button>
      </div>
    </ng-container>
  `,
})
export class EditProfile {
  readonly open = signal(false)
}

No providers or configuration needed. Parts with text of their own, like a select's value, show it when you add uiText: <span uiSelectValue uiText></span>. The ui-sdk documentation describes every component, its parts and options. The names are the same here: DialogTrigger is uiDialogTrigger.

Styling

The directives add no styles. Style the parts with:

  • State attributes: data-open, data-highlighted, data-selected, data-disabled, and data-starting-style and data-ending-style for animations.
  • data-slot on every part, like data-slot="dialog-content".
  • CSS variables on popups, like --anchor-width and --available-height.
[data-slot="dialog-content"] {
  transition: opacity 150ms;
}

[data-slot="dialog-content"][data-starting-style],
[data-slot="dialog-content"][data-ending-style] {
  opacity: 0;
}

Themes

The demo's themes are a separate package: ui-sdk's own, shadcn, Material and daisyUI, some with palettes.

npm install @ngx-ui-sdk/themes

Add one to angular.json:

"styles": ["@ngx-ui-sdk/themes/default/all.css", "src/styles.css"]

A theme only styles elements inside data-ui-theme. To style the whole app, add it to <body>:

<body data-ui-theme></body>

Colors, radii and sizes are CSS variables you can override. Its readme has the themes, their palettes and how to load less CSS.

Components

Component Supported
Accordion ✅
Alert Dialog ✅
Autocomplete ✅
Avatar ✅
Button ✅
Calendar ✅
Carousel ✅
Checkbox ✅
Collapsible ✅
Color Picker ✅
Combobox ✅
Command ✅
Date Input ✅
Date Picker ✅
Dialog ✅
Drawer ✅
Field ✅
File Input ✅
Hover Card ✅
Image ✅
Image Cropper ✅
Input ✅
Label ✅
Listbox ✅
Menu ✅
Menubar ✅
Meter ✅
Navigation Menu ✅
Number Input ✅
OTP Input ✅
Pagination ✅
Password Input ✅
Popover ✅
Preferences ✅
Progress ✅
Radio ✅
Rating ✅
Resizable ✅
Scroll Area ✅
Segmented Control ✅
Segmented Input ✅
Select ✅
Separator ✅
Shortcuts ✅
Slider ✅
Switch ✅
Tabs ✅
Textarea ✅
Time Input ✅
Timeline ✅
Toast ✅
Toggle ✅
Token Input ✅
Toolbar ✅
Tooltip ✅
Tree ✅
Trigger Menu ✅
Waterfall ✅
Agent tools ✅

Agents

AI agents can read and use your components through ui-sdk's agent bridge. Import it from @ngx-ui-sdk/core/agent:

import { createAgent } from "@ngx-ui-sdk/core/agent"

const agent = createAgent()
agent.snapshot() // the components on the page, their state and actions

See Built for Agents in the ui-sdk documentation.

Testing

This is not an official ui-sdk package. It runs ui-sdk's own end-to-end tests, unchanged: 268 Playwright spec files with more than 4,000 tests, the same ones the React, Vue, Svelte, Solid and web component adapters pass. They cover:

  • keyboard, pointer and touch input, focus, dismissal, forms and controllers
  • axe audits, screen reader announcements and WAI-ARIA patterns
  • right-to-left layouts
  • memory leaks across hundreds of mounts

ui-sdk's server rendering tests don't run yet. The demo examples and the adapter internals have their own tests. Everything runs in CI on every push.

Development

Read AGENTS.md, contributing/design.md and contributing/code.md first.

git submodule update --init
npm install
npm start               # demo
npm run test:upstream   # ui-sdk's tests against the playground
npm run lint

About

Angular directives for ui-sdk: keyboard, focus, popups and ARIA on your own elements

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages