Mobile › Foundations
PlankProvider
Wraps your app once. Picks iOS or Material patterns, light or dark, and applies a PlankUI theme, accent, style and corner radius to every component.
Installation
npx expo install plankui-mobile react-native-safe-area-context expo-hapticsUsage
import { PlankProvider, ToastProvider, useTheme } from "plankui-mobile";
export default function App() {
return (
<PlankProvider theme="ember" look="keycap" accent="blue">
<ToastProvider>
<Home />
</ToastProvider>
</PlankProvider>
);
}
// In your own components, read every colour and size from the theme.
function Price({ amount }: { amount: string }) {
const t = useTheme();
return <Text style={{ color: t.c.accent }}>{amount}</Text>;
}iOS and Android
iOS: With no platform set, iPhones, iPads and the web get Apple's patterns and the San Francisco type scale.
Android: Android devices get Material 3 patterns, Roboto sizes and 48 dp touch targets.
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| theme | "volt" | "ember" | "grove" | "nebula" | "terminal" | "candy" | "volt" | PlankUI theme: paper, ink and accent colours. |
| look | "soft" | "flat" | "glass" | "keycap" | "brutal" | "soft" | PlankUI component style: shadows, outlines, glass, keycap edges or brutal blocks. |
| accent | "blue" | "violet" | "emerald" | "vermilion" | "rose" | "amber" | "mono" | string | theme's own | An accent preset or any hex colour. |
| radius | number | 1 | Corner multiplier, 0 (square) to 2. |
| platform | "ios" | "android" | the device | Force one platform's patterns. The web gets iOS. |
| scheme | "light" | "dark" | the system | Force light or dark. |
| fonts | { body?: string; display?: string } | – | Font families you have loaded with expo-font. |
useTheme()
| Prop | Type | Default | Description |
|---|---|---|---|
| os | "ios" | "android" | Which platform's patterns are drawn. | |
| scheme | "light" | "dark" | The current appearance. | |
| c | Colors | bg, grouped, surface, fill, field, ink, ink2, muted, rule, accent, onAccent, danger, success, warning and more. | |
| look | Look | The style: r() for radii, card, field and button styles. | |
| type | TypeScale | The platform's type scale, largeTitle to caption. | |
| hit | number | Minimum touch target: 44 on iOS, 48 on Android. | |
| wash | (color?) => string | A faint tint of a colour for backgrounds. |