You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/tags/reactcode.md
+32-1Lines changed: 32 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,8 +21,9 @@ Importantly, this allows you to continue leveraging Label Studio's annotation ma
21
21
| Parameter | Type | Default | Description |
22
22
|-----------|------|---------|-------------|
23
23
| name | string | — | Unique identifier for the tag (required) |
24
-
|[toName]| string | — | If this is a [self-referencing tags ](#Self-referencing-tag), this parameter is required and should match `name`|
24
+
|[toName]| string | — | If this is a [self-referencing tag](#Self-referencing-tag), this parameter is required and should match `name`|
25
25
|[data]| string | — | The [task data](#Data-parameter), e.g., `data="$image"` or `data="$text"`|
26
+
|[src]| string | — | URL to an external JavaScript file containing the React component code. Use this as an alternative to inline code. [See more below](#Using-the-src-attribute)|
26
27
|[inputs]| string | — | Defines the JSON schema for the input data (`data`) |
27
28
|[outputs]| string | — | Defines the JSON schema for the [output](#Using-the-outputs-parameter)|
28
29
|[style]| string | — | Inline styles or CSS string for the iframe container |
@@ -66,7 +67,37 @@ function MyComponent({ React, addRegion, regions, data }) {
66
67
}
67
68
```
68
69
70
+
### Using the `src` attribute
69
71
72
+
By default, you write your React component code inline, directly inside the `<ReactCode>` tag (typically wrapped in a [CDATA section](#CDATA-wrapper)). The `src` attribute provides an alternative approach: instead of embedding the code in the labeling configuration, you can host it at an external URL and reference it.
73
+
74
+
This works similarly to how a `<script src="...">` tag loads JavaScript from an external file in HTML.
The external JavaScript file should export a function component with the same signature as inline code (receiving `React`, `addRegion`, `regions`, `data`, and `viewState` as props).
91
+
92
+
**When to use `src`:**
93
+
94
+
- Your component code is large or complex and difficult to manage inside XML
95
+
- You want to version and maintain your UI code in a separate repository
96
+
- You want to reuse the same component across multiple labeling projects
97
+
- You prefer developing in a standard IDE workflow (edit, deploy, reference)
98
+
99
+
!!! note
100
+
When the `src` attribute is provided, any inline code inside the `<ReactCode>` tag is ignored. The component is loaded entirely from the external URL.
0 commit comments