novadaemon / filament-pretty-json
Read-only field to show pretty json in your filamentphp forms
Installs: 26 984
Dependents: 0
Suggesters: 0
Security: 0
Stars: 17
Watchers: 1
Forks: 4
Open Issues: 2
Language:JavaScript
Requires
- php: ^8.1|^8.2
- filament/filament: ^3.0
- filament/forms: ^3.0
- illuminate/contracts: ^10.0|^11.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9|^8.1
- phpstan/extension-installer: ^1.1
README
Read-only field to show pretty json in your filamentphp forms.
Installation
You can install the package via composer:
composer require novadaemon/filament-pretty-json
This package supports Laravel 9, Laravel 10 and Laravel 11.
Usage
Simply use the component as you'd use any other Filament field. It's especially perfect for the resource view page where it blends right in.
use Novadaemon\FilamentPrettyJson\PrettyJson; class FileResource extends Resource { public static function form(Form $form): Form { return $form ->schema([ PrettyJson::make('json') ]); } }
The value of the field can be an array or a json string
/** * @var string[] */ protected $casts = [ 'json' => 'array', ];
Customize
Optionally, you can publish the views using
php artisan vendor:publish --tag="filament-pretty-json-views"
Also, you can overwrite the css rules in your stylesheets.
pre.prettyjson { color: black; background-color: ghostwhite; border: 1px solid silver; padding: 10px 20px; border-radius: 4px; overflow: auto; } :is(.dark) pre.prettyjson { opacity: .7; --tw-bg-opacity: 1; --tw-border-opacity: 1; background-color: rgb(55 65 81/var(--tw-bg-opacity)); border: 1px solid rgb(75 85 99/var(--tw-border-opacity)); color: rgb(209 213 219/var(--tw-text-opacity)); } :is(.dark) pre.prettyjson span.json-key { color: red !important; } :is(.dark) pre.prettyjson span.json-string { color: aquamarine !important; } :is(.dark) pre.prettyjson span.json-value { color: deepskyblue !important; }
Contributing
Contributing is pretty chill and is highly appreciated! Just send a PR and/or create an issue!
Credits
License
The MIT License (MIT). Please see License File for more information.