Colors
React and React Native
Light and dark colour palettes for React Native, named by role, with a helper that adds transparency to any colour.
Every colour a screen needs, named by role rather than by shade, so light and dark can swap freely. lightColors and darkColors hold the same nine names, and withAlpha turns any #rrggbb colour into an rgba() string for overlays and pressed states. One file that works unchanged in React and in React Native, with no extra packages.
Installation
CLI
npx @modus-ui/cli add theme-colorsManual
- Copy the code from the code tab.
- Create a file at
components/ui/theme-colors.ts. - Paste the code.
The same file serves React and React Native, so the CLI installs it unchanged in either.
Usage
tsx
API
| Export | Type | Description |
|---|---|---|
lightColors | ThemeColors | The light palette. |
darkColors | ThemeColors | The dark palette. |
withAlpha | (hex: string, alpha: number) => string | Adds transparency to a #rrggbb colour; alpha runs from 0 to 1. |
The names are background, foreground, card, muted, mutedForeground, primary, primaryForeground, border and destructive.
Comments