動作
使用者按下去會發生事情的元件。全部共用「動作元件」的方法(顏色、大小、圖示、開關 Modal、呼叫 Linker)。
INFO
所有元件都能用共用方法(key、visible、class、attributes、view…)。
Button
button按鈕。可送出表單、切換前端狀態、開關 Modal,或呼叫 Linker 方法。
php
use Cg\ComponentFramework\Component\Button\Button;
Button::make('儲存')
->type('submit')
->color('primary')
->icon('check');建構:Button::make(Htmlable|Closure|string $label)
可用選項
type():button·submit·resetcolor():neutral·primary·success·warning·danger·infosize():sm·md·lgvariant():solid·outline·ghost
方法一覽 (3)
type(string $type)name(?string $name)value(string|int|float|bool|null $value)
另外可用所有動作元件共用方法。
ButtonGroup
button-group把多個按鈕或連結組成一組,可相連顯示。
php
use Cg\ComponentFramework\Component\ButtonGroup\ButtonGroup;
use Cg\ComponentFramework\Component\Button\Button;
ButtonGroup::make([
Button::make('日'),
Button::make('週'),
Button::make('月'),
])->attached()->label('檢視範圍');建構:ButtonGroup::make(iterable $actions = [])
可用選項
orientation():horizontal·vertical
方法一覽 (5)
actions(iterable $actions)push(ActionComponent $action)orientation(string $orientation)attached(bool $condition = true)label(?string $label)
DropdownMenu
dropdown-menu下拉選單,把次要動作收進一個按鈕裡。
php
use Cg\ComponentFramework\Component\Button\Button;
use Cg\ComponentFramework\Component\DropdownMenu\DropdownMenu;
use Cg\ComponentFramework\Component\Link\Link;
DropdownMenu::make('更多動作', [
Link::make('編輯', '/posts/1/edit'),
Button::make('刪除')->color('danger'),
])->placement('end')->variant('outline');建構:DropdownMenu::make(Htmlable|Closure|string $label, iterable $actions = [])
可用選項
placement():start·endwidth():sm·md·lgcolor():neutral·primary·success·warning·danger·infosize():sm·md·lgvariant():solid·outline·ghost
方法一覽 (5)
actions(iterable $actions)push(ActionComponent $action)placement(string $placement)width(string $width)open(bool $condition = true)
另外可用所有動作元件共用方法。
Link
link連結,外觀可以和按鈕一致;支援新分頁、下載與 rel。
php
use Cg\ComponentFramework\Component\Link\Link;
Link::make('查看文件', 'https://example.com/docs')
->newTab()
->icon('chevron-right', 'after');建構:Link::make(Htmlable|Closure|string $label, Closure|string $url = '#')
可用選項
target():_self·_blank·_parent·_topcolor():neutral·primary·success·warning·danger·infosize():sm·md·lgvariant():solid·outline·ghost
方法一覽 (4)
target(string $target)newTab(bool $condition = true)rel(array|string $relations)download(string|bool $download = true)
另外可用所有動作元件共用方法。
這一頁由 scripts/wiki-components/generate.php 依原始碼產生,範例都經過實際渲染驗證。