The Grab UI Components
Relevant source files
The following files were used as context for generating this wiki page:The Grab UI is a set of non-intrusive components that overlay a web application during development. Its primary purpose is to allow developers to select any UI element, view its underlying code context, and send this information along with a prompt to an AI coding agent. This creates a "visual editing" workflow, where developers can request changes to the UI directly from the browser, streamlining the frontend development process.
The entire UI is designed to be lightweight and only active in development environments. It is built using SolidJS and XState to prevent conflicts with the host React application. Styling is managed via Tailwind CSS.
Sources: packages/react-grab/README.md, packages/website/app/blog/agent/page.tsx:210-213, packages/react-grab/package.json:71-75
Core Components
The user interface consists of several key components that appear based on user interaction.
| Component | Description |
|---|---|
| Selection Box | A visual highlight that appears around an HTML element when the user hovers over it while the grab tool is active. |
| Selection Label | A small label that appears next to a clicked element. It displays the component name and HTML tag. Pressing Enter expands it. |
| Agent Prompt | An expanded input field that appears after pressing Enter on the Selection Label. Users can type their change request here. |
| Agent Provider Dropdown | A dropdown menu within the agent prompt UI that allows selecting the target coding agent (e.g., Cursor, Claude Code). |
Sources: packages/website/app/blog/agent/page.tsx:210-222, packages/react-grab/README.md
The diagram below illustrates the relationship between the main UI components.
User Interaction Flow
The standard workflow for using the Grab UI to interact with a coding agent is designed to be fast and intuitive, keeping the developer in the context of their application.
This sequence diagram shows the typical user interaction flow.
Technology Stack
A notable architectural choice is that the Grab UI components are not built with React. To ensure isolation and prevent interference with the host application's React instance, the UI is built with SolidJS for rendering and XState for state management.
- SolidJS: Used for its fine-grained reactivity and performance, creating a lightweight UI layer.
- XState: Manages the component states (e.g., idle, selecting, prompting).
- Tailwind CSS: Used for styling the UI components. The styles are compiled into a single
styles.cssfile.
Sources: packages/react-grab/package.json:71-75, 59-61, CONTRIBUTING.md:73-74
Configuration and Customization
The Grab UI can be configured and customized through an init function or via data-options attributes on the script tag. This allows developers to tailor the appearance and behavior of the tool.
Sources: packages/react-grab/README.md, packages/website/components/install-tabs.tsx:50-57
Initialization Example
The init function provides a programmatic way to configure React Grab.
import { init } from "react-grab/core";
const api = init({
theme: {
enabled: true, // disable all UI by setting to false
hue: 180, // shift colors by 180 degrees (pink → cyan/turquoise)
crosshair: {
enabled: false, // disable crosshair
},
elementLabel: {
enabled: false, // disable element label
},
},
onElementSelect: (element) => {
console.log("Selected:", element);
},
});
Sources: packages/react-grab/README.md
Theme Options
The visual appearance of the UI components can be altered using the theme configuration object.
| Option | Type | Description | Default |
|---|---|---|---|
enabled | boolean | Enables or disables all Grab UI components. | true |
hue | number | A value from 0-360 to shift the color palette. For example, 180 changes the default pink to cyan. | (not specified) |
crosshair.enabled | boolean | Enables or disables the crosshair guide. | true |
elementLabel.enabled | boolean | Enables or disables the label that appears on element selection. | true |
Sources: packages/react-grab/README.md
Hotkey Configuration
The activation hotkey can be customized. By default, it is ⌘C. This can be changed via the data-options attribute on the script tag.
<!-- Example of custom hotkey in Next.js -->
<Script
src="//unpkg.com/react-grab/dist/index.global.js"
data-options={JSON.stringify({
activationKey: { key: "c", altKey: true }
})}
/>
Sources: packages/website/components/install-tabs.tsx:43-57
Summary
The Grab UI components provide a powerful and seamless bridge between a developer's visual application and their AI coding tools. Built with SolidJS for isolation and performance, the UI offers an intuitive flow for selecting elements, providing context, and prompting agents directly from the browser. Its customizability ensures it can be adapted to different developer workflows, ultimately aiming to make frontend UI adjustments faster and more accurate.
Sources: packages/react-grab/README.md, packages/website/app/blog/intro/page.tsx:103-107