studio-variable / kirby-edit-button
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
Type:kirby-plugin
pkg:composer/studio-variable/kirby-edit-button
Requires
- php: >=8.2
- getkirby/composer-installer: ^1.2
Requires (Dev)
- getkirby/cms: ^5.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
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 insite.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 theselectoroption. If none is found, thedefaultstyle 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 theclassoption (for example'class' => 'button button--small') or the.kirby-edit-buttonclass.
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.
| Key | Type | Default | Description |
|---|---|---|---|
enabled | bool | true | Turns the button off everywhere when false. |
inject | bool | true | Adds the button before </body> automatically. Set to false to use the edit-button snippet. |
urls | array\|Closure | [] | Rewrites the link of some or all pages, see Panel URLs. |
position | string | 'bottom-right' | bottom-right, bottom-left, top-right or top-left. |
offset | string | '1rem' | Distance from the edges of the screen, any CSS length. |
style | string | 'auto' | auto, default or none, see Style. |
selector | string | 'button, input[type="submit"], …' | CSS selector of the site's buttons the auto style copies from. |
class | string\|null | null | Extra classes added to the button. |
label | string\|null | null | Text of the button. Defaults to the translated text in the Panel language of the user. |
newTab | bool | false | Opens 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