Skip to content

Data Display Components ​

Table ​

php
use Lartrix\Schema\Components\NaiveUI\Table;

Table::make()
    ->props([
        'data' => '{{ list }}',
        'columns' => [
            ['title' => 'ID', 'key' => 'id'],
            ['title' => 'Name', 'key' => 'name'],
            ['title' => 'Status', 'key' => 'status'],
        ],
    ]);

With Action Column ​

php
Table::make()
    ->props([
        'data' => '{{ list }}',
        'columns' => [
            ['title' => 'ID', 'key' => 'id'],
            ['title' => 'Name', 'key' => 'name'],
            [
                'title' => 'Actions',
                'key' => 'actions',
                'render' => [
                    Button::make('Edit')->type('primary'),
                    Button::make('Delete')->type('error'),
                ],
            ],
        ],
    ]);

Props ​

PropertyTypeDescription
dataarrayTable data
columnsarrayColumn configuration
borderedbooleanShow border
stripedbooleanStriped rows
singleLinebooleanSingle line display
sizestringSize: small, medium, large
loadingbooleanLoading state
paginationobject/booleanPagination config
scrollXnumberHorizontal scroll width
maxHeightnumberMax height

List ​

php
use Lartrix\Schema\Components\NaiveUI\ListC;

ListC::make()
    ->props([
        'data' => '{{ list }}',
    ]);

Tree ​

php
use Lartrix\Schema\Components\NaiveUI\Tree;

Tree::make()
    ->props([
        'data' => [
            [
                'label' => 'Root',
                'key' => 'root',
                'children' => [
                    ['label' => 'Child 1', 'key' => 'child1'],
                    ['label' => 'Child 2', 'key' => 'child2'],
                ],
            ],
        ],
    ]);

Props ​

PropertyTypeDescription
dataarrayTree data
checkablebooleanShow checkbox
selectablebooleanSelectable
expandedKeysarrayExpanded nodes
checkedKeysarrayChecked nodes
defaultExpandAllbooleanExpand all by default
keyFieldstringNode key field, default 'key'
labelFieldstringNode label field, default 'label'
childrenFieldstringChildren field, default 'children'

TreeSelect ​

php
use Lartrix\Schema\Components\NaiveUI\TreeSelect;

TreeSelect::make()
    ->props([
        'options' => [...],
    ]);

Props ​

PropertyTypeDescription
optionsarrayOptions data
multiplebooleanMultiple selection
checkablebooleanShow checkbox
cascadebooleanCascade selection
checkStrategystringCheck strategy: all, parent, child
placeholderstringPlaceholder
clearablebooleanClearable
filterablebooleanSearchable

Badge ​

php
use Lartrix\Schema\Components\NaiveUI\Badge;

Badge::make()
    ->props(['value' => 5])
    ->children([
        Button::make('Messages'),
    ]);

Tag ​

php
use Lartrix\Schema\Components\NaiveUI\Tag;

Tag::make()->type('success')->children(['Success']);
Tag::make()->type('warning')->children(['Warning']);
Tag::make()->type('error')->children(['Error']);

Avatar ​

php
use Lartrix\Schema\Components\NaiveUI\Avatar;

Avatar::make()
    ->props([
        'src' => '{{ user.avatar }}',
        'fallbackSrc' => '/default-avatar.png',
    ]);

Progress ​

php
use Lartrix\Schema\Components\NaiveUI\Progress;

Progress::make()
    ->props([
        'percentage' => 50,
        'status' => 'success',
    ]);

基于 MIT 许可发布