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

Master-detail

A list and a detail view driven by the URL: the detail sits beside the list in a wide container and opens in a vig-drawer in a narrow one, decided by a container query rather than the viewport, with focus following the selection.

Live demo

Pick a ticket: the URL gets ?ticket= and focus moves to the ticket's heading. Narrow the demo's container to get the drawer layout without resizing the window.

A list of records with the selected record's detail. The selection lives in the URL ( ?ticket=T-1042 ). Where the page has room, the detail sits beside the list; in a narrow space it opens in a drawer. The page decides by its own width (a container query), not the viewport's, so it works the same in a sidebar layout, a split view or full screen.

When to use

  • Users scan a list and read one item at a time: inboxes, support tickets, orders, logs.
  • The detail is read more than edited; for editing, link to a form page (see the form-page recipe).
  • For a table with many columns where rows are compared, use the crud-list recipe and open the detail from a row action instead.

Component choices

Need Component Why Alternatives
The list A list of links ( routerLink with queryParams ) Selection is navigation: the URL updates, back and forward work, middle-click opens a new tab; aria-current marks the selected one vig-table with selectionMode="single" when the list needs columns
Status vig-badge Text plus color, never color alone vig-chip when the user can remove it
Detail beside the list A section named "Ticket details" Stays in the reading order after the list —
Detail on narrow screens vig-drawer Native modal: focus moves in, Escape and the backdrop close it, focus returns to the link A separate detail route ( /tickets/:id ) that replaces the list on phones
Nothing selected, not found, errors vig-empty-state Explains the state, offers a retry where it helps —
Loading vig-skeleton Keeps the layout stable while data arrives vig-spinner for short waits without layout

Folder structure

Angular CLI

Text
src/app/features/tickets/
  data-access/
    ticket.ts                  TicketSummary for the list, Ticket for the detail
    tickets-api.ts             abstract API = DI token, TicketNotFoundError
    http-tickets-api.ts
    in-memory-tickets-api.ts
    tickets-store.ts           list, selected id, selected ticket
  feature/
    tickets-page.ts            routed smart page: URL, layout, focus
    tickets.routes.ts
  ui/
    ticket-labels.ts           texts and badge variants
    ticket-list.ts             presentational list of links
    ticket-detail.ts           presentational detail
app.routes.ts
{
  path: 'tickets',
  providers: [{ provide: TicketsApi, useClass: HttpTicketsApi }],
  loadChildren: () =>
    import('./features/tickets/feature/tickets.routes').then((m) => m.ticketsRoutes),
}

The ticket query parameter reaches the page's ticket input through withComponentInputBinding() in provideRouter .

Nx

Terminal
npx nx g @nx/angular:library --directory=libs/tickets/data-access --name=tickets-data-access --tags=type:data-access,scope:tickets --prefix=app --no-interactive
npx nx g @nx/angular:library --directory=libs/tickets/feature-inbox --name=tickets-feature-inbox --tags=type:feature,scope:tickets --prefix=app --no-interactive
npx nx g @nx/angular:library --directory=libs/tickets/ui --name=tickets-ui --tags=type:ui,scope:tickets --prefix=app --no-interactive

Key decisions

  • The URL owns the selection. Picking a ticket is a link to ?ticket=<id> ; the page mirrors the query parameter into the store, which loads that ticket. Reloading, sharing the URL and the back button all restore the same view. A query parameter (rather than /tickets/:id ) keeps the list component alive while the selection changes; with a path parameter, use one route whose component reads an optional :id child param the same way.
  • Light list, full detail. The list endpoint returns TicketSummary objects; the detail loads the full Ticket by id. The store holds both as rxResource s; deselecting idles the detail.
  • Container query, not viewport. The grid switches to two columns with Tailwind's @3xl container variant (48rem) on the page's own @container . The drawer needs the same answer in code, so a ResizeObserver on the page compares its width with WIDE_LAYOUT_MIN_WIDTH_REM (also 48rem). On the server, without ResizeObserver , the wide layout renders.
  • One detail template, two places. The detail states (none selected, loading, not found, error, loaded) are written once in an ng-template and rendered either in the side pane or in the drawer.
  • Closing the drawer clears the selection. Escape, the close button and the backdrop all end in openChange(false) , which removes ?ticket from the URL. Growing the container while a ticket is open simply moves the detail out of the drawer.

Accessibility

  • Each ticket is a real link, the selected one has aria-current="true" , and the selected state is shown by a border as well as a tint, so it survives forced-colors mode.
  • After a pick, focus moves to the detail's heading ( tabindex="-1" ), so screen readers start reading the new content and keyboard users continue from there; in the drawer the native dialog moves focus and returns it to the link on close.
  • The list and the detail are named sections; loading skeletons sit in a named role="status" container.
  • Error states say what failed and offer a retry in user-facing texts ( TICKETS_PAGE_TEXT ); the technical error.message stays out of the UI.
  • Dates are <time datetime> elements; badges carry text.

Performance

  • track ticket.id keeps list items stable across reloads.
  • Only the selected ticket's body is loaded; the list stays small.
  • OnPush everywhere; the layout signal changes only when the width crosses the breakpoint.
  • The feature is lazy-loaded; consider @defer (on viewport) for heavy detail parts such as attachments or history.

Definition of done

  • nx build <app> (or ng build ) succeeds; nx lint passes.
  • The specs pass: list, selection from the URL, focus after picking, not found, list error and retry, the narrow layout in a drawer, closing it clears the URL.
  • axe reports no violations in the wide and the narrow layout (drawer open), light and dark.
  • Keyboard only: tab to a ticket, open it, read it, go back to the list; in the narrow layout close the drawer with Escape and land on the same link.
  • Reload with ?ticket= in the URL shows that ticket; back and forward move between selections.

Source files

Are you sure?