@agg-build/ui

中文文档
4.37.0发布于 2026/11/06MITTypeScriptESM + CJS近 30 天下载 3654

Pre-built React component library for the AGG prediction market aggregator. Tailwind-based, themeable, with primitives, event surfaces, trading flows, full pages, and modals.

原始使用文档
文档目录22 节
  1. What it is
  2. When to use this package
  3. Install
  4. Quick start
  5. Styling
  6. Tree-shaking
  7. Using a full page
  8. Components
  9. Primitives — @agg-build/ui/primitives
  10. Events — @agg-build/ui/events
  11. Trading — @agg-build/ui/trading
  12. Pages — @agg-build/ui/pages
  13. Modals — @agg-build/ui/modals
  14. classNames overrides
  15. Key component props
  16. HomePage
  17. EventMarketPage
  18. PlaceOrder
  19. Entrypoints
  20. Peer dependencies
  21. Links
  22. License

@agg-build/ui

Pre-built React component library for the AGG prediction market aggregator. Tailwind-based styles, themeable CSS tokens, and components grouped into primitives, event surfaces, trading flows, full pages, and modals.

See every component live in the AGG Storybook.

What it is

@agg-build/ui ships the UI you'd have to build yourself: event cards, market detail pages, orderbook and chart primitives, order entry forms, deposit/withdraw/onboarding modals, and opinionated page layouts. Components are built on top of @agg-build/hooks and expect an <AggProvider> above them in the tree. Styling is Tailwind v4 + CSS custom properties so you can theme everything from your own stylesheet.

