..

main.js

1import { world } from "@minecraft/server"
2import { ActionFormData } from "@minecraft/server-ui"
3
4const ui = new ActionFormData()
5    .title("Form")
6    .body("")
7    .button("button1")
8    .button("button2")
9    .button("button3");
10
11const customUi = new ActionFormData()
12    .title("Custom Form")
13    .body("Select Something Here")
14    .button("Rewards", "textures/ui/promo_holiday_gift_small")
15    .button("Shop", "textures/ui/icon_deals")
16    .button("Ban Tool", "textures/ui/hammer_l")
17    .button("Skins", "textures/ui/icon_hangar")
18    .button("Skins", "textures/ui/icon_hangar")
19    .button("Skins", "textures/ui/icon_hangar")
20    .button("Skins", "textures/ui/icon_hangar")
21    .button("Skins", "textures/ui/icon_hangar")
22    .button("Skins", "textures/ui/icon_hangar");
23
24world.afterEvents.itemUse.subscribe(async (event) => {
25    const { source, itemStack } = event
26    switch (itemStack.typeId) {
27        case "minecraft:compass": ui.show(source); break;
28        case "minecraft:clock": {
29            const res = await customUi.show(source);
30            res.selection //This Is Number Will Be Derived From The "collection_index" property of a button in JSON UI
31            world.sendMessage(`Button ${res.selection} Has Been Pressed!`)
32            break
33        };
34    }
35})

Not Affiliated With Mojang Or Microsoft