Search by

studio-variable / kirby-edit-button

isUnknown

Show an edit button on every page of a Kirby site to logged-in editors, styled like the site's own buttons

Package info

forge.studio-variable.com/studio-variable/kirby-edit-button.git

Homepage

Issues

Type:kirby-plugin

pkg:composer/studio-variable/kirby-edit-button

Statistics

Installs: 3

Dependents: 1

Suggesters: 0

v1.0.0 2026-11-16 09:36 UTC

This package is auto-updated.

Last update: 2026-11-16 12:29:53 UTC


README

Show an "Edit page" button on every page of a Kirby site to logged-in editors. It links to the page in the Panel, sits in the bottom right corner and borrows the look of the site's own buttons. Works out of the box, without a snippet or any configuration.

Installation • Usage • Panel URLs • Style • Configuration • Translations

Requirements

  • Kirby 5
  • PHP 8.2+

Installation

Composer (recommended)

composer require studio-variable/kirby-edit-button

Manual installation

Download this repository and copy it to site/plugins/edit-button.

Usage

Nothing to do: once installed, the button is added before </body> of every HTML page, for logged-in users who can access the Panel. Visitors never see it, and the pages cached by Kirby for them never contain it.

The button is hidden when the page is shown inside an iframe (such as the Panel preview) and when printing.

To place it yourself, turn off the automatic injection and output the snippet in your templates:

// site/config/config.php
return [
  'studio-variable.edit-button.inject' => false,
];
<?php snippet('edit-button') ?>
</body>

Panel URLs

By default, each page links to its own view in the Panel, and to the current language on a multilingual site. The urls option rewrites any of them. Keys are page ids or patterns (blog/*), values can be:

  • 'site': the site view, for a home page edited in site.yml;
  • a page id: the Panel view of another page;
  • a URL, absolute or starting with /;
  • a closure receiving the page and returning one of these values, a page, a file or the site;
  • false: no button on that page;
  • null: the default link.
// site/config/config.php
return [
  'studio-variable.edit-button.urls' => [
    'home'      => 'site',
    'blog/*'    => fn ($page) => $page->parent(),
    'thank-you' => false,
    'shop'      => 'https://shop.example.com/admin',
  ],
];

An exact page id wins over a pattern, and patterns are checked in order.

To rewrite every URL with your own logic, set urls to a closure. Return null to keep the default link:

'studio-variable.edit-button.urls' => fn ($page) => match ($page->intendedTemplate()->name()) {
  'home'    => 'site',
  'project' => $page->parent(),
  default   => null,
},

Style

The style option sets the look of the button:

  • 'auto' (default): the button copies the font, colors, border, radius, padding and shadow of the first visible button of the page that has a background or a border. Candidates are found with the selector option. If none is found, the default style is used.
  • 'default': a black button with white text, independent from the site.
  • 'none': only the position is set. Style the button with your own CSS through the class option (for example 'class' => 'button button--small') or the .kirby-edit-button class.

The position is fixed in every style: bottom-right by default, 1rem from the edges.

'studio-variable.edit-button' => [
  'position' => 'top-left',
  'offset'   => '2rem',
  'style'    => 'none',
  'class'    => 'button',
],

Configuration

No option is required. Set them under the studio-variable.edit-button key of site/config/config.php if needed.

KeyTypeDefaultDescription
enabledbooltrueTurns the button off everywhere when false.
injectbooltrueAdds the button before </body> automatically. Set to false to use the edit-button snippet.
urlsarray\|Closure[]Rewrites the link of some or all pages, see Panel URLs.
positionstring'bottom-right'bottom-right, bottom-left, top-right or top-left.
offsetstring'1rem'Distance from the edges of the screen, any CSS length.
stylestring'auto'auto, default or none, see Style.
selectorstring'button, input[type="submit"], …'CSS selector of the site's buttons the auto style copies from.
classstring\|nullnullExtra classes added to the button.
labelstring\|nullnullText of the button. Defaults to the translated text in the Panel language of the user.
newTabboolfalseOpens the Panel in a new tab.

Translations

The label follows the Panel language of the logged-in user. English (Edit page) and French (Éditer la page) ship with the plugin, and other languages fall back to English.

To add a language, register its translation from a plugin of your site:

// site/plugins/translations/index.php
Kirby::plugin('my/translations', [
  'translations' => [
    'de' => [
      'studio-variable.edit-button.label' => 'Seite bearbeiten',
    ],
  ],
]);

License

MIT License © 2026 Studio Variable