Prometheus Design System v0.2.0 — WIP

UI Patterns

Common UI composition patterns in the Prometheus UI codebase.

Info Page Pattern

Used by: StatusPage, TSDBStatusPage, AgentPage, FlagsPage

The info page pattern combines InfoPageLayout + multiple InfoCard components, each containing a KeyValueTable or DataTable.

Structure

<InfoPageLayout>
  <InfoCard title="Runtime Information" icon={IconServer}>
    <KeyValueTable object={runtimeInfo} />
  </InfoCard>
  <InfoCard title="Build Information" icon={IconInfoCircle}>
    <KeyValueTable object={buildInfo} />
  </InfoCard>
  <InfoCard title="Command-Line Flags" icon={IconFlag}>
    <DataTable columns={flagColumns} data={flags} />
  </InfoCard>
</InfoPageLayout>

Key Characteristics

Accordion List Pattern

Used by: AlertsPage, RulesPage, TargetsPage, ServiceDiscoveryPage

The accordion list pattern combines FilterToolbar + HealthPanel items inside an Accordion. Each page filters groups by state and search text, then renders expandable panels with health-colored borders.

Structure

// Filter bar at top
<FilterToolbar
  searchValue={search}
  onSearchChange={setSearch}
  stateOptions={stateOptions}
  selectedStates={states}
  onStatesChange={setStates}
  showCollapseAll={hasCollapseAll}
  allCollapsed={collapsed}
  onCollapseAllChange={setCollapsed}
/>

// Accordion with health panels
<Accordion multiple variant="separated">
  {filteredGroups.map(group => (
    <HealthPanel key={group.name} value={group.name} status={group.health}>
      <Accordion.Control>
        {group.name}
        <StatusBadge status={group.health} />
      </Accordion.Control>
      <Accordion.Panel>...</Accordion.Panel>
    </HealthPanel>
  ))}
</Accordion>

Variations

PageState OptionsCollapse AllPagination
AlertsPagefiring, pending, inactiveNoYes
RulesPageok, err, unknownNoYes
TargetsPageup, down, unknownYesPool limit (20)
ServiceDiscoveryPageactive, droppedYesPool limit (20)

Query Panel Pattern

The query page is the most complex pattern, combining CodeMirror, time controls, graph rendering, and result tables.

Key Elements

Data Flow

  1. User types PromQL expression
  2. Pressing Enter triggers /query_range or /query API call
  3. Old data stays visible during query (no flash-to-empty)
  4. Results render in either graph or table view
  5. Range selection on graph updates time range and re-queries

Filter Bar Pattern

All filter bars in Prometheus UI follow the same composition:

[StateMultiSelect] + [TextInput with search icon] + [optional collapse button]

FilterToolbar encapsulates this entire pattern. The search input uses fuzzy matching via @nexucis/kvsearch on the page level. All filter values are persisted to URL query parameters.

URL Persistence

// Example URL with persisted filters:
/alerts?search=cpu&state=firing&state=pending&page=2

Suspense + ErrorBoundary Composition

Every async data page uses a consistent wrapping pattern:

<Suspense fallback={<Skeleton />}>
  <ErrorBoundary
    key={location.pathname}
    FallbackComponent={ErrorFallback}
  >
    <PageContent />
  </ErrorBoundary>
</Suspense>

Key Behaviors

URL-Persistent State

All major filter states are persisted in URL query parameters via use-query-params:

StateURL ParamTypePages
Search textsearchStringParamAll list pages
State filterstateArrayParamAlerts, Rules, Targets, SD
Page numberpageNumberParamAlerts, Rules
Active tabtabStringParamQuery (graph/table)
ExpressionexprStringParamQuery
Time rangerange, endNumberParamQuery

This enables: