# Principles

The rules every @vigdx/ui component follows, and what they make simpler. New APIs follow them from the start; existing ones move toward them through aliases, never through breaking minor releases.

## The principles

1. **Small surface, composition over configuration.** A component keeps around a dozen behavioural inputs. Sub-features are child components, directives or typed option objects; user-facing strings come from `VigdxLabels` and can be overridden per instance.
2. **Types flow from your data.** No `any` in public signatures. New APIs take functions and `keyof T` instead of string paths, regex strings or `{0}` templates, e.g. the password `strength` function or a table column's `value` accessor.
3. **Three styling layers: tokens, then parts, then a class.** Change a CSS custom property first; reach a component's inside through its documented `data-part` attributes; put a class on the host for the rest. No runtime stylesheets and no `!important`. See [Customizing](https://vigdx.com/docs/theming.md).
4. **Stability.** A renamed input keeps its old name as an alias for at least a full major version, warns once in development builds, and loses to the new name when both are set. A CI gate compares the public API (inputs, outputs, types and styling parts) with the committed report and fails a breaking change that is not marked as one.
5. **Docs lead with the happy path**, then customization, accessibility and the API reference.
6. **Accessible by default, native elements first:** `<dialog>`, `<button>`, native inputs and the top layer, checked with AXE in every story.
7. **Performance by construction:** OnPush components on signals that run without zone.js; overlays render their content only while open. Form fields share one pair of document listeners for form submit and reset, and popovers and tooltips listen on the document only while they are open.
8. **One overlay system.** Overlays use the browser's top layer and the CDK overlay container. There are no `appendTo` or `zIndex` inputs. New position values are logical: `start`/`end` (and `top-end`…) mirror in right-to-left layouts. The older `left`/`right` values are deprecated and stay physical, and so do the defaults of an unset drawer (right edge) and toaster (top right) until 3.0.
9. **Forms:** Signal Forms bind directly; Reactive and template-driven forms bind through `VigValueAccessor`. Invalid styling comes from the control's state, not from `ng-*` classes.
10. **Testable:** tests query the `data-scope` / `data-part` contract, not class names or DOM structure, and so do the component harnesses of `@vigdx/ui/testing` ([Testing](https://vigdx.com/docs/testing.md)).
11. **One vocabulary.** `closable` with `closeAriaLabel` and `(closed)`; `heading` for titles; `…AriaLabel` for text only screen readers hear, `…Label` for visible text; `variant` for tone; `sm`/`md`/`lg` sizes; `xChange` for two-way state and past tense for one-shot events.

## What's simpler than PrimeNG

PrimeNG is a large, mature suite. If you are coming from it, these are the differences you will notice first, each with where to check it.

- **Static CSS.** Components ship no stylesheets of their own: their look is Tailwind utilities compiled at build time plus the static `theme.css`, so the kit inserts no theme at runtime and needs no CSP nonce for it. Two limits under a strict `style-src`: the Angular CDK overlay behind select-type panels adds a small structural stylesheet through Angular (covered by Angular's `CSP_NONCE`), and with server-side rendering, `[style.…]` bindings (a dialog's width, a drawer's size) are serialized as `style` attributes, which a policy without `'unsafe-inline'` for styles blocks in the server-rendered HTML. The kit is not fully strict-CSP compatible.
- **Token overrides at three levels** — globally in your `@theme`, on a subtree, or on one instance — with plain CSS custom properties ([Theming](https://vigdx.com/docs/theming.md)).
- **Signal Forms plus a value-accessor bridge.** Controls implement `FormValueControl` for `[formField]`, and `VigValueAccessor` connects them to Reactive and template-driven forms ([Forms](https://vigdx.com/docs/getting-started.md)).
- **Top-layer overlays without `appendTo` or z-index settings.** Dialogs and drawers are native modal `<dialog>` elements; other panels use the CDK overlay container, which the kit keeps above open modals.
- **A required `label` at compile time.** Form fields declare `label` as a required input, so a field without one is a template compile error under `strictTemplates`, not an accessibility bug found later.
- **MIT for every version**, with no license key or registration step.
- **An API gate in CI.** Each package has a committed `api-report.json`; CI fails when the built API differs from it, and a breaking difference needs a `!` in the pull request title (see `CONTRIBUTING.md` in the repository).

Also true of the kit, though not a difference: PrimeNG 22 does not list `@angular/animations` or zone.js among its peer dependencies either.

- **No animations package.** `@angular/animations` is not a dependency; transitions are CSS, and reduced motion is respected.
- **Zoneless and OnPush.** Every component uses OnPush change detection and signals, and the test suite runs without zone.js.

Moving an app over? See [Migrating from PrimeNG](https://vigdx.com/docs/migrating-from-primeng.md) for a component mapping and before-and-after examples.
