PolymorfaProvider
Props, styling and a live PolymorfaProvider example.
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.
npm install @polymorfa/react@dev @polymorfa/browser@devimport { 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#
appearanceAppearanceInputTheme, variables and slot styles. See Appearance.
Default System theme, default variables
localeLocaleInterface text and direction.
Default English
tokenEndpointstringYour 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.clientPolymorfaClientA client you created yourself; takes precedence over
tokenEndpoint.childrenReactNodeYour components.
appearance#
themeThemevariablesPartial<AppearanceVariables>darkVariablesPartial<AppearanceVariables>unstyledbooleanlayoutPartial<AppearanceLayout>elementsReadonly<Record<string, ElementAppearance>>
Types#
Named types used in the props above.
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.