Designing a shared UI library for several Angular applications
The practical decision
Share interaction behaviour. Keep business rules with the product.
Repeated controls are easy to spot; a useful boundary takes more thought. These are the decisions I use to keep a shared Angular interface maintainable as applications evolve.
Start with a repeated responsibility
A library earns its place when a behaviour has more than one consumer and a stable contract. Start with sorting, selection, validation or a repeated layout. Name the second consumer before adding options for hypothetical future products.
Keep product policy outside
A shared grid can own sorting, paging and keyboard navigation. The application owns record identity, permissions, requests and business actions. Pass data, labels and callbacks through an explicit API; do not import application services into the library.
For example, a parcel table and an invoice table can share selection behaviour while applying different rules to export or approve a record. Visibility in the UI does not replace authorization on the server.
Give each behaviour one owner
Use established tools for the jobs they already solve. In my workspace, Angular Aria and the CDK provide interaction foundations, TanStack Table owns grid state, and form APIs own validation state. The shared layer composes them into a consistent interface.
A fix then has a clear home. Consumers still need verification and deployment before that fix reaches users.
Separate rules from rendering
Keep domain-independent models and state transitions separate from Angular views. Test those rules with plain data. Use component tests for binding and interaction, and a real browser when the behaviour depends on layout, focus or native browser APIs.
Make appearance a public contract
Expose colours, spacing and typography through design tokens. Products can change their visual identity without reaching into a component’s private markup. Reusable controls should also carry consistent focus states and touch targets; the composed screen still needs its own accessibility checks.
Show states in a working catalog
A catalog should import the actual components and show loading, empty, error and populated states. Use realistic long labels and dense records. Keep examples small enough to reveal a component’s behaviour without requiring a tour of another product.
Test the contract and its consumers
Cover state transitions with unit tests and key interactions with browser tests. Add automated accessibility checks and manual keyboard review. For visual comparisons, use a consistent rendering environment. Scope test locators to the demonstrated component so a new example does not accidentally change neighbouring tests.
Choose how changes reach applications
In one workspace, verify a library change with its affected applications. A published package also needs versioning, compatibility checks and migration notes. Decide who upgrades consumers and how regressions are reported.
Apply it to one real screen
Extract one duplicated behaviour, wire two consumers and verify both. Keep the public API small and leave product-specific rules at the edge. This gives the next extraction a tested pattern to follow.
The Geoportal architecture uses shared map and interface foundations. The benefit is practical: a common fix can be tested in one place while the product keeps control of its workflows.