UI SDK
@rainbow-robotics/plugin-ui
| import | Contents |
|---|---|
| .../plugin-ui/react | Design components (RBLabelButton, RBSlider, RBSwitch, RBTextInput, RBSelectBox …) |
| .../plugin-ui/sdk | useRb(), useRbFormData(), useRbSave() |
| rb method | Behavior |
|---|---|
| rb.pub(topic, payload) | Fire and forget |
| rb.sub(topic, handler) | Subscribe |
| await rb.action(topic, payload) | Request and wait for the response (10 s) |
| rb.toast · alert · confirm · prompt | Muscat notifications · dialogs |
Component list: muscat-pk storybook
Example — call the backend from a button
ui/content.tsx
import { useState } from "react";
import { RBLabelButton, RBSlider }
from "@rainbow-robotics/plugin-ui/react";
import { useRb } from "@rainbow-robotics/plugin-ui/sdk";
export default function App() {
const rb = useRb();
const [width, setWidth] = useState(20);
const grip = async () => {
await rb.action("grip", { width });
rb.toast({ type: "success", message: `grip ${width}mm` });
};
return (<>
<RBSlider value={[width]} min={0} max={100}
onValueChange={(v) => setWidth(v[0] ?? 0)} />
<RBLabelButton onClick={grip}>Grip</RBLabelButton>
</>);
}
Notifications · dialogs

rb.toast
rb.alert
rb.confirm
rb.promptrb.toast({ type: "success", message: "grip 24mm" });
// type: info | success | warning | caution | danger
await rb.alert({ title: "Notice", message: "Done" });
const ok = await rb.confirm({ message: "Send it?",
buttonText: { yes: "Send", no: "Cancel" } }); // → true | false
const name = await rb.prompt({
message: "Enter a name", placeholder: "target" }); // → string | undefined