diff --git a/docs/filters/available-methods.md b/docs/filters/available-methods.md index f8845dbaf..359d2aba9 100644 --- a/docs/filters/available-methods.md +++ b/docs/filters/available-methods.md @@ -387,6 +387,8 @@ Example label blade: ``` ### setFilterLabelAttributes + +#### Old Method (Still Supported) Set custom attributes for a Filter Label. At present it is recommended to only use this for "class" and "style" attributes to avoid conflicts. By default, this replaces the default classes on the Filter Label wrapper, if you would like to keep them, set the default flag to true. @@ -401,6 +403,21 @@ TextFilter::make('Name') ), ``` +#### New Method (Recommended) +Set custom attributes for a Filter Label. At present it is recommended to only use this for "class" and "style" attributes to avoid conflicts. + +By default, this replaces the default classes on the Filter Label wrapper, if you would like to keep them, set the default flag to true. + +```php +TextFilter::make('Name') + ->setLabelAttributes( + [ + 'class' => 'text-xl', + 'default' => true, + ] + ), +``` + ### setCustomView Use a fully custom view for a filter. This will utilise solely your view when rendering this filter. Note that the following methods will no longer apply to a filter using this: - setCustomFilterLabel diff --git a/docs/misc/actions.md b/docs/misc/actions.md index 1030183d5..089b71139 100644 --- a/docs/misc/actions.md +++ b/docs/misc/actions.md @@ -92,6 +92,21 @@ public function actions(): array ## Button Available Methods +### setLabelAttributes +Set custom attributes for an Action Label. At present it is recommended to only use this for "class" and "style" attributes to avoid conflicts. + +By default, this replaces the default classes on the Action Label, if you would like to keep them, set the default flag to true. + +```php +Action::make('Dashboard') + ->setRoute('dashboard') + ->wireNavigate() + ->setLabelAttributes([ + 'class' => 'text-xl', + 'default' => true, + ]), +``` + ### setActionAttributes setActionAttributes is used to pass any attributes that you wish to implement on the "button" element for the action button. By default it will merge with the default classes. @@ -252,6 +267,7 @@ public function actions(): array } ``` + ## Extending You can extend the Base Action class which can be a useful timesaver, when you wish to re-use the same look/feel of an Action, but wish to set a different route (for example). diff --git a/resources/views/includes/actions/button.blade.php b/resources/views/includes/actions/button.blade.php index cbd20ba96..71eaa50b8 100644 --- a/resources/views/includes/actions/button.blade.php +++ b/resources/views/includes/actions/button.blade.php @@ -14,7 +14,7 @@ > @if($action->hasIcon() && $action->getIconRight()) - {{ $action->getLabel() }} + getLabelAttributesBag() }}>{{ $action->getLabel() }} getIconAttributes() ->class(["ms-1 ". $action->getIcon() => $isBootstrap]) ->class(["ml-1 ". $action->getIcon() => $isTailwind]) @@ -28,8 +28,8 @@ ->except(['default','default-styling','default-colors']) }} > - {{ $action->getLabel() }} + getLabelAttributesBag() }}>{{ $action->getLabel() }} @else - {{ $action->getLabel() }} + getLabelAttributesBag() }}>{{ $action->getLabel() }} @endif \ No newline at end of file diff --git a/src/Views/Action.php b/src/Views/Action.php index 3c6570328..ee3d4640e 100644 --- a/src/Views/Action.php +++ b/src/Views/Action.php @@ -6,13 +6,14 @@ use Illuminate\View\ComponentAttributeBag; use Rappasoft\LaravelLivewireTables\Views\Traits\Actions\{HasActionAttributes, HasRoute}; use Rappasoft\LaravelLivewireTables\Views\Traits\Columns\HasVisibility; -use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasIcon, HasLabel, HasTheme, HasView, HasWireActions}; +use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasIcon, HasLabel, HasLabelAttributes, HasTheme, HasView, HasWireActions}; class Action extends Component { use HasActionAttributes; use HasIcon; use HasLabel; + use HasLabelAttributes; use HasRoute; use HasTheme; use HasView;