@redis-ui/components 51.9.1 → 51.9.3

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@redis-ui/components",
3
3
  "license": "UNLICENSED",
4
- "version": "51.9.1",
4
+ "version": "51.9.3",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "repository": "git@github.com:redislabsdev/redis-ui.git",
@@ -7,7 +7,7 @@ description: Use Redis UI components from redis-ui components. Provides usage re
7
7
 
8
8
  Package: `@redis-ui/components`
9
9
 
10
- **Requirements:** React 18 or 19, react-dom 18 or 19
10
+ **Requirements:** React 18 or 19, react-dom 18 or 19, styled-components 5, `@redis-ui/styles` and `@redis-ui/icons` (peer dependencies). The root setup below also imports `modern-normalize`, a peer dependency of the styles package that apps must install themselves.
11
11
 
12
12
  ## How to Use
13
13
 
@@ -27,13 +27,68 @@ import { EditIcon, DeleteIcon, iconVariants, type IconVariant } from '@redis-ui/
27
27
  import { RedisLogoDarkMinIcon } from '@redis-ui/icons/multicolor';
28
28
  ```
29
29
 
30
+ ## Setup and themes
31
+
32
+ An app needs this once, at its root. Install the packages it imports first: `@redis-ui/styles`, `styled-components` and `modern-normalize` (a peer dependency, not installed automatically). Without the theme provider components render incorrectly, and without `TooltipProvider` every `Tooltip` (and components that render tooltips, such as `MoreInfoIcon`, `Chip`, `KeyValueList`) throws.
33
+
34
+ ```tsx
35
+ import 'modern-normalize/modern-normalize.css';
36
+ import '@redis-ui/styles/normalized-styles.css';
37
+ import '@redis-ui/styles/fonts.css'; // fonts-next.css with themesNext
38
+ import { ThemeProvider } from 'styled-components';
39
+ import { CommonStyles, themes } from '@redis-ui/styles';
40
+ import { TooltipProvider } from '@redis-ui/components';
41
+
42
+ <ThemeProvider theme={themes.light}>
43
+ <CommonStyles />
44
+ <TooltipProvider>
45
+ <App />
46
+ </TooltipProvider>
47
+ </ThemeProvider>;
48
+ ```
49
+
50
+ Before adding providers, check whether the app already mounts them (they usually live in the app's root component).
51
+
52
+ **Theme bundles** — `@redis-ui/styles` exports two, each with `light` and `dark`:
53
+
54
+ | Bundle | Fonts file | Use for |
55
+ |---|---|---|
56
+ | `themes` | `fonts.css` | The current (classic) Redis brand |
57
+ | `themesNext` | `fonts-next.css` | The next brand, used by the Redis Ultra console |
58
+
59
+ - Use the bundle the app already uses; never mix bundles in one app. Code under an Ultra surface uses `themesNext`.
60
+ - Components are the same for both bundles; only their look changes. Never wrap an individual component in its own `ThemeProvider` — it inherits the app's theme.
61
+ - Light/dark switching: replace `ThemeProvider` with `SwitchableModeThemeProvider` (`lightTheme`, `darkTheme`, `storageKey`, optional `allowSystemThemeMode` / `defaultThemeMode`) and render `ThemeModeSwitch` (see [ThemeModeSwitch](./references/ThemeModeSwitch.md)).
62
+
63
+ **Styling with tokens** — read values from the theme instead of hard-coding them, so custom UI follows both bundles and both modes:
64
+
65
+ ```tsx
66
+ import styled from 'styled-components';
67
+ import { useTheme } from '@redis-ui/styles';
68
+ import { Typography } from '@redis-ui/components';
69
+
70
+ const Panel = styled.div`
71
+ padding: ${({ theme }) => theme.core.space.space400};
72
+ background: ${({ theme }) => theme.semantic.color.background.neutral100};
73
+ `;
74
+
75
+ // useTheme is a hook: call it inside a component or custom hook
76
+ const ModeLabel = () => {
77
+ const { mode } = useTheme(); // 'light' | 'dark'
78
+
79
+ return <Typography.Body>Current mode: {mode}</Typography.Body>;
80
+ };
81
+ ```
82
+
83
+ `theme.core` holds the scales (`space`, `font`, `icon`, `shadow`, `zIndex`, `motion`, `focus`), `theme.semantic.color` the colors by role (`text`, `background`, `border`, `icon`), and `theme.components` the per-component tokens. `normalized-styles.css` sets the root font size to `62.5%`, so `rem` values are on a 10px base (`space400` = `3.2rem` = 32px).
84
+
30
85
  ## Key Patterns
31
86
 
32
87
  - **Composition**: Many components support a `Compose` pattern for advanced customization (e.g., `Select.Compose`, `Section.Compose`). Check the component reference for compose examples.
33
88
  - **Compound Components**: Some components use `Object.assign` to attach sub-components (e.g., `Button.Icon`, `Modal.Content`, `Tabs.TabBar`). These sub-components share internal React context with their parent, so they must be rendered inside it.
34
89
  - **Layouts**: Use `FlexGroup` and `FlexItem` for flex layouts instead of raw `div` with inline styles. `FlexGroup` supports `gap`, `direction`, `align`, `justify`, and `wrap` props. For 2-D layouts (tracks that line up across both axes) use `Grid`. All layout boxes share `padding`/`margin`/sizing props via `BoxProps`. See the Layout references.
35
90
  - **Typography**: Use `Typography.Heading`, `Typography.Body`, and `Typography.Code` for all text rendering instead of raw `<span>`, `<p>`, or `<h1>`–`<h6>` elements. See the [Typography](./references/Typography.md) reference.
36
- - **Theming**: Components use `styled-components` and access theme via `useTheme()` from `@redis-ui/styles`.
91
+ - **Theming**: Components read everything from the `styled-components` theme (see [Setup and themes](#setup-and-themes)). Use `useTheme()` from `@redis-ui/styles` and theme tokens in custom styles instead of hard-coded values.
37
92
  - **ForwardRef**: Most components support `ref` forwarding.
38
93
 
39
94
  ## Important
@@ -35,7 +35,7 @@ Typography.Base also inherits standard `HTMLAttributes<HTMLElement>` props, exce
35
35
  | component | `'p' \| 'span' \| 'div'` | `'p'` | Element used to render the body text |
36
36
  | size | `'XL' \| 'L' \| 'M' \| 'S' \| 'XS' \| 'auto'` | `'M'` | Body text size |
37
37
  | variant | `'regular' \| 'semiBold' \| 'italic'` | `'regular'` | Font style/weight variant |
38
- | color | `TypographyColor` | - | Theme typography color token |
38
+ | color | `'primary' \| 'secondary' \| 'notice' \| 'success' \| 'attention' \| 'danger' \| 'upsell' \| 'informative'` | - | Semantic text color from the theme (`TypographyColor`; the list is exported as `typographyColors`) |
39
39
 
40
40
  Typography.Body inherits all `Typography.Base` props.
41
41
 
@@ -45,7 +45,7 @@ Typography.Body inherits all `Typography.Base` props.
45
45
  |------|------|---------|-------------|
46
46
  | size | `'S' \| 'M' \| 'L'` | `'L'` | Inline code size |
47
47
  | variant | `'regular' \| 'semiBold'` | `'regular'` | Font weight variant |
48
- | color | `TypographyColor` | - | Theme typography color token |
48
+ | color | `'primary' \| 'secondary' \| 'notice' \| 'success' \| 'attention' \| 'danger' \| 'upsell' \| 'informative'` | - | Semantic text color from the theme (`TypographyColor`; the list is exported as `typographyColors`) |
49
49
 
50
50
  Typography.Code inherits all `Typography.Base` props and always renders as `<code>`.
51
51
 
@@ -54,7 +54,7 @@ Typography.Code inherits all `Typography.Base` props and always renders as `<cod
54
54
  | Prop | Type | Default | Description |
55
55
  |------|------|---------|-------------|
56
56
  | size | `'XXL' \| 'XL' \| 'L' \| 'M' \| 'S' \| 'XS'` | `'XL'` | Heading size and semantic level mapping |
57
- | color | `TypographyColor` | - | Theme typography color token |
57
+ | color | `'primary' \| 'secondary' \| 'notice' \| 'success' \| 'attention' \| 'danger' \| 'upsell' \| 'informative'` | - | Semantic text color from the theme (`TypographyColor`; the list is exported as `typographyColors`) |
58
58
  | variant | `'bold' \| 'semiBold'` | - | Font weight variant |
59
59
  | component | `'p' \| 'span' \| 'div' \| 'h1' \| 'h2' \| 'h3' \| 'h4' \| 'h5' \| 'h6'` | `'div'` | Element used to render the heading |
60
60