Skip to content

Navigation ​

Moving between pages: breadcrumbs, menus and pagination.

INFO

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

breadcrumbs

Breadcrumb trail; mark the last item with current().

php
use Cg\ComponentFramework\Component\Breadcrumbs\BreadcrumbItem;
use Cg\ComponentFramework\Component\Breadcrumbs\Breadcrumbs;

Breadcrumbs::make([
    BreadcrumbItem::make('home', '首頁')->url('/'),
    BreadcrumbItem::make('orders', '訂單')->url('/orders'),
    BreadcrumbItem::make('detail', '#1024')->current(),
]);

Constructor:Breadcrumbs::make(iterable $items = [])

All methods (4)
  • items(iterable $items)
  • push(BreadcrumbItem $item)
  • label(string $label)
  • separator(Htmlable|string $separator)
navigation menu

Navigation menu with nested items, badges and horizontal/vertical layout.

php
use Cg\ComponentFramework\Component\Navigation\Navigation;
use Cg\ComponentFramework\Component\Navigation\NavigationItem;

Navigation::make([
    NavigationItem::make('dashboard', '儀表板')->url('/dashboard')->current(),
    NavigationItem::make('settings', '設定')->children([
        NavigationItem::make('profile', '個人資料')->url('/settings/profile'),
        NavigationItem::make('billing', '帳單')->url('/settings/billing'),
    ]),
])->orientation('vertical');

Constructor:Navigation::make(iterable $items = [])

Options

  • orientation():horizontal · vertical
All methods (5)
  • items(iterable $items)
  • push(NavigationItem $item)
  • label(string $label)
  • orientation(string $orientation)
  • single(bool $condition = true)

Pagination ​

pagination pager

Pagination that takes a Laravel paginator directly.

php
use App\Models\User;
use Cg\ComponentFramework\Component\Pagination\Pagination;

Pagination::make(User::query()->paginate(15))
    ->onEachSide(1)
    ->showSummary();

Constructor:Pagination::make(Paginator|CursorPaginator|Closure $paginator)

All methods (6)
  • onEachSide(int $pages)
  • label(string $label)
  • showSummary(bool $condition = true)
  • hideWhenSinglePage(bool $condition = true)
  • renderPagesWith(string $controller, string $target, string $method = 'components', array $params = [], array $extra = [])
  • linkerPaginate(string $method, array $extra = [])

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