Skip to content

Overlays ​

Interfaces that float above the page: modals, drawers, popovers and tooltips.

INFO

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

Drawer ​

drawer

Side drawer. openButton() creates the trigger; the drawer itself must also be on the page.

php
use Cg\ComponentFramework\Component\Button\Button;
use Cg\ComponentFramework\Component\Drawer\Drawer;
use Cg\ComponentFramework\Component\Select\Select;
use Cg\ComponentFramework\Component\Stack\Stack;

$drawer = Drawer::make('filters', '篩選條件', 'right')
    ->body(Select::make('status', '狀態')->options(['open' => '進行中', 'done' => '已完成']))
    ->footer([
        Button::make('套用')->color('primary')->closesModal('filters'),
    ]);

Stack::make([$drawer->openButton('開啟篩選'), $drawer]);

Constructor:Drawer::make(string $name, Htmlable|Closure|string|null $title = null, string $side = 'right')

All methods (10)
  • side(string $side)
  • variant(string $variant)
  • body(mixed $body)
  • footer(Actions|Traversable|array $actions)
  • description(Closure|string|null $description)
  • label(?string $label)
  • static(bool $condition = true)
  • autofocus(?string $selector)
  • closeButton(bool $condition = true)
  • openButton(Htmlable|Closure|string $label)
modal dialog

Dialog. Opening is client-side state with no request; openButton() creates the trigger.

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

$modal = Modal::make('confirm-delete', '確定要刪除?')
    ->description('刪除後無法復原。')
    ->footer([
        Button::make('取消')->variant('ghost')->closesModal('confirm-delete'),
        Button::make('刪除')->color('danger'),
    ]);

Stack::make([$modal->openButton('刪除'), $modal]);

Constructor:Modal::make(string $name, Htmlable|Closure|string|null $title = null)

All methods (9)
  • body(mixed $body)
  • footer(Actions|Traversable|array $actions)
  • description(Closure|string|null $description)
  • label(?string $label)
  • variant(string $variant)
  • static(bool $condition = true)
  • autofocus(?string $selector)
  • closeButton(bool $condition = true)
  • openButton(Htmlable|Closure|string $label)

Popover ​

popover

Floating content shown on click; can hold any component.

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

Popover::make(
    Button::make('說明')->variant('ghost'),
    '這個欄位會顯示在公開頁面。',
)->title('提示')->placement('bottom');

Constructor:Popover::make(Component $trigger, mixed $content = null)

Options

  • placement():top · right · bottom · left
  • align():start · center · end
  • width():sm · md · lg
All methods (10)
  • id(string $id)
  • content(mixed $content)
  • title(Htmlable|Closure|string|null $title)
  • label(?string $label)
  • placement(string $placement, string $align = 'start')
  • width(string $width)
  • offset(int $pixels)
  • open(bool $condition = true)
  • dismissible(bool $condition = true, string $label = '關閉浮動內容')
  • stateKey(string $key)

Tooltip ​

tooltip

Short hint text shown on hover or focus.

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

Tooltip::make(
    Button::make('複製')->icon('file'),
    '複製分享連結',
)->placement('top');

Constructor:Tooltip::make(Component $trigger, Closure|string $content)

Options

  • placement():top · right · bottom · left
All methods (4)
  • id(string $id)
  • placement(string $placement)
  • delay(int $milliseconds)
  • offset(int $pixels)

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