# Command

Source: /tuil/docs/reference/packages/core/api/command
Locale: en

interface exported by @mwillbanks/tuil-core.



{/* Generated by tooling/docs/generate-reference.ts. */}

## interface [#interface]

Public interface exported by `@mwillbanks/tuil-core`.

```ts
export interface Command<TResult = unknown> {
  readonly id: string;
  readonly title: string;
  readonly description?: string;
  readonly category?: string;
  readonly hotkeys?: readonly string[];
  readonly hotkeyScope?:
    | "application"
    | "route"
    | "focus-scope"
    | "component"
    | "overlay"
    | "dialog";
  readonly hotkeyScopeId?: string;
  readonly enabled?: (context: CommandContext) => boolean | Promise<boolean>;
  readonly execute: (context: CommandContext) => TResult | Promise<TResult>;
}
```

## Members [#members]

| Member          | Type                                                                                             | Required | Description                                                                                                                                  | Related types                                                         |
| --------------- | ------------------------------------------------------------------------------------------------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| `id`            | `string`                                                                                         | Yes      | The `id` member uses the `string` contract.                                                                                                  | —                                                                     |
| `title`         | `string`                                                                                         | Yes      | The `title` member uses the `string` contract.                                                                                               | —                                                                     |
| `description`   | `string \| undefined`                                                                            | No       | The `description` member uses the `string \| undefined` contract.                                                                            | —                                                                     |
| `category`      | `string \| undefined`                                                                            | No       | The `category` member uses the `string \| undefined` contract.                                                                               | —                                                                     |
| `hotkeys`       | `readonly string[] \| undefined`                                                                 | No       | The `hotkeys` member uses the `readonly string[] \| undefined` contract.                                                                     | —                                                                     |
| `hotkeyScope`   | `"application" \| "route" \| "focus-scope" \| "component" \| "overlay" \| "dialog" \| undefined` | No       | The `hotkeyScope` member uses the `"application" \| "route" \| "focus-scope" \| "component" \| "overlay" \| "dialog" \| undefined` contract. | —                                                                     |
| `hotkeyScopeId` | `string \| undefined`                                                                            | No       | The `hotkeyScopeId` member uses the `string \| undefined` contract.                                                                          | —                                                                     |
| `enabled`       | `((context: CommandContext) => boolean \| Promise<boolean>) \| undefined`                        | No       | The `enabled` member uses the `((context: CommandContext) => boolean \| Promise<boolean>) \| undefined` contract.                            | [`CommandContext`](/tuil/docs/reference/packages/core/api/command-context) |
| `execute`       | `(context: CommandContext) => TResult \| Promise<TResult>`                                       | Yes      | The `execute` member uses the `(context: CommandContext) => TResult \| Promise<TResult>` contract.                                           | [`CommandContext`](/tuil/docs/reference/packages/core/api/command-context) |

## Parameters [#parameters]

This declaration has no public members.

## Returns [#returns]

This declaration does not return a value.

## Throws [#throws]

No thrown errors are documented for this declaration.

## Related types [#related-types]

* [`CommandContext`](/tuil/docs/reference/packages/core/api/command-context)

## Source [#source]

[View the secondary source reference](https://github.com/mwillbanks/tuil/blob/main/packages/core/src/commands.ts)

## Package [#package]

[@mwillbanks/tuil-core](/tuil/docs/reference/packages/core)
