Content & Media
Content and media: cards, avatars, carousels, files, quotes, audio and video.
INFO
Every component also has the common methods (key, visible, class, attributes, view…).
Avatar
avatarAvatar. Falls back to initials without an image; supports a presence status.
use Cg\ComponentFramework\Component\Avatar\Avatar;
Avatar::make('王小明')
->size('lg')
->status('online');Constructor:Avatar::make(Closure|string $name, Closure|string|null $source = null)
Options
shape():circle·rounded·squaresize():xs·sm·md·lg·xl·2xlstatus():online·offline·away·busy
All methods (7)
source(Closure|string|null $source)initials(Closure|string|null $initials)shape(string $shape)size(string $size)status(?string $status)eager(bool $condition = true)decorative(bool $condition = true)
Card
cardCard, the most common content container: title, description, body, actions and image.
use Cg\ComponentFramework\Component\Badge\Badge;
use Cg\ComponentFramework\Component\Button\Button;
use Cg\ComponentFramework\Component\Card\Card;
Card::make('方案升級')
->description('解鎖進階報表與團隊協作')
->color('primary')
->body(Badge::make('NT$ 299 / 月'))
->actions([
Button::make('立即升級')->color('primary'),
]);Constructor:Card::make(Htmlable|Closure|string|null $title = null)
Options
color():default·primary·success·warning·danger·info
All methods (11)
title(Htmlable|Closure|string|null $title)description(Htmlable|Closure|string|null $description)url(?string $url)image(?string $image)color(string $color)headingLevel(int $level)body(mixed $content)schema(Schema $schema)actions(Actions|Traversable|array $actions)collapsible(bool $condition = true, bool $collapsed = false)serverCollapsible(bool $collapsed = false)
Carousel
carouselCarousel with autoplay, looping and fade effect.
use Cg\ComponentFramework\Component\Carousel\Carousel;
use Cg\ComponentFramework\Component\Carousel\CarouselSlide;
use Cg\ComponentFramework\Component\Image\Image;
Carousel::make([
CarouselSlide::make('spring', Image::make('/images/spring.jpg', '春季新品'))
->caption('春季新品'),
CarouselSlide::make('summer', Image::make('/images/summer.jpg', '夏日特賣'))
->caption('夏日特賣'),
])->aspect('video')->autoplay(5)->loop();Constructor:Carousel::make(iterable $slides = [])
Options
aspect():auto·video·square·portraiteffect():slide·fade
All methods (12)
slides(iterable $slides)push(CarouselSlide $slide)label(string $label)active(?string $key)stateKey(string $key)aspect(string $aspect)effect(string $effect)controls(bool $condition = true)indicators(bool $condition = true)loop(bool $condition = true)autoplay(int $seconds = 5)withoutAutoplay()
File
file downloadFile download card showing name, size, type and modified time.
use Cg\ComponentFramework\Component\File\File;
File::make('2026 年報.pdf', '/files/annual-report.pdf')
->sizeBytes(2_400_000)
->mimeType('application/pdf')
->download();Constructor:File::make(Htmlable|Closure|string $name, Closure|string $url)
Options
target():_self·_blankvariant():default·compact
All methods (9)
description(Htmlable|Closure|string|null $description)sizeBytes(Closure|int|null $bytes)mimeType(Closure|string|null $mimeType)modifiedAt(DateTimeInterface|Closure|null $modifiedAt)icon(Icon|string|null $icon)download(string|bool $filename = true)newTab(bool $condition = true)variant(string $variant)disabled(Closure|bool $condition = true)
Quote
quoteQuotation with author and source.
use Cg\ComponentFramework\Component\Quote\Quote;
Quote::make('簡單是可靠的先決條件。')
->author('Edsger W. Dijkstra')
->align('center');Constructor:Quote::make(Htmlable|Closure|string $content)
Options
align():start·center·endsize():sm·md·lg
All methods (4)
author(Htmlable|Closure|string|null $author)source(Htmlable|Closure|string|null $title, Closure|string|null $url = null)align(string $alignment)size(string $size)
Sound
sound audioAudio player with multiple sources, text tracks and a transcript.
use Cg\ComponentFramework\Component\Sound\Sound;
Sound::make('/audio/intro.mp3', '節目片頭')
->preload('metadata');Constructor:Sound::make(Closure|string|null $source, Closure|string $label = '音訊')
Options
preload():none·metadata·autocrossOrigin():anonymous·use-credentials
All methods (11)
source(Closure|string $source, ?string $type = null)sources(iterable $sources)addSource(SoundSource $source)tracks(iterable $tracks)addTrack(SoundTrack $track)transcript(mixed $content, string $label = '顯示逐字稿', bool $open = false)showLabel(bool $condition = true)muted(bool $condition = true)loop(bool $condition = true)preload(string $preload)crossOrigin(?string $crossOrigin)
Video
video mediaVideo player with poster, text tracks and playback options.
use Cg\ComponentFramework\Component\Video\Video;
Video::make('/video/demo.mp4', '產品示範')
->poster('/images/demo-poster.jpg')
->dimensions(1280, 720)
->playsInline();Constructor:Video::make(Closure|string|null $source, Closure|string $label = '影片')
Options
preload():none·metadata·autocrossOrigin():anonymous·use-credentials
All methods (14)
source(Closure|string $source, ?string $type = null)sources(iterable $sources)addSource(VideoSource $source)tracks(iterable $tracks)addTrack(VideoTrack $track)poster(Closure|string|null $poster)controls(bool $condition = true)autoplay(bool $condition = true)muted(bool $condition = true)loop(bool $condition = true)playsInline(bool $condition = true)preload(string $preload)crossOrigin(?string $crossOrigin)dimensions(?int $width, ?int $height)
Generated from source by scripts/wiki-components/generate.php; every example is rendered as part of the build.