Title: router-outlet should not affect layout (option to render as non-box/anchor) · Issue #64553 · angular/angular · GitHub
Open Graph Title: router-outlet should not affect layout (option to render as non-box/anchor) · Issue #64553 · angular/angular
X Title: router-outlet should not affect layout (option to render as non-box/anchor) · Issue #64553 · angular/angular
Description: Which @angular/* package(s) are relevant/related to the feature request? router Description is a marker element that does not contain the routed component’s DOM; the actual component root is rendered as a sibling after the outlet. Howeve...
Open Graph Description: Which @angular/* package(s) are relevant/related to the feature request? router Description is a marker element that does not contain the routed component’s DOM; the actual component root is render...
X Description: Which @angular/* package(s) are relevant/related to the feature request? router Description is a marker element that does not contain the routed component’s DOM; the actual component root is render...
Opengraph URL: https://github.com/angular/angular/issues/64553
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"router-outlet should not affect layout (option to render as non-box/anchor)","articleBody":"### Which @angular/* package(s) are relevant/related to the feature request?\n\n`router`\n\n### Description\n\n\u003crouter-outlet\u003e is a marker element that does not contain the routed component’s DOM; the actual component root is rendered as a sibling after the outlet.\nHowever, the outlet element itself still participates in layout (inline/box). This can interfere with CSS Grid/Flexbox flows, gaps, and alignment, forcing developers to add a global stylesheet rule like:\n\n```css\nrouter-outlet { display: none; }\n```\n\nor similar hacks.\n\nRelated to: https://stackoverflow.com/questions/54868967/how-to-get-angulars-router-outlet-to-work-with-css-grid\n\n### Motivation\n\n- Avoid layout artifacts (extra empty grid/flex item, unexpected inline box).\n- Reduce boilerplate and “magic CSS” in every app and library.\n- Make router behavior consistent with other Angular structural anchors, which use comment anchors and do not create a layout box.\n\n\n### Proposed solution\n\n(any of the following would solve the problem)\n\n#### 1. Opt-in comment anchor for outlets\n\nAdd a configuration/flag so that router-outlet uses a comment node anchor (like `@if`) instead of an element. \nPossible shapes:\n\nRouter config:\n\n```typescript\nprovideRouter(routes, { outletAnchor: 'comment' /* | 'element' (default) */ });\n```\n\nOr attribute/boolean input on the outlet:\n\n```html\n\u003crouter-outlet anchor=\"comment\"\u003e\u003c/router-outlet\u003e\n```\n\nOr provide control-flow directive:\n```html\n@router-outlet;\n\n@router-outlet (name: 'secondary');\n\n@router-outlet { placeholder };\n\n@router-outlet (name: 'secondary') { placeholder };\n```\n\n#### 2. Documented \u0026 bundled style\n\nOfficially document and ship a built-in global style (or recommend it prominently in the Router docs) so apps don’t need to rediscover it:\n\n```css\nrouter-outlet { display: none /* or display: contents */; }\n```\n\n### Alternatives considered\n\nKeep relying on app-level CSS (`router-outlet { display:none }`).\nWorks, but it’s non-obvious, duplicated across apps, and easy to miss (especially inside Shadow DOM).","author":{"url":"https://github.com/MillerSvt","@type":"Person","name":"MillerSvt"},"datePublished":"2025-10-21T00:25:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/64553/angular/issues/64553"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7112098a-62a2-7d15-bba7-29932a6a1978 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CB86:340321:AF7720A:E2D48BB:69767994 |
| html-safe-nonce | 3eba1b83cccce6e614c30c665eae502c457c8c3f5b81edd5739c194d29bd7475 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQjg2OjM0MDMyMTpBRjc3MjBBOkUyRDQ4QkI6Njk3Njc5OTQiLCJ2aXNpdG9yX2lkIjoiNTc1NjE1MDMxMzI5MDk4NzkyNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 85960fcf9245ce0db544e842b0b1782e00bbc7fbb93deb4ec3592f0d02cb00bb |
| hovercard-subject-tag | issue:3534396329 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/64553/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b81aba106d59a2257c6c7a4eaad0bde383af35e5a4ca900a8592d6bd7dd4b37b/angular/angular/issues/64553 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b81aba106d59a2257c6c7a4eaad0bde383af35e5a4ca900a8592d6bd7dd4b37b/angular/angular/issues/64553 |
| og:image:alt | Which @angular/* package(s) are relevant/related to the feature request? router Description is a marker element that does not contain the routed component’s DOM; the actual component root is render... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MillerSvt |
| hostname | github.com |
| expected-hostname | github.com |
| None | 032152924a283b83384255d9489e7b93b54ba01da8d380b05ecd3953b3212411 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5b577f6be6482e336e3c30e8daefa30144947b17 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width