@redis-ui/components 51.9.2 → 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
|
@@ -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
|
|
|
@@ -29,7 +29,7 @@ import { RedisLogoDarkMinIcon } from '@redis-ui/icons/multicolor';
|
|
|
29
29
|
|
|
30
30
|
## Setup and themes
|
|
31
31
|
|
|
32
|
-
An app needs this once, at its root. Without the theme provider components render incorrectly, and without `TooltipProvider` every `Tooltip` (and components that render tooltips, such as `MoreInfoIcon`, `Chip`, `KeyValueList`) throws.
|
|
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
33
|
|
|
34
34
|
```tsx
|
|
35
35
|
import 'modern-normalize/modern-normalize.css';
|
|
@@ -65,13 +65,19 @@ Before adding providers, check whether the app already mounts them (they usually
|
|
|
65
65
|
```tsx
|
|
66
66
|
import styled from 'styled-components';
|
|
67
67
|
import { useTheme } from '@redis-ui/styles';
|
|
68
|
+
import { Typography } from '@redis-ui/components';
|
|
68
69
|
|
|
69
70
|
const Panel = styled.div`
|
|
70
71
|
padding: ${({ theme }) => theme.core.space.space400};
|
|
71
72
|
background: ${({ theme }) => theme.semantic.color.background.neutral100};
|
|
72
73
|
`;
|
|
73
74
|
|
|
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
|
+
};
|
|
75
81
|
```
|
|
76
82
|
|
|
77
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).
|