Skip to content

Conversation

@tony
Copy link

@tony tony commented Dec 13, 2025

RFC / Context: Dev Toolbar: allow configuring default position roadmap#1277

DX / Quality of life tweak for dev toolbar placement.

Changes

Adds optional devToolbar.placement configuration option.

  • New config property: devToolbar.placement accepts 'bottom-left', 'bottom-center', or 'bottom-right'

  • Priority: defaultSettingsconfiglocalStorage (user's UI choice still wins)

  • Use case: Sites with bottom-center UI elements (chat widgets, cookie banners) can set a project-wide default that persists across team members and localStorage clears

    Example: image

    Before this PR, it would require manually setting the placement every time localStorage is cleared. Doesn't persist as a project default.

Exampe usage, astro.config.mjs:

export default defineConfig({
  devToolbar: {
    placement: 'bottom-left',
  },
});

Files changed

File Change
types/public/toolbar.ts Export DevToolbarPlacement type
types/public/config.ts Add placement to interface with JSDoc
core/config/schemas/base.ts Add Zod schema validation
vite-plugin-astro-server/pipeline.ts Pass placement to client metadata
runtime/client/dev-toolbar/settings.ts Implement priority chain
test/units/config/config-validate.test.js Add validation tests

Testing

  • Added unit tests for config validation:
    • Valid placement values are accepted
    • Invalid placement values are rejected
    • Omitting placement is allowed (optional)

Testing only test/units/config/config-validate.test.js:

pnpm:

pnpm --filter=astro exec astro-scripts test "test/units/config/config-validate.test.js"

npm:

node --test packages/astro/test/units/config/config-validate.test.js

Docs

@withastro/maintainers-docs for feedback, Documentation needed for:

  • Configuration reference: new devToolbar.placement option
  • Default value: 'bottom-center'
  • Behavior: config acts as default, localStorage overrides persist user choice

@changeset-bot
Copy link

changeset-bot bot commented Dec 13, 2025

🦋 Changeset detected

Latest commit: bd8c445

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) docs pr labels Dec 13, 2025
@tony tony changed the title Feat/devtoolbar placement conf Add devToolbar.placement configuration option Dec 13, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 13, 2025

Merging this PR will not alter performance

✅ 9 untouched benchmarks


Comparing tony:feat/devtoolbar-placement-conf (bd8c445) with main (9e7a3c8)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (33b65d7) during the generation of this report, so 9e7a3c8 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@tony tony marked this pull request as ready for review December 13, 2025 20:23
@tony tony force-pushed the feat/devtoolbar-placement-conf branch 2 times, most recently from bc17e05 to 8e300bb Compare December 22, 2025 11:39
@tony tony force-pushed the feat/devtoolbar-placement-conf branch from 8e300bb to 88b0cb2 Compare December 28, 2025 19:05
@tony tony force-pushed the feat/devtoolbar-placement-conf branch from 88b0cb2 to c6821fa Compare January 13, 2026 10:38
@tony
Copy link
Author

tony commented Jan 13, 2026

@withastro Dev toolbar placement is tied to a site’s layout rather than an individual user preference, so defining it in config makes the default explicit and consistent across environments (e.g. dev machines, browser instances), while still preserving local overrides.

Assuming the case is sound, is this the right approach for introducing the config option? Are there any other boxes I should be ticking?

@Princesseuh
Copy link
Member

Hello! Apologies for the delay, with the upcoming Astro 6 and the holidays, some things fell through the cracks. I'll be reviewing this shortly!

Copy link
Member

@Princesseuh Princesseuh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good with me, awesome work!

@Princesseuh Princesseuh added this to the 5.17.0 milestone Jan 13, 2026
Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for providing this new feature! Left a note on the kind of changeset message we'd typically like to have with an example you can use as a model. And the docs look good! Just tiny updates!

@tony tony force-pushed the feat/devtoolbar-placement-conf branch from a78725a to 923d8c4 Compare January 14, 2026 00:39
@tony
Copy link
Author

tony commented Jan 14, 2026

@Princesseuh @sarah11918 Thank you - Rebased! Let me know if this works!

@tony tony force-pushed the feat/devtoolbar-placement-conf branch 2 times, most recently from cef52b4 to 6b3689b Compare January 14, 2026 23:10
Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving for docs! Thanks for making the dev toolbar even more usable! 🥳

tony and others added 8 commits January 16, 2026 12:45
Add exported type for toolbar placement options and extend
DevToolbarMetadata to include optional placement property.
Add optional `placement` property to devToolbar config schema
and interface with JSDoc documentation.
Pass the devToolbar.placement config value to the client via
__astro_dev_toolbar__ metadata injection.
Implement the settings priority chain:
1. defaultSettings (hardcoded 'bottom-center')
2. Config placement (from astro.config.mjs)
3. localStorage (user's persisted choice)

This allows project-level default placement while still
respecting user's UI-driven placement preferences.
Test that:
- Valid placement values are accepted
- Placement is optional (can be omitted)
- Invalid placement values are rejected
Minor version bump per Astro convention for new config options.
Include @Version added and tweak comment copy

Co-authored-by: Sarah Rainsberger <[email protected]>
Co-authored-by: Sarah Rainsberger <[email protected]>
@tony
Copy link
Author

tony commented Jan 16, 2026

@sarah11918 Thank you!

@tony tony force-pushed the feat/devtoolbar-placement-conf branch from 6b3689b to 2cb299e Compare January 16, 2026 18:46
- Add js syntax highlighting to code block
- Fix spacing in comment
- Fix "overriden" → "overridden" typo
@tony tony force-pushed the feat/devtoolbar-placement-conf branch from 2cb299e to bd8c445 Compare January 16, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs pr pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants