# PolymorfaProvider

> Props, styling and a live PolymorfaProvider example.

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

## Props

| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `appearance` | `AppearanceInput` | Optional | System theme, default variables | Theme, variables and slot styles. See [Appearance](https://docs.polymorfa.com/ui-kit/appearance). |
| `locale` | `Locale` | Optional | English | Interface text and direction. |
| `tokenEndpoint` | `string` | Optional |  | 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. |
| `client` | `PolymorfaClient` | Optional |  | A client you created yourself; takes precedence over `tokenEndpoint`. |
| `children` | `ReactNode` | Optional |  | Your components. |

## appearance

| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `theme` | `Theme` | Optional |  |  |
| `variables` | `Partial<AppearanceVariables>` | Optional |  |  |
| `darkVariables` | `Partial<AppearanceVariables>` | Optional |  |  |
| `unstyled` | `boolean` | Optional |  |  |
| `layout` | `Partial<AppearanceLayout>` | Optional |  |  |
| `elements` | `Readonly<Record<string, ElementAppearance>>` | Optional |  |  |

## Types

Named types used in the props above.

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

## Styling

Use `className`, `classNames` (a class for any [slot](https://docs.polymorfa.com/ui-kit/appearance#slots), typed `SlotClassNames`), appearance variables and element styles. The Style panel applies changes to the live component. See [Appearance](https://docs.polymorfa.com/ui-kit/appearance).

## Setup

Use [the provider and server route](https://docs.polymorfa.com/ui-kit/setup) for your application. The preview above uses local sample data and controllers. [Chat controllers](https://docs.polymorfa.com/ui-kit/chat#controllers) and [inbox data sources](https://docs.polymorfa.com/ui-kit/inbox#data-sources) keep your data separate from the UI.
