<!--
{
  "availability" : [
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "TabletopKit",
  "identifier" : "/documentation/TabletopKit/CustomAction",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "TabletopKit"
    ],
    "preciseIdentifier" : "s:11TabletopKit12CustomActionP"
  },
  "title" : "CustomAction"
}
-->

# CustomAction

A protocol that represents an action whose behavior is implemented outside of TabletopKit.
A custom action that can be applied to a `TableState`.

```
protocol CustomAction
```

## Topics

### Creating a custom action

[`init?(from: some TabletopAction)`](/documentation/TabletopKit/CustomAction/init(from:))

Creates an instance of `CustomAction` initialized from the provided `TabletopAction`. If the provided action is not a custom action, this initializer
returns `nil`.

### Applying the action

[`func apply(table: inout TableState)`](/documentation/TabletopKit/CustomAction/apply(table:))

Implement this function to perform the changes to the table state that this action represents. It is important that the code performed in this function is only
a function of the provided table state and the data of the action instance.

### Validating the action

[`func validate(snapshot: TableSnapshot) -> Bool`](/documentation/TabletopKit/CustomAction/validate(snapshot:))

Implement this function to detect whether the action is valid and should be applied given the state of the table represented by `snapshot`.
If not implemented, the action is always considered valid. It is important that the validation for a given action is only a function of the given snapshot and the
data of the action instance.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)