Skip to content
Shortcut: /, ⌘K or Ctrl+K

PolymorfaProvider

Props, styling and a live PolymorfaProvider example.

View as Markdown
PolymorfaProvider
Sample data
@polymorfa/react

Customize

appearance6 props

Your handler's token route, for example `/api/polymorfa/token`. The provider fetches a client token from it, refreshes it before expiry and shares it with every component inside.

A client you created yourself; takes precedence over `tokenEndpoint`.

React only: @polymorfa/elements has no element for PolymorfaProvider.

PolymorfaProviderExample.jsx
npm install @polymorfa/react@dev @polymorfa/browser@dev
import { PolymorfaProvider } from "@polymorfa/react";

const appearance = { theme: "light", variables: { colorPrimary: "#635bff" } };

export function PolymorfaProviderExample() {
  return (
    <PolymorfaProvider appearance={appearance} />
  );
}

PolymorfaProvider from @polymorfa/react. Choose props and styles above; the preview stays visible in every code view.

Props#

  • appearanceAppearanceInput

    Theme, variables and slot styles. See Appearance.

    Default System theme, default variables

  • localeLocale

    Interface text and direction.

    Default English

  • tokenEndpointstring

    Your handler's token route, for example /api/polymorfa/token. The provider fetches a client token from it, refreshes it before expiry and shares it with every component inside.

  • clientPolymorfaClient

    A client you created yourself; takes precedence over tokenEndpoint.

  • childrenReactNode

    Your components.

appearance#

  • themeTheme
  • variablesPartial<AppearanceVariables>
  • darkVariablesPartial<AppearanceVariables>
  • unstyledboolean
  • layoutPartial<AppearanceLayout>
  • elementsReadonly<Record<string, ElementAppearance>>

Types#

Named types used in the props above.

@polymorfa/ui
type Theme = "light" | "dark" | "system";

Styling#

Use className, classNames (a class for any slot, typed SlotClassNames), appearance variables and element styles. The Style panel applies changes to the live component. See Appearance.

Setup#

Use the provider and server route for your application. The preview above uses local sample data and controllers. Chat controllers and inbox data sources keep your data separate from the UI.