Skip to content

feat: allow overriding default English labels in admin bar#16615

Open
Zayooo00 wants to merge 1 commit into
payloadcms:mainfrom
Zayooo00:feat/admin-bar-labels
Open

feat: allow overriding default English labels in admin bar#16615
Zayooo00 wants to merge 1 commit into
payloadcms:mainfrom
Zayooo00:feat/admin-bar-labels

Conversation

@Zayooo00
Copy link
Copy Markdown

The admin bar currently renders five hardcoded English strings inside the bar (Edit <singular>, New <singular>, Exit preview mode, Logout, Profile). There is no API for swapping them out short of forking the package, which makes the bar awkward for any site that runs in another language or wants different copy.

This PR adds an optional labels prop to PayloadAdminBar that lets consumers override each of those strings individually:

<PayloadAdminBar
  cmsURL="https://cms.website.com"
  collectionSlug="pages"
  collectionLabels={{ singular: 'strona', plural: 'strony' }}
  id="12345"
  labels={{
    edit: ({ singular }) => `Edytuj ${singular ?? 'stronę'}`,
    create: ({ singular }) => `Nowa ${singular ?? 'strona'}`,
    exitPreview: 'Wyjdź z podglądu',
    logout: 'Wyloguj',
    profile: 'Profil',
  }}
/>

Shape

labels?: {
  edit?: ((args: { singular?: string }) => string) | string
  create?: ((args: { singular?: string }) => string) | string
  exitPreview?: string
  logout?: string
  profile?: string
}
  • edit and create accept either a plain string or a function. The function form receives the resolved collectionLabels.singular so the consumer can localize while still pulling the collection name into the label.
  • Every entry is optional. Omitted entries fall back to the existing English defaults.

Backwards compatibility

No behavior change for existing consumers. All five fallbacks match the strings that were hardcoded before.

Notes

  • README updated with a Customizing labels section and a Polish usage example.
  • No new dependencies.
  • Tested locally against this repo's pnpm exec tsc --noEmit.

If you'd prefer a different API shape (e.g. a flat editLabel / createLabel rather than a grouped labels object), happy to revise.

@Zayooo00 Zayooo00 changed the title feat(admin-bar): allow overriding default English labels feat: allow overriding default English labels in admin bar May 14, 2026
Adds an optional `labels` prop to `PayloadAdminBar` that lets consumers
swap any of the hardcoded English strings rendered inside the bar:

- `edit`: text on the Edit link (default `Edit <singular>` / `Edit page`)
- `create`: text on the Create link (default `New <singular>` / `New page`)
- `exitPreview`: text on the preview-exit button (default `Exit preview mode`)
- `logout`: text on the Logout link (default `Logout`)
- `profile`: fallback shown when the user has no email (default `Profile`)

`edit` and `create` accept either a string or a function
`(args: { singular?: string }) => string`, so consumers using a localized
`collectionLabels.singular` can interpolate it into the translated label.
Defaults are unchanged, so existing consumers see no behavior change.

Adds a Customizing labels section to the README with a Polish example.
@Zayooo00 Zayooo00 force-pushed the feat/admin-bar-labels branch from 796df50 to 9941097 Compare May 14, 2026 12:08
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.

1 participant