Fields

Code

Extends Textarea *has the same features

The Code field is an extension of Textarea with a visual appearance of the edited code.

use MoonShine\Fields\Code;
 
//...
 
public function fields(): array
{
return [
Code::make('Code')
];
}
//...

code code_dark

Language

By default, PHP styling is used, but using the language() method You can change the design for another programming language.

language(string $language)

Supported languages: HTML , XML , CSS , PHP , JavaScript and many others.

use MoonShine\Fields\Code;
 
//...
 
public function fields(): array
{
return [
Code::make('Code')
->language('js')
];
}
//...

Line numbering

The lineNumbers() method allows you to display line numbering.

lineNumbers()
use MoonShine\Fields\Code;
 
//...
 
public function fields(): array
{
return [
Code::make('Code')
->lineNumbers()
];
}