Skip to content

useComponent

useComponent<K>(slot): UIPluginComponents[K]

Defined in: packages/ui/src/plugin.tsx:119

Resolves a component for a given UIPluginComponents slot.

Looks up the slot in the current UIPlugin (via useUIPlugin). If the plugin provides an implementation for the slot, that component is returned. Otherwise, the headless HTML default is returned. This ensures every component renders correctly even without a UI plugin installed.

K extends keyof UIPluginComponents

The slot key from UIPluginComponents.

K

The component slot name to resolve (e.g., "button", "table", "chip").

UIPluginComponents[K]

The component implementation for the given slot.

function MyComponent() {
const Button = useComponent("button");
const Chip = useComponent("chip");
return <Button onClick={handleClick}>Click me</Button>;
}