ZUI

Search documentation

Find a page or a heading.

AI provider picker

A responsive grid of AI provider cards, from the host's entries or a sample, that calls back with the provider key a card selects.

Installation

bash

The CLI writes components/data-entry/ai-provider-picker.tsx, installs AI provider card, Card, Utils and the brand mark lib, and adds @zeroxsolutions/icons, whose brand-mark-url and ai-provider-mappings entries name each provider's mark and where the CDN serves it, and expo-image, which draws it.

Usage

tsx

With no entries, the picker shows its sample providers. Every card is a button that calls onSelect with its entry's provider key:

tsx

The brand mark lib, @/lib/brand-mark, also draws a mark on its own: BrandMark by a brand's name and AiProviderIcon by a provider's key.

tsx

API reference

AiProviderPicker

Takes every prop of React Native's View, plus:

The cards sit in one column, two from the sm width and three from lg, each as tall as the tallest in its row.

AiProviderPickerEntry

One card's data.

AI_PROVIDER_PICKER_SAMPLE_ENTRIES

The sample entries the picker shows with no entries: providers the @zeroxsolutions/icons brand set has a mark for, with names, blurbs and model counts only.

BrandMark

A variant the mark has no file for, or one whose file fails to load, falls to the next along combine/avatar to color to mono, and past mono to the name's first letter on a tinted circle. With a label the mark is an image named by it; without one a screen reader skips it.

AiProviderIcon

Takes provider, the key, matched without regard to case, and type, size (default 24), shape and label, which it hands to BrandMark. A key that resolves to no mark draws a sparkle.

Differences from the web

  • The web paints mono and combine in the text colour through a CSS mask, which React Native lacks; expo-image tints them the foreground colour instead.
  • The web's ambient style provider and setBrandMarkBase are not ported: the picker names its variant, and a mark takes its own base.
  • AiProviderIcon takes no extra mappings, and neither part takes a className or a style.
  • size is a number of pixels; the web's also takes a CSS length, and BrandMark's defaults to 1em.
  • A key the CDN serves no mark for draws the letter, as on the web, without a request where the manifest lists no file.
  • A row of views stands in for the web's grid, so a className adds to the row's classes rather than replacing a column step.
  • The web's data-slot attributes are not set; a View takes no data attributes.