@vigdx/ui v2.2.0 on npm (opens in a new tab)

Getting started

Add @vigdx/ui to an Angular 22 app, with or without Tailwind CSS v4: install the package, import the styles, register the providers and use your first component.

View as Markdown

Requirements

  • Angular 22 (standalone components; zone.js optional)
  • Tailwind CSS 4 with @tailwindcss/postcss, or no Tailwind at all with the precompiled stylesheet
  • @angular/cdk 22 as a peer dependency

Note

The kit bundles no font files. Its tokens name Montserrat and Geist Mono, which the stylesheet below loads from Google Fonts; self-host them instead, or point --font-sans and --font-mono at your own.

Install

Current version: @vigdx/ui 2.2.0 on npm (opens in a new tab)

Terminal
pnpm add @vigdx/ui @angular/cdk@^22

If the app uses Tailwind, or you want it to, set it up with its PostCSS plugin (otherwise skip to Without Tailwind):

Terminal
pnpm add -D tailwindcss @tailwindcss/postcss postcss
.postcssrc.json
{
  "plugins": {
    "@tailwindcss/postcss": {}
  }
}

Import the theme

In your global stylesheet, import Tailwind, the CDK overlay styles and the kit's theme.css, then point @source at the package so Tailwind generates the utilities its components use.

styles.css
/* src/styles.css */
/* The kit's tokens reference Montserrat and Geist Mono; load them yourself. */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&family=Geist+Mono:wght@400;500;600&display=swap');
@import 'tailwindcss';
@import '@angular/cdk/overlay-prebuilt.css';
@import '@vigdx/ui/theme.css';

/* Let Tailwind scan the library's compiled output for the classes it uses. */
@source '../node_modules/@vigdx/ui/**/*.mjs';

/* Optional: make Tailwind's dark: variant follow the kit's .dark class. */
@custom-variant dark (&:where(.dark, .dark *));

Every token in theme.css is declared with @theme default, so your own @theme always wins — see Theming.

Without Tailwind

Apps without Tailwind import the precompiled @vigdx/ui/styles.css instead (about 270 kB, 22 kB gzipped): the tokens of theme.css and exactly the utilities the components use, generated when the package is built. Nothing else to install or configure.

