Skip to content

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:

php
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:

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 ​

LayerClassPurpose
ComponentCard、Button…A single UI element
SchemaForm、Entries、ActionsA group of components: a form (renders <form>), plain entries, an action bar
PagePageOne page made of schemas
ClusterClusterA 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.

ComponentIDDescription
IconiconBuilt-in SVG icon. Without a label it is treated as decorative and hidden from screen readers.
HeadingheadingHeading text; the semantic level (h1–h6) and the visual size are set independently.
ImageimageImage with required alt text; supports dimensions, object-fit and eager loading.
BadgebadgeSmall status label for categories, states or counts.
LabellabelForm label; binds to a field id, marks required fields, or can be visually hidden.
SeparatorseparatorDivider line with an optional centered label; horizontal or vertical.
StackstackLayout 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).

ComponentIDDescription
ButtonbuttonButton. Submits forms, toggles client state, opens/closes modals, or calls a Linker method.
ButtonGroupbutton-groupGroups several buttons or links, optionally attached together.
DropdownMenudropdown-menuDropdown menu that tucks secondary actions behind one button.
LinklinkLink 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).

ComponentIDDescription
CheckboxcheckboxCheckbox with configurable checked and unchecked values.
ColorPickercolor-pickerColor picker with optional preset swatches.
ComboboxcomboboxSearchable select, suited to long option lists.
DateInputdate-inputNative browser date/time field (date, datetime-local, time, month, week).
DatePickerdate-pickerCustom calendar picker with display format and first day of week.
FileUploadfile-uploadFile upload field with type, size and count limits. Makes its Form multipart automatically.
RadioButtonradio-buttonRadio button. Share one name across the group and give each a different value.
RatingratingStar rating field.
RichTextEditorrich-text-editorWYSIWYG editor; submitted HTML is sanitized on the server.
SearchInputsearch-inputSearch box with optional clear and submit buttons.
SegmentedControlsegmented-controlSegmented control for a few mutually exclusive options shown side by side.
SelectselectNative select. A nested array in the options becomes an option group (optgroup).
SlidersliderRange slider with min/max, step and unit.
TextAreatext-areaMulti-line text field.
TextInputtext-inputSingle-line input supporting HTML types such as email, password and number.
ToggletoggleSwitch; semantically a checkbox, suited to settings that apply immediately.

Data ​

Structured data: tables, charts, tabs, accordions, lists and trees.

ComponentIDDescription
ChartchartChart (amCharts by default): line, bar, pie, Gantt and more. See Advanced → Charts for details.
AccordionaccordionAccordion. single() keeps only one panel open at a time.
ItemListitem-listList of items, each with optional description, meta, icon and link.
TabletableFilament-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.
TabstabsTabs; switching is client-side state and makes no request.
TreeViewtree-viewTree with expandable nodes and single or multiple selection.

Feedback ​

Telling users what happened: alerts, callouts and toasts.

ComponentIDDescription
AlertalertInline alert message; can be dismissible and carry action buttons.
CalloutcalloutHighlighted block for notes, caveats or reminders.
ToasttoastFloating notification that disappears after a few seconds.

Moving between pages: breadcrumbs, menus and pagination.

ComponentIDDescription
BreadcrumbsbreadcrumbsBreadcrumb trail; mark the last item with current().
NavigationnavigationNavigation menu with nested items, badges and horizontal/vertical layout.
PaginationpaginationPagination that takes a Laravel paginator directly.

Status & Progress ​

Progress and loading states.

ComponentIDDescription
ProgressBarprogress-barProgress bar with optional value and unit.
ProgressIndicatorprogress-indicatorCircular progress indicator with a custom range.
SkeletonskeletonLoading placeholder skeleton.
SpinnerspinnerSpinning loading indicator.
StepperstepperStep indicator showing progress through a flow.

Content & Media ​

Content and media: cards, avatars, carousels, files, quotes, audio and video.

ComponentIDDescription
AvataravatarAvatar. Falls back to initials without an image; supports a presence status.
CardcardCard, the most common content container: title, description, body, actions and image.
CarouselcarouselCarousel with autoplay, looping and fade effect.
FilefileFile download card showing name, size, type and modified time.
QuotequoteQuotation with author and source.
SoundsoundAudio player with multiple sources, text tracks and a transcript.
VideovideoVideo player with poster, text tracks and playback options.

Overlays ​

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

ComponentIDDescription
DrawerdrawerSide drawer. openButton() creates the trigger; the drawer itself must also be on the page.
ModalmodalDialog. Opening is client-side state with no request; openButton() creates the trigger.
PopoverpopoverFloating content shown on click; can hold any component.
TooltiptooltipShort hint text shown on hover or focus.

Page Structure ​

Page skeleton: header, footer, hero and field groups.

ComponentIDDescription
FieldSetfield-setField group (fieldset) that puts related fields under one legend, optionally in columns.
FooterfooterPage footer for copyright, links and actions.
HeaderheaderPage header with brand, navigation and actions; can be sticky.
HeroheroHero section: large title, description, media and primary call to action.

Accessibility ​

Accessibility helpers.

ComponentIDDescription
SkipLinkskip-link"Skip to main content" link, visible only on keyboard focus.
VisuallyHiddenvisually-hiddenText 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)
bash
php artisan component:list
php artisan component:list --json

To 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.