beartropy/ui
Beartropy UI is a small Laravel UI package providing ready-made components and helpers to speed up building admin and front-end screens. Drop in common layouts, forms, and UI utilities to get a consistent look fast with minimal setup.
<x-bt-table />
Table → extends BeartropyComponenttable.blade.phpresources/views/presets/table.php (color classes for thead, rows, pagination)resources/views/presets/sizes.phpresources/js/modules/table.js exports beartropyTable(cfg), registered as Alpine.data('beartropyTable') and window.$beartropy.beartropyTable in resources/js/index.js$beartropy.beartropyTable({...}) containing all server-side values; JS handles all runtime logic including sorting, filtering, pagination| Prop | PHP Type | Default | Blade Attribute |
|---|---|---|---|
| items | array|Collection |
[] |
:items="$data" |
| columns | array |
auto-detected | :columns="$cols" |
| perPage | int |
10 |
:per-page="25" |
| sortable | bool |
true |
:sortable="false" |
| searchable | bool |
true |
:searchable="false" |
| paginated | bool |
true |
:paginated="false" |
| striped | bool |
false |
:striped="true" |
| allowHtml | bool |
false |
:allow-html="true" |
| color | ?string |
null |
color="beartropy" |
| Slot | Purpose | Default |
|---|---|---|
actions |
Content rendered top-right of the table, opposite the search input (e.g., buttons, filters) | (empty) |
primary, beartropy, red, blue, green, yellow, purple, pink, gray, orange, amber, lime, emerald, teal, cyan, sky, indigo, violet, rose, fuchsia, slate, stone, zinc, neutral
The constructor calls normalizeData() which handles:
->all()toArray(): each item mapped to arrayWhen no columns prop is provided, columns are auto-detected from the first item's keys.
Columns can be:
['id', 'name', 'email'] — used as both key and label['username' => 'User', 'role' => 'Role'] — key = data key, value = display labelresources/js/modules/table.js)The beartropyTable(cfg) function receives a config object from Blade and returns an Alpine data object.
{
data, // array — normalized items from PHP
columns, // array|object — column keys or key→label map
perPage, // int
sortable, // bool
searchable, // bool
paginated, // bool
}
filtered — applies search filter across all columnssorted — sorts filtered results by sortBy column (numeric-aware)paginatedRows — slices sorted results for current pagetotalPages — total page countstart — current page start indextoggleSort(col) — toggles sort column/direction, resets page to 1gotoPage(p) — navigates to page pnextPage() / prevPage() — page navigationpagesToShow() — returns array of page numbers with '...' ellipsis for large page countscolLabel(col) — returns display label for a column keyinit() — watches search to reset page to 1x-text (safe text rendering):allow-html="true", cells use x-html (renders HTML — use only with trusted data)When :striped="true", alternating rows get even:bg-gray-50 dark:even:bg-gray-800/50 classes.
<th>: role="columnheader", :aria-sort="ascending|descending|none" when sortablearia-hidden="true"<td>: role="status"aria-labelaria-label, type="button":aria-current="page" on active, type="button"aria-hidden="true"aria-hidden="true"All user-facing strings use __('beartropy-ui::ui.*'):
searchno_resultstable_showing, table_to, table_of, table_resultstable_previous, table_nextcolors → {color} → {
searchbox, thead, th, row, td, table,
pagination_container, pagination_button, pagination_active,
pagination_icon, pagination_disabled, pagination_ellipsis,
pagination_info
}
{{-- Basic --}}
<x-bt-table :items="$users" />
{{-- Custom columns with labels --}}
<x-bt-table :items="$users" :columns="['name' => 'Name', 'email' => 'Email']" />
{{-- Non-sortable, non-searchable --}}
<x-bt-table :items="$data" :sortable="false" :searchable="false" />
{{-- Striped rows --}}
<x-bt-table :items="$data" :striped="true" />
{{-- HTML content (trusted data only) --}}
<x-bt-table :items="$data" :allow-html="true" />
{{-- Custom page size --}}
<x-bt-table :items="$data" :per-page="25" />
{{-- No pagination --}}
<x-bt-table :items="$data" :paginated="false" />
{{-- Actions slot (top-right content) --}}
<x-bt-table :items="$users" :columns="['name' => 'Name', 'email' => 'Email']">
<x-slot name="actions">
<x-bt-button primary sm>Add User</x-bt-button>
</x-slot>
</x-bt-table>
{{-- Colored --}}
<x-bt-table :items="$data" color="beartropy" />
{{-- Collection data --}}
<x-bt-table :items="$users->toArray()" />
resources/js/modules/table.js, not inline in the Blade templatefilter_var($prop, FILTER_VALIDATE_BOOLEAN) is used for bool props — string "true"/"false" from Blade attributes work correctlytoggleSort() resets page to 1 to prevent viewing an empty page after sort changes$watch('search') in init() also resets page to 1x-text by default for XSS safety; opt into x-html with :allow-html="true"How can I help you explore Laravel packages today?