···4343}
4444```
45454646-## Exports
4747-4848-Everything ships from one entry point: `@bsky.app/alf`.
4949-5050-| Export | Description |
5151-|--------|-------------|
5252-| `atoms` | 300+ frozen style objects for layout, spacing, typography, borders |
5353-| `useTheme()` | Hook returning the active `Theme` with color-adaptive `atoms` |
5454-| `Provider` | React context provider for theme selection |
5555-| `tokens` | Namespaced design tokens (spacing, font sizes, line heights, radii, weights) |
5656-| `utils` | Namespaced utilities: `alpha`, `leading`, `flatten`, `select` |
5757-| `themes` | Pre-built light, dark, and dim theme objects |
5858-| `createTheme()` | Build a custom theme from a palette |
5959-| `createThemes()` | Build light/dark/dim variants from two palettes |
6060-| `Palette` | Type and defaults for color palettes |
6161-| `invertPalette()` | Flip a palette's color scale for dark mode |
6262-| `isWeb`, `isNative`, `isIOS`, `isAndroid` | Platform detection booleans |
6363-| `web()`, `native()`, `ios()`, `android()` | Platform-gated value selectors |
6464-| `platform()` | `Platform.select()` equivalent |
6565-6646## Platform behavior
67476848ALF uses React Native's file extension convention (`.native.ts`) to resolve platform-specific code at build time.
···77577858## API reference
79598080-See [api-reference.md](./api-reference.md) for the complete API.
6060+See the [full API reference](./api-reference.md) for every export, token value, and platform-specific behavior.
+32-4
api-reference.md
···2727 android,
2828 platform,
2929} from '@bsky.app/alf'
3030+3131+import type {
3232+ Palette,
3333+ Theme,
3434+ ThemeScheme,
3535+ ThemeName,
3636+ ThemeAtoms,
3737+ TextStyleProp,
3838+ ViewStyleProp,
3939+} from '@bsky.app/alf'
3040```
31413242---
···66766777### `Context`
68786969-The raw React context (`React.Context<{ theme: Theme }>`). Defaults to `themes.light`. Display name: `'AlfContext'`.
7979+The raw React context (`React.Context<{ theme: Theme }>`). Initial value uses `themes.light`. Display name: `'AlfContext'`.
70807181You rarely need this directly. Use `useTheme()` instead.
7282···578588579589### `invertPalette(palette)`
580590581581-Flips **all four** color scales (contrast, primary, positive, negative) for dark mode. Swaps `_0`/`_25` with `_1000`/`_975`, and so on symmetrically. Keeps `white`, `black`, and `like` unchanged.
591591+Flips **all four** color scales (contrast, primary, positive, negative) for dark mode. Swaps `_0`/`_25` with `_1000`/`_975`, and so on symmetrically. The `_500` center values in each scale remain unchanged. Keeps `white`, `black`, and `like` unchanged.
582592583593```typescript
584594const darkPalette = invertPalette(DEFAULT_PALETTE)
···678688platform({ web: 16, default: 12 })
679689```
680690691691+> On web, this uses `||` (not `??`), so falsy values like `0` or `""` for `specifics.web` will fall through to `specifics.default`.
692692+681693---
682694683695## Utils
···706718// Native: { lineHeight: 23 } (rounded pixel value)
707719```
708720709709-Defaults to `tokens.fontSize.sm` and `tokens.lineHeight.snug` when values are missing.
721721+Defaults to `tokens.lineHeight.snug` when `lineHeight` is missing. On native, also defaults to `tokens.fontSize.sm` when `fontSize` is missing (web does not use `fontSize`).
710722711723Returns: `Pick<TextStyle, 'lineHeight'>`
712724···746758// { flexDirection: 'row', gap: 12 }
747759```
748760749749-On both web and native, this delegates to `StyleSheet.flatten`. A custom fallback implementation exists for environments where neither `.web.ts` nor `.native.ts` is resolved.
761761+On web and native, this delegates to `StyleSheet.flatten`. A custom fallback implementation is provided for other environments where neither `.web.ts` nor `.native.ts` is resolved.
750762751763Returns: merged style object
752764···776788| Background | `bg`, `bg_contrast_25`, `bg_contrast_50`, `bg_contrast_100` through `bg_contrast_900`, `bg_contrast_950`, `bg_contrast_975` |
777789| Border | `border_contrast_low`, `border_contrast_medium`, `border_contrast_high` |
778790| Shadow | `shadow_sm`, `shadow_md`, `shadow_lg` |
791791+792792+### `Palette`
793793+794794+Color value map for a theme. See [Palette](#palette) for the full shape.
795795+796796+### `Theme`
797797+798798+Complete theme object containing scheme, name, palette, and atoms. See [Themes](#themes) for details.
799799+800800+### `ThemeScheme`
801801+802802+`'light' | 'dark'`
803803+804804+### `ThemeName`
805805+806806+`'light' | 'dark' | 'dim'`
779807780808---
781809