Skip to content

Commit aa25d2d

Browse files
committed
adds responsive option to DataTableComponent
1 parent 14c0725 commit aa25d2d

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

resources/views/bootstrap-4/components/table/table.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="table-responsive">
1+
<div class="{{$this->responsive ? 'table-responsive' : ''}}">
22
<table {{ $attributes->except('wire:sortable') }} class="table table-striped">
33
<thead>
44
<tr>

resources/views/bootstrap-5/components/table/table.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="table-responsive">
1+
<div class="{{$this->responsive ? 'table-responsive' : ''}}">
22
<table {{ $attributes->except('wire:sortable') }} class="table table-striped">
33
<thead>
44
<tr>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@props(['customAttributes' => []])
22

3-
<td {{ $attributes->merge(array_merge(['class' => 'px-3 py-2 md:px-6 md:py-4 whitespace-nowrap text-sm leading-5 text-gray-900'], $customAttributes)) }}>
3+
<td {{ $attributes->merge(['class' => 'px-3 py-2 md:px-6 md:py-4 text-sm leading-5 text-gray-900'])->merge(['class' => $this->responsive ? 'whitespace-nowrap' : ''])->merge($customAttributes) }}>
44
{{ $slot }}
55
</td>

src/DataTableComponent.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ abstract class DataTableComponent extends Component
6868
*/
6969
public string $emptyMessage = 'No items found. Try to broaden your search.';
7070

71+
/**
72+
* Wheter or not to display a responsive table
73+
*
74+
* @var bool
75+
*/
76+
public bool $responsive = true;
77+
7178
/**
7279
* Name of the page parameter for pagination
7380
* Good to change the default if you have more than one datatable on a page.

0 commit comments

Comments
 (0)