@redis-ui/styles 21.13.0 → 21.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +110 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # @redis-ui/styles
2
+
3
+ Design tokens, themes and global styles for Redis UI. Every Redis UI package (`components`, `table`, `charts`, `icons`) reads its colors, spacing, typography and component styles from the theme this package provides.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @redis-ui/styles styled-components modern-normalize
9
+ ```
10
+
11
+ Peer dependencies: `react` and `react-dom` 18 or 19, `styled-components` 5, `modern-normalize` 3.
12
+
13
+ ## Setup
14
+
15
+ Import the CSS once in your app entry, then provide a theme and render `CommonStyles`:
16
+
17
+ ```tsx
18
+ import 'modern-normalize/modern-normalize.css';
19
+ import '@redis-ui/styles/normalized-styles.css';
20
+ import '@redis-ui/styles/fonts.css';
21
+ import { ThemeProvider } from 'styled-components';
22
+ import { CommonStyles, themes } from '@redis-ui/styles';
23
+
24
+ <ThemeProvider theme={themes.light}>
25
+ <CommonStyles />
26
+ <App />
27
+ </ThemeProvider>
28
+ ```
29
+
30
+ | Export | What it is |
31
+ |---|---|
32
+ | `@redis-ui/styles/normalized-styles.css` | Resets for Redis UI elements, so global app styles don't override them. Import it after your normalization sheet. To add your own, target `[class*="RedisUI"]` |
33
+ | `@redis-ui/styles/fonts.css` | Fonts for the classic `themes` |
34
+ | `@redis-ui/styles/fonts-next.css` | Fonts for `themesNext` |
35
+ | `CommonStyles` | Global styles from the theme (body, scrollbars), plus a reduced-motion safety net for users with `prefers-reduced-motion: reduce` |
36
+
37
+ ## Themes
38
+
39
+ Two theme bundles are exported, each with a `light` and a `dark` theme:
40
+
41
+ | Bundle | Fonts | Use for |
42
+ |---|---|---|
43
+ | `themes` | `fonts.css` | The current (classic) Redis brand |
44
+ | `themesNext` | `fonts-next.css` | The next brand, used by the Redis Ultra console |
45
+
46
+ Use one bundle per app, and import the fonts file that matches it. To try components in both, use the theme switcher in [Storybook](https://redislabsdev.github.io/redis-ui/).
47
+
48
+ The `theme` export is the classic light theme and is meant for tests only. Don't use it in apps.
49
+
50
+ ### Light/dark switching
51
+
52
+ `SwitchableModeThemeProvider` replaces `ThemeProvider` when the user can switch modes. It persists the choice under `storageKey`:
53
+
54
+ ```tsx
55
+ import { CommonStyles, SwitchableModeThemeProvider, themes } from '@redis-ui/styles';
56
+
57
+ <SwitchableModeThemeProvider
58
+ lightTheme={themes.light}
59
+ darkTheme={themes.dark}
60
+ storageKey="redis-ui-theme-mode"
61
+ >
62
+ <CommonStyles />
63
+ <App />
64
+ </SwitchableModeThemeProvider>
65
+ ```
66
+
67
+ Pair it with the `ThemeModeSwitch` component from `@redis-ui/components`. See **Others → Theme Providers → Theme Mode Switching** in Storybook.
68
+
69
+ ## Using the theme in your own styles
70
+
71
+ A theme has three parts:
72
+
73
+ - `core`: the scales (`space`, `font`, `icon`, `shadow`, `zIndex`, `motion`, `focus`), e.g. `theme.core.space.space400`
74
+ - `semantic.color`: semantic colors by role (`text`, `background`, `border`, `icon`), e.g. `theme.semantic.color.background.neutral100`
75
+ - `components`: per-component tokens used by Redis UI components, e.g. `theme.components.button`
76
+
77
+ Read it in styled-components, or with the `useTheme` hook:
78
+
79
+ ```tsx
80
+ import styled from 'styled-components';
81
+ import { useTheme } from '@redis-ui/styles';
82
+
83
+ const Panel = styled.div`
84
+ padding: ${({ theme }) => theme.core.space.space400};
85
+ background: ${({ theme }) => theme.semantic.color.background.neutral100};
86
+ `;
87
+
88
+ const { mode } = useTheme(); // 'light' | 'dark'
89
+ ```
90
+
91
+ Use tokens instead of hard-coded values, so your UI follows both themes and both modes.
92
+
93
+ ## Other exports
94
+
95
+ - `getFocusStyle()` / `getFocusStyleProperties()`: the design system's focus ring, for custom interactive elements
96
+ - `usePrefersReducedMotion()`: `true` when the user asked for reduced motion
97
+ - `useStorage()`: the persisted-value hook used by mode switching
98
+ - `withOpacity()` / `withContrast()`: color helpers
99
+ - Theme types (`Theme`, `ThemePair`, ...)
100
+
101
+ ## Development
102
+
103
+ The themes live in `src/themes/<themeLight|themeDark|themeLightNext|themeDarkNext>/`. Each one has `tokens.ts` (semantic colors and core scales) and `theme/components/*` (component tokens). A change to one bundle usually needs the same change in its light/dark sibling. To add or retire a whole bundle (a rebrand), follow the `redis-ui-rebrand-theme` skill in `.agents/skills`.
104
+
105
+ ```bash
106
+ npm run build -w packages/styles
107
+ npm run lint -w packages/styles
108
+ ```
109
+
110
+ This package has no unit tests. Changes show up in the components' stories and visual tests. See the [root README](https://github.com/redislabsdev/redis-ui) for Storybook, visual testing and releasing.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@redis-ui/styles",
3
3
  "license": "UNLICENSED",
4
- "version": "21.13.0",
4
+ "version": "21.13.1",
5
5
  "repository": "git@github.com:redislabsdev/redis-ui.git",
6
6
  "type": "module",
7
7
  "files": [