Command
A dialog component that facilitates search functionality, often featuring fuzzy search capabilities for quick and efficient filtering.
Usage
A basic example to quickly demonstrate how the Command
component works.
This will showcase the essential functionality of the command interface in a simple, usable format.
Properties
Interactive configurator to explore different customization options for the Command
component.
This section allows users to adjust properties such as state control, error handling, and other configurable aspects of the Command
component.
Data Types
Defines the structure of the data used by the Command
component.
The Command
component can handle both static and dynamic data, depending on whether you choose to define data using props.actions
or manually specifying the children components.
-
Important:
- Either props.actions or children should be specified; you cannot use both at the same time or omit both.
- Using both options simultaneously will cause confusion in the function and omitting both will result in no action being executed.
- To prevent this conflict, error handling is implemented to ensure that only one data type (either props.actions or children) is used.
-
Alternative Approach:
- You can use the
<Command.Root>
compound component to group multiple<Command>
components together while managing their data types effectively.
- You can use the
Data Single
Demonstrates how to define a single data item for the Command
component.
Ideal for situations where you need to display a simple, single-action command with minimal configuration.
Data Group
Shows how to define a group of data for the Command
component.
This allows multiple actions or commands to be grouped together, useful for when you want to provide several related options in a single command interface.
Multiple Command
When using the Command
component in multiple places or contexts with different states, it’s essential to create separate store and storeState instances using the createCommand()
function.
This ensures that each command operates independently and does not interfere with others.
API References
Styles API
type T =
| "search"
| "overlay"
| "content"
| "footer"
| "searchWrap"
| "searchLabel"
| "closeCommand"
| "empty"
| "actionsOrder"
| "actionSection"
| "actionsList"
| "actionsGroup"
| "actionGroupLabel"
| "action"
| "actionLabel"
| "actionInner"
| "highlight"
| "actionDescription"
| "actionLeftSection"
| "actionRightSection"
| "footer";
Styles API | Type | Default | Annotation |
---|---|---|---|
unstyled? | Partial<Record<T, boolean>> | false | if true , default styles will be removed |
className? | string | undefined | pass to root component <div> |
classNames? | Partial<Record<T, string>> | undefined | |
style? | CSSProperties | undefined | pass to root component <div> |
styles? | Partial<Record<T, CSSProperties>> | undefined |
Props API
Props API | Type | Default | Annotation |
---|---|---|---|
container? | Element | DocumentFragment | null | document.body | Specify a container element to portal the content into. |
forceMount? | boolean | false | Used to force mounting when more control is needed. |
Source Codes
Full working code example, including necessary markup and styles. You can copy and paste this code directly to start using the component immediately.