styles.css
/* src/styles.css (listed under "styles" in angular.json) — no Tailwind */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&family=Geist+Mono:wght@400;500;600&display=swap');
/* A reset of yours (normalize.css, Bootstrap…) goes first. */
@import '@angular/cdk/overlay-prebuilt.css';
@import '@vigdx/ui/styles.css';
/* Your own styles go after it. */
  • It styles the kit's own elements only: its base styles (Tailwind's preflight) and utilities match elements carrying one of the kit's data-scope values, overlay panels included. Your markup, and content you project into a component, keeps its own styles; a class="p-2" of yours is not the kit's p-2.
  • Resets and global styles of yours (normalize.css, Bootstrap's reboot, element rules) do not restyle the kit: its rules have specificity 0,1,0, above element selectors. To restyle a kit element, use a part selector ([data-scope='chip'][data-part='close']) or an equally specific rule loaded after styles.css.
  • Tokens sit in the vigdx cascade layer: override them on :root, .dark, a subtree or one instance (see Theming). The kit's font follows --font-sans; set it to give the kit your app's font.

WarningOne setup, not both

A Tailwind app should use theme.css with @source. Adding styles.css on top repeats the utilities and tokens under the same names: which copy wins then depends on the order of the cascade layers, and your @theme overrides no longer reach the precompiled tokens.

Register the providers

Call provideVigdxUi() once in the application config. It keeps dropdowns inside dialogs and drawers interactive and sets the default labels for the chosen locale.

app.config.ts
// src/app/app.config.ts
import { ApplicationConfig } from '@angular/core';
import { provideVigdxUi } from '@vigdx/ui/core';

export const appConfig: ApplicationConfig = {
  providers: [
    // Keeps dropdowns inside dialogs and drawers interactive
    // and sets the default (translated) labels.
    provideVigdxUi({ locale: 'en' }),
  ],
};

Your first component

Import each component or directive in the standalone component that uses it. Inputs are signals; two-way values use [( )].

newsletter.ts
import { Component, signal } from '@angular/core';
import { Button } from '@vigdx/ui/button';
import { InputField } from '@vigdx/ui/input-field';

@Component({
  selector: 'app-newsletter',
  imports: [Button, InputField],
  templateUrl: './newsletter.html',
})
export class Newsletter {
  readonly email = signal('');
}
newsletter.html
<vig-input label="Email" type="email" [(value)]="email" />
<vig-button label="Subscribe" [disabled]="!email()" />

Every component has an entry point of its own, named after it: @vigdx/ui/button, @vigdx/ui/input-field, @vigdx/ui/table… Providers and helpers shared by the kit, such as provideVigdxUi and VigValueAccessor, come from @vigdx/ui/core. Each component page shows its import line.

NoteWhy entry points

A bundler splits code file by file, and each entry point ships as a file of its own. A component that only a lazy route imports then stays out of the initial bundle, even when the app shell imports other components. Imports from the package root, @vigdx/ui, keep working: it re-exports every entry point.

TipPlace the overlay hosts once

Using the Toast or Confirm services? Add <vig-toaster /> and <vig-confirm-dialog /> to your app shell.

Forms

Form controls implement Signal Forms' FormValueControl, so [formField] binds value, validation and touched state directly:

TypeScript
import { Component, signal } from '@angular/core';
import { FormField, email, form, required } from '@angular/forms/signals';
import { InputField } from '@vigdx/ui/input-field';

@Component({
  imports: [FormField, InputField],
  template: `<vig-input label="Email" type="email" [formField]="f.email" />`,
})
export class Signup {
  readonly model = signal({ email: '' }); // '' — never null or undefined
  readonly f = form(this.model, (p) => {
    required(p.email);
    email(p.email);
  });
}

For Reactive Forms (formControlName, [formControl]) and ngModel, import VigValueAccessor next to the component. Built-in validators such as Validators.required show the same messages.

TypeScript
import { Component } from '@angular/core';
import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
import { VigValueAccessor } from '@vigdx/ui/core';
import { InputField } from '@vigdx/ui/input-field';

@Component({
  imports: [ReactiveFormsModule, InputField, VigValueAccessor],
  template: `
    <form [formGroup]="form">
      <vig-input label="Name" formControlName="name" />
    </form>
  `,
})
export class Profile {
  readonly form = new FormGroup({
    name: new FormControl('', { nonNullable: true, validators: [Validators.required] }),
  });
}

Empty values are '' for text, null for numbers, dates and single selection, [] for multiple selection and files, and false for booleans.

Localization

English (en) and Turkish (tr) ship built in. Pass labels for partial overrides, including validation messages; component inputs still override per instance.

TypeScript
provideVigdxUi({
  locale: 'tr',
  labels: { errors: { required: 'Bu alan zorunludur.' } },
});

Register more languages with registerVigdxLocale and switch without a reload through VigdxI18n. Labels you pass as inputs stay as given.

TypeScript
import { inject } from '@angular/core';
import { VigdxI18n, registerVigdxLocale } from '@vigdx/ui/core';

// Add a language (BCP 47 code); missing keys fall back to English.
registerVigdxLocale('de', { paginationAriaLabel: 'Seitennavigation' /* … */ });

// Switch at runtime: every default label of open components follows.
inject(VigdxI18n).setLocale('de');

Right-to-left

Components use logical CSS (ps-*, start-*, text-start), so they mirror under right-to-left scripts. Overlay panels read the direction from the CDK Directionality.

HTML
<!-- The whole app -->
<html dir="rtl" lang="ar">

<!-- Or one subtree: import Dir from @angular/cdk/bidi so overlay panels follow -->
<section dir="rtl">…</section>

Positions are logical too: vig-drawerposition="end", vig-toasterposition="top-end" and vigTooltipPosition="start" follow the text direction. Their older physical values (left, right, top-right…) are deprecated and keep their side in both directions.

Icons

<vig-icon name="check" /> renders a registered SVG glyph at 1em in the current text color. Register your own, or override built-ins by name:

TypeScript
import { provideVigdxIcons } from '@vigdx/ui/icon';

providers: [
  provideVigdxIcons({
    pencil: { paths: ['M17 3a2.8 2.8 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z'] },
  }),
];

Element ids

Components generate the ids their labels and ARIA attributes point to, such as vig-input-0. They are counted per application, so they restart at 0 in every app and in every TestBed test; do not hard-code them in tests or styles. An app with its own APP_ID adds it to them (vig-input-shop-0 for shop), so several apps can share a page.

With server rendering the browser continues counting after the ids the server used. Blocks that incremental hydration leaves as rendered (@defer (hydrate …)) keep their server ids without clashing with new ones; hydrated components get fresh ids together with the labels and ARIA references that point to them.

Next steps

Are you sure?