diff --git a/README.md b/README.md
index 4cd675c..25990d4 100644
--- a/README.md
+++ b/README.md
@@ -71,14 +71,14 @@ You can now:
## Working with Actions
-### Row Actions
+### Row Actions with Custom Attributes
-Actions now support custom **classes** and **styles** for better UI customization:
+You can now add **custom CSS classes and HTML attributes** to actions:
```blade
:actions="[
- ['label' => 'Edit', 'route' => 'users.edit', 'class' => 'bg-blue-500 hover:bg-blue-600 text-white px-2 py-1 rounded', 'style' => 'margin-right: 5px;'],
- ['label' => 'Delete', 'route' => 'users.destroy', 'class' => 'bg-red-500 hover:bg-red-600 text-white px-2 py-1 rounded']
+ ['label' => 'Edit', 'route' => 'users.edit', 'attributes' => ['class' => 'bg-green-500 text-white px-3 py-1 rounded']],
+ ['label' => 'Delete', 'route' => 'users.destroy', 'attributes' => ['class' => 'bg-red-500 text-white px-3 py-1 rounded', 'onclick' => 'return confirm(\'Are you sure?\')']]
]"
```
diff --git a/resources/views/vendor/datatables/actions.blade.php b/resources/views/vendor/datatables/actions.blade.php
index 6aa0c18..4ebb2ac 100644
--- a/resources/views/vendor/datatables/actions.blade.php
+++ b/resources/views/vendor/datatables/actions.blade.php
@@ -1,10 +1,12 @@
diff --git a/src/Action.php b/src/Action.php
index 93954c3..439c997 100644
--- a/src/Action.php
+++ b/src/Action.php
@@ -2,44 +2,40 @@
namespace Ginkelsoft\DataTables;
-/**
- * Class representing an action that can be performed on a DataTable row.
- */
class Action
{
- /** @var string The name of the action */
public string $name;
-
- /** @var string The label displayed for the action */
public string $label;
-
- /** @var string The route associated with the action */
public string $route;
+ public array $attributes = [];
/**
* Action constructor.
*
- * @param string $name The action name
- * @param string $label The action label
- * @param string $route The route associated with the action
+ * @param string $name Unique action name.
+ * @param string $label Button label.
+ * @param string $route Named route for the action.
+ * @param array $attributes Additional HTML attributes (e.g., classes, styles).
*/
- public function __construct(string $name, string $label, string $route)
+ public function __construct(string $name, string $label, string $route, array $attributes = [])
{
$this->name = $name;
$this->label = $label;
$this->route = $route;
+ $this->attributes = $attributes;
}
/**
- * Static method to create a new action instance.
+ * Factory method to create an action instance.
*
- * @param string $name The action name
- * @param string $label The action label
- * @param string $route The route associated with the action
- * @return self A new Action instance
+ * @param string $name Unique action name.
+ * @param string $label Button label.
+ * @param string $route Named route for the action.
+ * @param array $attributes Additional HTML attributes (e.g., classes, styles).
+ * @return self
*/
- public static function make(string $name, string $label, string $route): self
+ public static function make(string $name, string $label, string $route, array $attributes = []): self
{
- return new self($name, $label, $route);
+ return new self($name, $label, $route, $attributes);
}
}