Skip to content

Primitives ​

The smallest building blocks: icons, headings, images, labels and layout.

INFO

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

Icon ​

icon svg symbol

Built-in SVG icon. Without a label it is treated as decorative and hidden from screen readers.

php
use Cg\ComponentFramework\Component\Icon\Icon;

Icon::make('check')->size('lg')->label('完成');

Constructor:Icon::make(Closure|string $name)

Options

  • size():xs · sm · md · lg · xl
All methods (2)
  • size(string $size)
  • label(?string $label)

Heading ​

heading title typography

Heading text; the semantic level (h1–h6) and the visual size are set independently.

php
use Cg\ComponentFramework\Component\Heading\Heading;

Heading::make('季度報告')
    ->level(2)
    ->size('xl')
    ->description('2026 Q4 營運摘要');

Constructor:Heading::make(Htmlable|Closure|string $content)

Options

  • size():xs · sm · md · lg · xl · 2xl
All methods (3)
  • level(int $level)
  • size(?string $size)
  • description(?string $description)

Image ​

image media picture

Image with required alt text; supports dimensions, object-fit and eager loading.

php
use Cg\ComponentFramework\Component\Image\Image;

Image::make('/images/cover.jpg', '產品封面')
    ->dimensions(960, 540)
    ->fit('cover');

Constructor:Image::make(Closure|string $source, Closure|string $alt = '')

Options

  • fit():contain · cover · fill · none · scale-down
All methods (3)
  • dimensions(?int $width, ?int $height)
  • fit(string $fit)
  • eager(bool $condition = true)

Badge ​

badge tag label

Small status label for categories, states or counts.

php
use Cg\ComponentFramework\Component\Badge\Badge;

Badge::make('已上線')->color('success')->icon('check');

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

Options

  • color():neutral · primary · success · warning · danger · info
  • size():sm · md · lg
All methods (4)
  • color(string $color)
  • size(string $size)
  • icon(Icon|string|null $icon)
  • rounded(bool $condition = true)

Label ​

label form

Form label; binds to a field id, marks required fields, or can be visually hidden.

php
use Cg\ComponentFramework\Component\Label\Label;

Label::make('電子郵件', 'email')->required();

Constructor:Label::make(Htmlable|Closure|string $content, ?string $for = null)

All methods (3)
  • for(?string $id)
  • required(bool $condition = true)
  • visuallyHidden(bool $condition = true)

Separator ​

separator divider

Divider line with an optional centered label; horizontal or vertical.

php
use Cg\ComponentFramework\Component\Separator\Separator;

Separator::make('或');

Constructor:Separator::make(Closure|string|null $label = null)

Options

  • orientation():horizontal · vertical
All methods (1)
  • orientation(string $orientation)

Stack ​

stack layout

Layout container that arranges children by direction, gap and alignment.

php
use Cg\ComponentFramework\Component\Badge\Badge;
use Cg\ComponentFramework\Component\Stack\Stack;

Stack::make([
    Badge::make('PHP'),
    Badge::make('Laravel')->color('primary'),
])->direction('row')->gap('sm')->wrap();

Constructor:Stack::make(iterable $components = [])

Options

  • direction():row · column
  • gap():none · xs · sm · md · lg · xl
  • align():start · center · end · stretch · baseline
  • justify():start · center · end · between · around · evenly
All methods (7)
  • components(iterable $components)
  • push(Component $component)
  • direction(string $direction)
  • gap(string $gap)
  • align(string $align)
  • justify(string $justify)
  • wrap(bool $condition = true)

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