Skip to content

fix: shrink file tree code blocks - #2208

Open
luozejian wants to merge 1 commit into
sveltejs:mainfrom
luozejian:fix-258-file-tree-styles
Open

fix: shrink file tree code blocks#2208
luozejian wants to merge 1 commit into
sveltejs:mainfrom
luozejian:fix-258-file-tree-styles

Conversation

@luozejian

Copy link
Copy Markdown

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time.
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.

Fixes #258

Problem

File tree code blocks in documentation and blog posts currently expand to the full content width, even when the tree itself is much narrower. This leaves a large amount of empty space and makes file trees look disproportionate compared with their content.

Solution

Shrink tree code blocks to their intrinsic content width on non-mobile viewports while keeping them capped at the available content width.

The inner pre uses automatic width so it can contribute its intrinsic size, with extra right padding reserved for the copy button. Mobile layouts keep the existing full-width block and horizontal scrolling behavior.

This only targets code blocks whose generated pre has data-language="tree"; other code blocks are unchanged.

Validation

Chrome layout measurements:

  • Docs project structure page: 749px block reduced to 354px
  • Blog file trees: 856px blocks reduced to approximately 245px and 254px
  • 320px mobile viewport: block remains 288px wide with internal horizontal scrolling

The following checks pass:

  • pnpm --filter @sveltejs/site-kit lint
  • pnpm --filter @sveltejs/site-kit check
  • pnpm --filter svelte.dev check
  • pnpm build

@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

@luozejian is attempting to deploy a commit to the Svelte Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[blog post] / [docs] file trees look terrible

1 participant