This package intentionally contains no wallet code and no auth adapters — the modular connect/sign-in UI lives in @agg-build/auth. That keeps @agg-build/ui free of wagmi, @solana/*, and related peers.

When to use this package

  • You want production-ready AGG trading UI without wiring every view from scratch.
  • You plan to render a full AGG home/event/market/profile surface inside your app.
  • You want themeable primitives (Button, Card, Modal, Chart, Tooltip, etc.) consistent with the rest of the AGG surfaces.

If you only need the underlying logic, install @agg-build/sdk and @agg-build/hooks and build your own UI.

Install

npm install @agg-build/sdk @agg-build/hooks @agg-build/ui liveline

liveline is the charting engine used by Chart / LineChart and is declared as a peer dependency.

Quick start

import "@agg-build/ui/styles.css";
import { QueryClient, QueryClientProvider } from "@agg-build/hooks";
import { createAggClient } from "@agg-build/sdk";
import { AggProvider } from "@agg-build/ui";
import { HomePage } from "@agg-build/ui/pages";

const client = createAggClient({
  baseUrl: "https://api.agg.market",
  appId: "your-app-id",
  wsUrl: "wss://ws.agg.market",
});
const queryClient = new QueryClient();

export default function App() {
  return (
    <QueryClientProvider client={queryClient}>
      <AggProvider
        client={client}
        config={{
          general: { locale: "en-US", theme: "dark" },
          features: { enableAnimations: true, enableLiveUpdates: true, showFeesBreakdown: true },
        }}
      >
        <HomePage withHeader />
      </AggProvider>
    </QueryClientProvider>
  );
}

Set config.features.enableEventDiscoveryUrlPersistence to true to persist the primary HomePage section's category, repeated subcategory, venue, and sort filters in browser history. It is disabled by default and preserves unrelated query parameters such as search.

Styling

Import the default theme once at your app entrypoint:

import "@agg-build/ui/styles.css";

The UI-level AggProvider adds AGG's toast surface to the hooks provider. It still requires the same client prop and QueryClientProvider ancestor shown above. Override theme tokens with CSS variables on the .agg-root container (automatically applied by AggProvider):

.agg-root {
  --agg-color-primary: #ed8200;
  --agg-color-foreground: #1a1a1a;
  --agg-radius-md: 8px;
  --agg-font-family-sans: "Your Font", ui-sans-serif, system-ui, sans-serif;
}

You can also set --agg-font-family-sans on :root; a value on .agg-root wins because it is scoped closer to the AGG UI tree.

With Next.js next/font, expose the generated font variable on an ancestor, then map it into the AGG token on .agg-root:

import { Inter } from "next/font/google";

const inter = Inter({
  subsets: ["latin"],
  variable: "--font-inter",
});

export default function App() {
  return (
    <div className={inter.variable}>
      <QueryClientProvider client={queryClient}>
        <AggProvider client={client}>
          <AggApp />
        </AggProvider>
      </QueryClientProvider>
    </div>
  );
}
.agg-root {
  --agg-font-family-sans: var(--font-inter), ui-sans-serif, system-ui, sans-serif;
}

If you already use Tailwind v4 in your app and want the AGG preset to merge with your config, import @agg-build/ui/tailwind.css instead of (or alongside) styles.css.

Tree-shaking

Import from the grouped subpaths to keep your bundle narrow:

// Preferred
import { Button, Card } from "@agg-build/ui/primitives";
import { HomePage, EventMarketPage } from "@agg-build/ui/pages";
import { DepositModal, OnboardingModal } from "@agg-build/ui/modals";
import { PlaceOrder } from "@agg-build/ui/trading";

// Wider than necessary
import { Button } from "@agg-build/ui";

Using a full page

The HomePage and EventMarketPage components take partner-owned navigation callbacks. In the demo app we wire them to Next.js router.push:

"use client";
import { HomePage } from "@agg-build/ui/pages";
import { useRouter } from "next/navigation";

export function Home() {
  const router = useRouter();
  const getMarketHref = (event, market, outcome) =>
    `/events/${event.id}?marketId=${market.id}&outcomeId=${outcome.id}`;
  const getEventHref = (event) => `/events/${event.id}`;

  return (
    <HomePage
      withHeader={false}
      onEventClick={(event) => router.push(getEventHref(event))}
      onMarketClick={(event, market, outcome) => router.push(getMarketHref(event, market, outcome))}
      getEventHref={getEventHref}
      getMarketHref={getMarketHref}
      stickyOrderPanel={{ enabled: true, top: 80 }}
    />
  );
}

Components

Primitives — @agg-build/ui/primitives

ComponentDescription
AggErrorBoundaryError boundary wrapper
AggLogoAGG wordmark
AutocompleteSelectCombobox with async results
BadgeStatus badge
ButtonBase button primitive
CardContent card
ChartPrice chart (liveline-based)
CurrencyInputLocale-aware money input
FooterSite footer
HeaderSite header with search
IconAGG icon set
InlineAlertError/warning inline alert
LoadingIconSpinner
ModalDialog/modal
NumberValueFormatted, animated numbers
RemoteImageImage with loading/error
SearchSearch input
SelectDropdown select
SkeletonLoading placeholder
StateMessageEmpty / error state display
SwitchButtonBinary toggle switch
TabsTab navigation
TooltipHover / focus tooltip
TypographyText scale primitives
VenueLogoVenue icon / logo

Events — @agg-build/ui/events

ComponentDescription
EventListGrid/list of prediction market events
EventListItemSingle event row / card
ItemDetailsPer-market detail block
MarketDetailsFull market detail view
OrderbookOrderbook depth view

Trading — @agg-build/ui/trading

ComponentDescription
PlaceOrderOrder entry form (managed execution)
SettlementSettlement status card
SettlementDetailsExpanded settlement detail
TradingContextEvent/market/outcome selection context

Pages — @agg-build/ui/pages

ComponentDescription
HomePageFull home page with tabs, search, grid
EventMarketPageFull event/market detail page
UserProfilePageUser profile page with tabs
LeaderboardPageTrader leaderboard by P&L or volume

Modals — @agg-build/ui/modals

ComponentDescription
DepositModalDeposit flow (managed wallets + chains)
WithdrawModalWithdraw flow
OnboardingModalUser onboarding flow
ProfileModalProfile edit + linked accounts
GeoBlockModalGeo-restriction modal
GeoBlockBannerPersistent geo-block banner

classNames overrides

Most components accept a classNames compound prop so partners can target sub-elements:

<Modal.Header
  title="Place order"
  classNames={{
    root: "custom-header",
    title: "custom-title",
    close: "custom-close-btn",
  }}
/>

Key component props

HomePage

PropTypeDescription
tabsHomePageTab[]Custom tab definitions
eventSectionItemsHomePageEventSectionItem[]Custom event section configuration
categoriesLimitnumberMax number of category tabs to show
allCategoryTabLabelstringLabel for the "All" category tab
actionsReactNodeSlot for header actions (e.g., <ConnectButton />)
withHeaderboolean (default true)Render the built-in Header with search + logo
onEventClick(event) => voidCalled when an event card is clicked
onMarketClick(event, market, outcome) => voidCalled when an outcome price is clicked
getEventHref(event) => stringProvide href for SSR-friendly links
getMarketHref(event, market, outcome) => stringProvide href for market links
stickyOrderPanel{ enabled: boolean; top?: number }Stick the order panel when scrolling
classNamesHomePageClassNamesStyle overrides

EventMarketPage

Renders the full event page with trading context. Requires <AggProvider> and uses EventTradingContext internally. Access selection state with useEventTradingContext() from @agg-build/hooks.

PlaceOrder

Order entry form. Renders inside EventMarketPage or standalone — requires an active EventTradingContext with a selected market and outcome. Integrates with the managed execution hooks from @agg-build/hooks.

Entrypoints

EntryPurpose
@agg-build/uiRoot export (re-exports every subpath)
@agg-build/ui/primitivesButtons, Modal, Chart, Tooltip, etc.
@agg-build/ui/eventsEventList, EventListItem, MarketDetails, Orderbook
@agg-build/ui/tradingPlaceOrder, Settlement, trading context utilities
@agg-build/ui/pagesHomePage, EventMarketPage, UserProfilePage
@agg-build/ui/modalsDeposit/Withdraw/Onboarding/Profile/GeoBlock modals
@agg-build/ui/styles.cssDefault theme stylesheet (import once at app entry)
@agg-build/ui/tailwind.cssTailwind preset if you run Tailwind v4 yourself

Peer dependencies

  • @agg-build/sdk
  • @agg-build/hooks
  • react ^18.0.0 or ^19.0.0
  • react-dom ^18.0.0 or ^19.0.0
  • liveline ^0.0.7 — charting engine used by Chart / LineChart

No wallet packages required. Wallet-backed auth lives in @agg-build/auth.

License

MIT

版本与发布记录

@agg-build/ui 共发布 93 个版本,首次发布于 2026/04/28;过去 12 个月发布了 93 个版本。

版本发布日期距今
4.37.0latest2026/11/06今天
4.36.12026/11/041 天前
4.36.02026/11/042 天前
4.35.02026/11/033 天前
4.33.02026/10/307 天前
4.32.02026/10/289 天前

关于 @agg-build/ui 的常见问题

@agg-build/ui 是什么?

Pre-built React component library for the AGG prediction market aggregator. Tailwind-based, themeable, with primitives, event surfaces, trading flows, full pages, and modals.

如何安装 @agg-build/ui?

在项目目录运行 npm install @agg-build/ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.0.0 || ^19.0.0)、liveline(^0.0.7)、react-dom(^18.0.0 || ^19.0.0)、@agg-build/sdk(^4.37.0)、@agg-build/hooks(^4.37.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@agg-build/ui 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@agg-build/ui 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@agg-build/ui 可以商用吗?

@agg-build/ui 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@agg-build/ui 的下载量有多少?

根据 npm 官方下载统计,@agg-build/ui 在 2026/10/05 – 2026/11/03 这 30 天内被下载 3,654 次,日均约 122 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@agg-build/ui 还在维护吗?

最新版本 4.37.0 发布于 2026/11/06(今天);至今共发布 93 个版本,其中过去 12 个月发布了 93 个;首次发布于 2026/04/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。