Components
The framework ships 61 components, composed in PHP and rendered to HTML on the server. Every component implements Htmlable, so you can echo it in Blade or nest it inside a Schema, Page or Cluster.
In thirty seconds
Build nodes in a controller or page class:
use Cg\ComponentFramework\Component\Button\Button;
use Cg\ComponentFramework\Component\Card\Card;
use Cg\ComponentFramework\Component\TextInput\TextInput;
use Cg\ComponentFramework\Page\Page;
use Cg\ComponentFramework\Schema\Form;
$page = Page::make('Contact us')
->key('contact')
->schemas([
Form::make([
Card::make('Leave a message')->body([
TextInput::make('email', 'Email')->type('email')->required(),
Button::make('Send')->type('submit')->color('primary'),
]),
])->action('/contact'),
]);
return view('page', ['page' => $page]);Echo it in Blade:
{{ $page }}Namespace
Examples use the package namespace Cg\ComponentFramework\ (starter project, Composer install). Inside this repository's source the namespace is App\, e.g. App\Component\Card\Card.
How the pieces fit
| Layer | Class | Purpose |
|---|---|---|
| Component | Card、Button… | A single UI element |
| Schema | Form、Entries、Actions | A group of components: a form (renders <form>), plain entries, an action bar |
| Page | Page | One page made of schemas |
| Cluster | Cluster | A group of pages (e.g. several views of one feature) |
Strings are HTML-escaped by default; only an HtmlString or another component is treated as trusted HTML.
All components
Primitives
The smallest building blocks: icons, headings, images, labels and layout.
| Component | ID | Description |
|---|---|---|
| Icon | icon | Built-in SVG icon. Without a label it is treated as decorative and hidden from screen readers. |
| Heading | heading | Heading text; the semantic level (h1–h6) and the visual size are set independently. |
| Image | image | Image with required alt text; supports dimensions, object-fit and eager loading. |
| Badge | badge | Small status label for categories, states or counts. |
| Label | label | Form label; binds to a field id, marks required fields, or can be visually hidden. |
| Separator | separator | Divider line with an optional centered label; horizontal or vertical. |
| Stack | stack | Layout container that arranges children by direction, gap and alignment. |
Actions
Things users click. All share the action methods (color, size, icon, modal toggles, Linker calls).
| Component | ID | Description |
|---|---|---|
| Button | button | Button. Submits forms, toggles client state, opens/closes modals, or calls a Linker method. |
| ButtonGroup | button-group | Groups several buttons or links, optionally attached together. |
| DropdownMenu | dropdown-menu | Dropdown menu that tucks secondary actions behind one button. |
| Link | link | Link that can look like a button; supports new tab, download and rel. |
Form Fields
Form inputs. All share the field methods (label, helper text, errors, required, disabled, client state).
| Component | ID | Description |
|---|---|---|
| Checkbox | checkbox | Checkbox with configurable checked and unchecked values. |
| ColorPicker | color-picker | Color picker with optional preset swatches. |
| Combobox | combobox | Searchable select, suited to long option lists. |
| DateInput | date-input | Native browser date/time field (date, datetime-local, time, month, week). |
| DatePicker | date-picker | Custom calendar picker with display format and first day of week. |
| FileUpload | file-upload | File upload field with type, size and count limits. Makes its Form multipart automatically. |
| RadioButton | radio-button | Radio button. Share one name across the group and give each a different value. |
| Rating | rating | Star rating field. |
| RichTextEditor | rich-text-editor | WYSIWYG editor; submitted HTML is sanitized on the server. |
| SearchInput | search-input | Search box with optional clear and submit buttons. |
| SegmentedControl | segmented-control | Segmented control for a few mutually exclusive options shown side by side. |
| Select | select | Native select. A nested array in the options becomes an option group (optgroup). |
| Slider | slider | Range slider with min/max, step and unit. |
| TextArea | text-area | Multi-line text field. |
| TextInput | text-input | Single-line input supporting HTML types such as email, password and number. |
| Toggle | toggle | Switch; semantically a checkbox, suited to settings that apply immediately. |
Data
Structured data: tables, charts, tabs, accordions, lists and trees.
| Component | ID | Description |
|---|---|---|
| Chart | chart | Chart (amCharts by default): line, bar, pie, Gantt and more. See Advanced → Charts for details. |
| Accordion | accordion | Accordion. single() keeps only one panel open at a time. |
| ItemList | item-list | List of items, each with optional description, meta, icon and link. |
| Table | table | Filament-style data table: feed it Eloquent, Query Builder, a Collection, an array or a Paginator; supports search, filters, sorting, grouping, summaries, Excel-like formulas, column groups, toggleable/collapsible columns and stacking on narrow screens. See Advanced: Tables. |
| Tabs | tabs | Tabs; switching is client-side state and makes no request. |
| TreeView | tree-view | Tree with expandable nodes and single or multiple selection. |
Feedback
Telling users what happened: alerts, callouts and toasts.
| Component | ID | Description |
|---|---|---|
| Alert | alert | Inline alert message; can be dismissible and carry action buttons. |
| Callout | callout | Highlighted block for notes, caveats or reminders. |
| Toast | toast | Floating notification that disappears after a few seconds. |
Navigation
Moving between pages: breadcrumbs, menus and pagination.
| Component | ID | Description |
|---|---|---|
| Breadcrumbs | breadcrumbs | Breadcrumb trail; mark the last item with current(). |
| Navigation | navigation | Navigation menu with nested items, badges and horizontal/vertical layout. |
| Pagination | pagination | Pagination that takes a Laravel paginator directly. |
Status & Progress
Progress and loading states.
| Component | ID | Description |
|---|---|---|
| ProgressBar | progress-bar | Progress bar with optional value and unit. |
| ProgressIndicator | progress-indicator | Circular progress indicator with a custom range. |
| Skeleton | skeleton | Loading placeholder skeleton. |
| Spinner | spinner | Spinning loading indicator. |
| Stepper | stepper | Step indicator showing progress through a flow. |
Content & Media
Content and media: cards, avatars, carousels, files, quotes, audio and video.
| Component | ID | Description |
|---|---|---|
| Avatar | avatar | Avatar. Falls back to initials without an image; supports a presence status. |
| Card | card | Card, the most common content container: title, description, body, actions and image. |
| Carousel | carousel | Carousel with autoplay, looping and fade effect. |
| File | file | File download card showing name, size, type and modified time. |
| Quote | quote | Quotation with author and source. |
| Sound | sound | Audio player with multiple sources, text tracks and a transcript. |
| Video | video | Video player with poster, text tracks and playback options. |
Overlays
Interfaces that float above the page: modals, drawers, popovers and tooltips.
| Component | ID | Description |
|---|---|---|
| Drawer | drawer | Side drawer. openButton() creates the trigger; the drawer itself must also be on the page. |
| Modal | modal | Dialog. Opening is client-side state with no request; openButton() creates the trigger. |
| Popover | popover | Floating content shown on click; can hold any component. |
| Tooltip | tooltip | Short hint text shown on hover or focus. |
Page Structure
Page skeleton: header, footer, hero and field groups.
| Component | ID | Description |
|---|---|---|
| FieldSet | field-set | Field group (fieldset) that puts related fields under one legend, optionally in columns. |
| Footer | footer | Page footer for copyright, links and actions. |
| Header | header | Page header with brand, navigation and actions; can be sticky. |
| Hero | hero | Hero section: large title, description, media and primary call to action. |
Accessibility
Accessibility helpers.
| Component | ID | Description |
|---|---|---|
| SkipLink | skip-link | "Skip to main content" link, visible only on keyboard focus. |
| VisuallyHidden | visually-hidden | Text hidden on screen but read by screen readers. |
Common methods
key(?string $key = null):Stable identifier; must be unique among siblings. Modals, tabs and similar use it for client state.visible(Closure|bool $condition = true):Conditional rendering; accepts a Closure.hidden(Closure|bool $condition = true):The inverse of visible.class(array|string $classes):Adds CSS classes to the root element.attributes(array $attributes):Sets HTML attributes on the root element.view(string $view):Swaps in your own Blade view (overrides one component's HTML).renderObject(string $name, array $allow = ['render']):Marks the node as a renderBlade object and grants capabilities (e.g. state:read).linker(string $alias, array $params = []):Binds the node to a Linker component.
Other methods
attribute(string $name, mixed $value = true)renderAuto(string $controller, string $method = 'components', array $params = [], array $extra = [])renderBlade(string $controller, string $method = 'components', array $params = [], ?string $target = null, array $extra = [])stateless(string $alias)
Shared action methods
Applies to Button, Link and DropdownMenu.
color(string $color):Color: neutral · primary · success · warning · danger · info.size(string $size):Size: sm · md · lg.variant(string $variant):Style: solid · outline · ghost.icon(Icon|Closure|string|null $icon, string $position = 'before'):Icon; position is before or after.iconOnly(?string $accessibleLabel = null):Icon only; the label goes to screen readers.disabled(Closure|bool $condition = true):Disables the action.opensModal(string $key):Opens the modal/drawer with that key.closesModal(string $key):Closes the modal/drawer with that key.stateSet(string $key, mixed $value):Writes a client state value on click.stateToggle(string $key):Toggles a boolean client state value on click.linkerCall(string $method, array|string|null $args = null, array $extra = [], array|string|null $confirm = null, string $on = 'click', ?int $debounce = null, bool $prevent = true):Calls a Linker method on click (args, confirmation, debounce).
Shared field methods
Applies to every component in Form Fields. The first argument, name, is the submitted field name.
label(Htmlable|Closure|string|null $label):Field label.helperText(Closure|string|null $text):Helper text below the field.error(Closure|string|null $message, string $bag = 'default'):Error message; Laravel validation errors are picked up automatically.required(Closure|bool $condition = true):Required.disabled(Closure|bool $condition = true):Disabled (not submitted).readOnly(Closure|bool $condition = true):Read-only (still submitted).id(?string $id):Custom id; derived from name by default.state(string $key):Binds the value to a client state key (renderBlade state).live(string $method, array|string|null $args = null, ?int $debounce = 300, array $extra = []):Calls a Linker method when the value changes (300 ms debounce by default).
Other methods
errorBag(string $bag)linkerCall(string $method, array|string|null $args = null, array $extra = [], array|string|null $confirm = null, string $on = 'click', ?int $debounce = null, bool $prevent = true)
Related commands
php artisan component:list
php artisan component:list --jsonTo add your own components or override built-in ones, see "Overriding the framework" in the starter README.
Generated from source by scripts/wiki-components/generate.php; every example is rendered as part of the build.