| Install | |
|---|---|
composer require mckenziearts/livewire-markdown-editor |
|
| Latest Version: | v1.1 |
| PHP: | ^8.3 |
GitHub-style Markdown editor for Laravel with Livewire and Alpine.js. This module provides a complete, standalone Markdown editing experience with full dark mode support.
Livewire Markdown editor can be installed via composer from your project root:
composer require mckenziearts/livewire-markdown-editor
Include the Markdown formatting buttons for text inputs Editor into your project:
npm install --save @github/markdown-toolbar-element @github/text-expander-element
Add the module's JavaScript to your main resources/js/app.js:
import '../../vendor/mckenziearts/livewire-markdown-editor/resources/js/markdown-editor.js';
And the CSS file to your main resources/css/app.css:
@import "../../vendor/mckenziearts/livewire-markdown-editor/resources/css/markdown-editor.css";
Then build:
npm run build
The service provider is auto-discovered via Laravel's package discovery.
<livewire:markdown-editor wire:model="content" />
<livewire:markdown-editor
wire:model="comment"
placeholder="Write your comment..."
:rows="15"
:show-toolbar="true"
:show-upload="true"
/>
use Livewire\Component;
class CreatePost extends Component
{
public string $content = '';
public function save()
{
$this->validate([
'content' => 'required|min:10',
]);
// $this->content contains the markdown
}
public function render()
{
return view('livewire.create-post');
}
}
<div>
<livewire:markdown-editor wire:model="content" />
<button wire:click="save">Save</button>
</div>
| Property | Type | Default | Description |
|---|---|---|---|
content |
string | '' |
The markdown content (use with wire:model) |
placeholder |
string | 'Leave a comment...' |
Textarea placeholder text |
class |
string | null |
Textarea custom classes |
rows |
int | 10 |
Number of textarea rows |
showToolbar |
bool | true |
Show/hide the markdown toolbar |
showUpload |
bool | true |
Show/hide the file upload button |
Files are automatically uploaded to storage/app/public/ when selected. Images are inserted as  and other files as [filename](https://github.com/mckenziearts/livewire-markdown-editor/blob/HEAD/url).
Make sure your storage is properly configured:
php artisan storage:link
The editor supports full GitHub Flavored Markdown including:
Dark mode is fully supported and automatically follows your Tailwind CSS dark mode configuration.
php artisan vendor:publish --tag=livewire-markdown-editor-views
Views will be published to resources/views/vendor/livewire-markdown-editor/.
php artisan vendor:publish --tag=livewire-markdown-editor-assets
Distributed under the MIT license. See LICENSE for details.