A modern Angular 21 project with Nx monorepo setup featuring a generic, reusable form layout component built with PrimeNG.
- Angular 21 - Latest Angular framework with standalone components
- Nx 22 - Advanced monorepo tooling for better development experience
- PrimeNG - Comprehensive UI component library with Aura theme
- TypeScript - Strict type checking for better code quality
- Signals - Modern reactive state management
- OnPush Change Detection - Optimized performance
- WCAG AA Compliant - Accessible forms with proper ARIA attributes
- Responsive Design - Mobile-friendly layouts
The FormLayoutComponent is a highly configurable, reusable component that accepts:
- FormGroup - Angular reactive form group
- DetailFormConfiguration - Configuration object defining form fields and behavior
input- Text input fieldstextarea- Multi-line text areasnumber- Numeric input with PrimeNG InputNumbercheckbox- Boolean checkboxesdropdown- Select dropdowns with filteringcalendar- Date/time pickerspassword- Password fields with toggle visibilityradio- Radio button groupsbutton- Action buttonslabel- Static text labelspanel- Collapsible panels
import { FormBuilder, Validators } from '@angular/forms';
import { DetailFormConfiguration } from './models';
userForm = this.fb.group({
firstName: ['', Validators.required],
email: ['', [Validators.required, Validators.email]],
country: [null, Validators.required],
});
formConfiguration: DetailFormConfiguration = {
label: 'User Registration',
isSaveButton: true,
discardButtonLabel: 'Cancel',
fields: [
{
name: 'firstName',
label: 'First Name',
type: 'input',
required: true,
placeholder: 'Enter your first name',
},
{
name: 'email',
label: 'Email',
type: 'input',
inputType: 'email',
required: true,
},
{
name: 'country',
label: 'Country',
type: 'dropdown',
options: [
{ label: 'USA', value: 'US' },
{ label: 'UK', value: 'UK' },
],
required: true,
filter: true,
},
],
};<app-form-layout [formGroup]="userForm" [configuration]="formConfiguration" />src/
├── app/
│ ├── components/
│ │ └── form-layout/ # Generic form layout component
│ ├── models/ # TypeScript interfaces and models
│ │ ├── form-entity-data.model.ts
│ │ ├── form-field.model.ts
│ │ └── detail-form-configuration.model.ts
│ ├── app.ts # Main app component
│ ├── app.config.ts # App configuration with PrimeNG setup
│ └── app.routes.ts # Routing configuration
├── styles.scss # Global styles and PrimeNG theme
└── index.html # Entry HTML
- Node.js (v18 or later)
- npm (v9 or later)
Dependencies are already installed. If you need to reinstall:
npm install --legacy-peer-depsRun the development server:
npx nx serve angular-21Navigate to http://localhost:4200/. The application will automatically reload when you change source files.
Build the project:
npx nx build angular-21Build artifacts will be stored in the dist/ directory.
Execute unit tests:
npx nx test angular-21Execute E2E tests:
npx nx e2e e2eThe project uses PrimeNG's Aura theme configured in app.config.ts:
providePrimeNG({
theme: {
preset: Aura,
options: {
darkModeSelector: '.dark-mode',
},
},
});Each field in the DetailFormConfiguration supports extensive customization:
- Layout:
isWide,isMid,class,cssClasses - Validation:
required,validators,maxLength,minLength - UI Options:
placeholder,hint,icon,filter,showClear - Conditional Display:
hide,isEditable - Accessibility: Automatic ARIA attributes
- ✅ Standalone components (no NgModules)
- ✅ Signals for state management
- ✅ OnPush change detection strategy
- ✅
input()andoutput()functions instead of decorators - ✅ Native control flow (
@if,@for,@switch) - ✅ Strict TypeScript type checking
- ✅ WCAG AA accessibility compliance
- ✅ Responsive, mobile-first design
- Angular: 19.x
- Nx: 22.x
- PrimeNG: 19.x
- TypeScript: 5.x
- Vite: Build tool
- Vitest: Unit testing
- Cypress: E2E testing
- Monorepo: Nx workspace for scalability
- Component-Driven: Reusable, composable components
- Type-Safe: Full TypeScript coverage with strict mode
- Performance: OnPush change detection and signals
- Accessibility: ARIA attributes, keyboard navigation, screen reader support