Skip to content

Actions ​

Things users click. All share the action methods (color, size, icon, modal toggles, Linker calls).

INFO

Every component also has the common methods (key, visible, class, attributes, view…).

Button ​

button

Button. Submits forms, toggles client state, opens/closes modals, or calls a Linker method.

php
use Cg\ComponentFramework\Component\Button\Button;

Button::make('儲存')
    ->type('submit')
    ->color('primary')
    ->icon('check');

Constructor:Button::make(Htmlable|Closure|string $label)

Options

  • type():button · submit · reset
  • color():neutral · primary · success · warning · danger · info
  • size():sm · md · lg
  • variant():solid · outline · ghost
All methods (3)
  • type(string $type)
  • name(?string $name)
  • value(string|int|float|bool|null $value)

All shared action methods are also available.

ButtonGroup ​

button-group

Groups several buttons or links, optionally attached together.

php
use Cg\ComponentFramework\Component\ButtonGroup\ButtonGroup;
use Cg\ComponentFramework\Component\Button\Button;

ButtonGroup::make([
    Button::make('日'),
    Button::make('週'),
    Button::make('月'),
])->attached()->label('檢視範圍');

Constructor:ButtonGroup::make(iterable $actions = [])

Options

  • orientation():horizontal · vertical
All methods (5)
  • actions(iterable $actions)
  • push(ActionComponent $action)
  • orientation(string $orientation)
  • attached(bool $condition = true)
  • label(?string $label)
dropdown-menu

Dropdown menu that tucks secondary actions behind one button.

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');

Constructor:DropdownMenu::make(Htmlable|Closure|string $label, iterable $actions = [])

Options

  • placement():start · end
  • width():sm · md · lg
  • color():neutral · primary · success · warning · danger · info
  • size():sm · md · lg
  • variant():solid · outline · ghost
All methods (5)
  • actions(iterable $actions)
  • push(ActionComponent $action)
  • placement(string $placement)
  • width(string $width)
  • open(bool $condition = true)

All shared action methods are also available.

link

Link that can look like a button; supports new tab, download and rel.

php
use Cg\ComponentFramework\Component\Link\Link;

Link::make('查看文件', 'https://example.com/docs')
    ->newTab()
    ->icon('chevron-right', 'after');

Constructor:Link::make(Htmlable|Closure|string $label, Closure|string $url = '#')

Options

  • target():_self · _blank · _parent · _top
  • color():neutral · primary · success · warning · danger · info
  • size():sm · md · lg
  • variant():solid · outline · ghost
All methods (4)
  • target(string $target)
  • newTab(bool $condition = true)
  • rel(array|string $relations)
  • download(string|bool $download = true)

All shared action methods are also available.


Generated from source by scripts/wiki-components/generate.php; every example is rendered as part of the build.