@redis-ui/components 51.4.0 → 51.5.0

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.
@@ -12,11 +12,12 @@ const require_Header = require("./components/Header/Header.cjs");
12
12
  const require_ScrollContainer = require("./components/ScrollContainer/ScrollContainer.cjs");
13
13
  const require_Footer = require("./components/Footer/Footer.cjs");
14
14
  const require_Group = require("./components/Group/Group.cjs");
15
+ const require_CollapseButton = require("./components/CollapseButton/CollapseButton.cjs");
15
16
  let _redislabsdev_redis_ui_styles = require("@redis-ui/styles");
16
17
  let react_jsx_runtime = require("react/jsx-runtime");
17
18
  let react = require("react");
18
19
  //#region src/SideBar/SideBar.tsx
19
- var SideBar = Object.assign(({ isExpanded, expandedWidth, ...rest }) => {
20
+ var SideBar = Object.assign(({ isExpanded, expandedWidth, showActiveIndicator = true, ...rest }) => {
20
21
  const [transitionEnd, setTransitionEnd] = (0, react.useState)(true);
21
22
  const prefersReducedMotion = (0, _redislabsdev_redis_ui_styles.usePrefersReducedMotion)();
22
23
  const sidebarId = require_index.useId();
@@ -28,6 +29,7 @@ var SideBar = Object.assign(({ isExpanded, expandedWidth, ...rest }) => {
28
29
  transitionEnd,
29
30
  handleTransitionChange,
30
31
  isExpanded,
32
+ showActiveIndicator,
31
33
  sidebarId
32
34
  },
33
35
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Provider.default, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SideBar_style.SideBarContainer, {
@@ -53,7 +55,8 @@ var SideBar = Object.assign(({ isExpanded, expandedWidth, ...rest }) => {
53
55
  Button: require_Button.default,
54
56
  Header: require_Header.default,
55
57
  Footer: require_Footer.default,
56
- Group: require_Group.default
58
+ Group: require_Group.default,
59
+ CollapseButton: require_CollapseButton.default
57
60
  });
58
61
  //#endregion
59
62
  exports.default = SideBar;
@@ -1,5 +1,5 @@
1
1
  import { SideBarProps } from './SideBar.types';
2
- declare const SideBar: (({ isExpanded, expandedWidth, ...rest }: SideBarProps) => import("react/jsx-runtime").JSX.Element) & {
2
+ declare const SideBar: (({ isExpanded, expandedWidth, showActiveIndicator, ...rest }: SideBarProps) => import("react/jsx-runtime").JSX.Element) & {
3
3
  SideBarLogo: ({ logoIcon: LogoIcon, ...restProps }: import("./components/SideBarLogo/SideBarLogo.types").SideBarLogoProps) => import("react/jsx-runtime").JSX.Element;
4
4
  ItemsContainer: (props: import("./components/ItemsContainer/ItemsContainer.types").SideBarItemsContainerProps) => import("react/jsx-runtime").JSX.Element;
5
5
  ScrollContainer: (props: import("./components/ScrollContainer/ScrollContainer.types").SideBarScrollContainerProps) => import("react/jsx-runtime").JSX.Element;
@@ -21,5 +21,6 @@ declare const SideBar: (({ isExpanded, expandedWidth, ...rest }: SideBarProps) =
21
21
  Group: ((props: import("./components/Group/Group.types").SideBarGroupProps) => import("react/jsx-runtime").JSX.Element) & {
22
22
  Title: ({ children, ...rest }: import("./components/Group/components/Title/Title.types").SideBarGroupTitleProps) => import("react/jsx-runtime").JSX.Element;
23
23
  };
24
+ CollapseButton: ({ onToggle, icon, collapseText, expandText, ...rest }: import("./components/CollapseButton/CollapseButton.types").SideBarCollapseButtonProps) => import("react/jsx-runtime").JSX.Element;
24
25
  };
25
26
  export default SideBar;
@@ -12,11 +12,12 @@ import Header from "./components/Header/Header.js";
12
12
  import ScrollContainer from "./components/ScrollContainer/ScrollContainer.js";
13
13
  import Footer from "./components/Footer/Footer.js";
14
14
  import Group from "./components/Group/Group.js";
15
+ import CollapseButton from "./components/CollapseButton/CollapseButton.js";
15
16
  import { usePrefersReducedMotion } from "@redis-ui/styles";
16
17
  import { jsx } from "react/jsx-runtime";
17
18
  import { useState } from "react";
18
19
  //#region src/SideBar/SideBar.tsx
19
- var SideBar = Object.assign(({ isExpanded, expandedWidth, ...rest }) => {
20
+ var SideBar = Object.assign(({ isExpanded, expandedWidth, showActiveIndicator = true, ...rest }) => {
20
21
  const [transitionEnd, setTransitionEnd] = useState(true);
21
22
  const prefersReducedMotion = usePrefersReducedMotion();
22
23
  const sidebarId = useId();
@@ -28,6 +29,7 @@ var SideBar = Object.assign(({ isExpanded, expandedWidth, ...rest }) => {
28
29
  transitionEnd,
29
30
  handleTransitionChange,
30
31
  isExpanded,
32
+ showActiveIndicator,
31
33
  sidebarId
32
34
  },
33
35
  children: /* @__PURE__ */ jsx(Provider, { children: /* @__PURE__ */ jsx(SideBarContainer, {
@@ -53,7 +55,8 @@ var SideBar = Object.assign(({ isExpanded, expandedWidth, ...rest }) => {
53
55
  Button,
54
56
  Header,
55
57
  Footer,
56
- Group
58
+ Group,
59
+ CollapseButton
57
60
  });
58
61
  //#endregion
59
62
  export { SideBar as default };
@@ -3,9 +3,12 @@ import { FlexGroupProps } from '../Layouts';
3
3
  export interface SideBarProps extends Omit<FlexGroupProps, 'direction'> {
4
4
  isExpanded: boolean;
5
5
  expandedWidth?: string;
6
+ /** Shows the line next to the active item. The active item keeps its background either way. */
7
+ showActiveIndicator?: boolean;
6
8
  }
7
9
  export interface SideBarContextProps {
8
10
  isExpanded: boolean;
11
+ showActiveIndicator: boolean;
9
12
  transitionEnd: boolean;
10
13
  handleTransitionChange: (end: boolean) => void;
11
14
  sidebarId: string;
@@ -0,0 +1,32 @@
1
+ const require_Tooltip = require("../../../Tooltip/Tooltip.cjs");
2
+ const require_ScreenReaderAnnounce = require("../../../ScreenReaderAnnounce/ScreenReaderAnnounce.cjs");
3
+ const require_SideBar_context = require("../../SideBar.context.cjs");
4
+ const require_Icon = require("../Item/components/Icon/Icon.cjs");
5
+ const require_Text = require("../Item/components/Text/Text.cjs");
6
+ const require_Item_style = require("../Item/Item.style.cjs");
7
+ const require_CollapseButton_style = require("./CollapseButton.style.cjs");
8
+ let react_jsx_runtime = require("react/jsx-runtime");
9
+ //#region src/SideBar/components/CollapseButton/CollapseButton.tsx
10
+ var CollapseButton = ({ onToggle, icon, collapseText = "Collapse", expandText = "Expand sidebar", ...rest }) => {
11
+ const { isExpanded, handleTransitionChange, sidebarId } = require_SideBar_context.useSideBarContext();
12
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_CollapseButton_style.Container, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Tooltip.default, {
13
+ placement: "right",
14
+ disabled: isExpanded,
15
+ content: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Item_style.TooltipContent, { children: expandText }),
16
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_CollapseButton_style.CollapseButton, {
17
+ as: "button",
18
+ type: "button",
19
+ "aria-label": isExpanded ? void 0 : expandText,
20
+ "aria-controls": sidebarId,
21
+ "aria-expanded": isExpanded,
22
+ ...rest,
23
+ onClick: () => {
24
+ handleTransitionChange(false);
25
+ onToggle();
26
+ },
27
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Icon.default, { icon }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Text.default, { children: collapseText })]
28
+ })
29
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ScreenReaderAnnounce.ScreenReaderAnnounce, { text: isExpanded ? "Sidebar expanded" : "Sidebar collapsed" })] });
30
+ };
31
+ //#endregion
32
+ exports.default = CollapseButton;
@@ -0,0 +1,3 @@
1
+ import { SideBarCollapseButtonProps } from './CollapseButton.types';
2
+ declare const CollapseButton: ({ onToggle, icon, collapseText, expandText, ...rest }: SideBarCollapseButtonProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default CollapseButton;
@@ -0,0 +1,32 @@
1
+ import Tooltip from "../../../Tooltip/Tooltip.js";
2
+ import { ScreenReaderAnnounce } from "../../../ScreenReaderAnnounce/ScreenReaderAnnounce.js";
3
+ import { useSideBarContext } from "../../SideBar.context.js";
4
+ import Icon from "../Item/components/Icon/Icon.js";
5
+ import Text from "../Item/components/Text/Text.js";
6
+ import { TooltipContent } from "../Item/Item.style.js";
7
+ import { CollapseButton as CollapseButton$1, Container } from "./CollapseButton.style.js";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ //#region src/SideBar/components/CollapseButton/CollapseButton.tsx
10
+ var CollapseButton = ({ onToggle, icon, collapseText = "Collapse", expandText = "Expand sidebar", ...rest }) => {
11
+ const { isExpanded, handleTransitionChange, sidebarId } = useSideBarContext();
12
+ return /* @__PURE__ */ jsxs(Container, { children: [/* @__PURE__ */ jsx(Tooltip, {
13
+ placement: "right",
14
+ disabled: isExpanded,
15
+ content: /* @__PURE__ */ jsx(TooltipContent, { children: expandText }),
16
+ children: /* @__PURE__ */ jsxs(CollapseButton$1, {
17
+ as: "button",
18
+ type: "button",
19
+ "aria-label": isExpanded ? void 0 : expandText,
20
+ "aria-controls": sidebarId,
21
+ "aria-expanded": isExpanded,
22
+ ...rest,
23
+ onClick: () => {
24
+ handleTransitionChange(false);
25
+ onToggle();
26
+ },
27
+ children: [/* @__PURE__ */ jsx(Icon, { icon }), /* @__PURE__ */ jsx(Text, { children: collapseText })]
28
+ })
29
+ }), /* @__PURE__ */ jsx(ScreenReaderAnnounce, { text: isExpanded ? "Sidebar expanded" : "Sidebar collapsed" })] });
30
+ };
31
+ //#endregion
32
+ export { CollapseButton as default };
@@ -0,0 +1,16 @@
1
+ const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
2
+ const require_Item_style = require("../Item/Item.style.cjs");
3
+ let styled_components = require("styled-components");
4
+ styled_components = require_runtime.__toESM(styled_components, 1);
5
+ //#region src/SideBar/components/CollapseButton/CollapseButton.style.ts
6
+ var Container = styled_components.default.div.withConfig({
7
+ displayName: "CollapseButtonstyle__Container",
8
+ componentId: "RedisUI__sc-1ukbtbz-0"
9
+ })(["display:flex;flex-direction:column;flex:none;"]);
10
+ var CollapseButton = (0, styled_components.default)(require_Item_style.SideBarItem).withConfig({
11
+ displayName: "CollapseButtonstyle__CollapseButton",
12
+ componentId: "RedisUI__sc-1ukbtbz-1"
13
+ })(["border:0;font:inherit;text-align:start;"]);
14
+ //#endregion
15
+ exports.CollapseButton = CollapseButton;
16
+ exports.Container = Container;
@@ -0,0 +1,4 @@
1
+ export declare const Container: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export declare const CollapseButton: import("styled-components").StyledComponent<"li", any, {
3
+ $hasActiveIndicator?: boolean;
4
+ }, never>;
@@ -0,0 +1,13 @@
1
+ import { SideBarItem } from "../Item/Item.style.js";
2
+ import _styled from "styled-components";
3
+ //#region src/SideBar/components/CollapseButton/CollapseButton.style.ts
4
+ var Container = _styled.div.withConfig({
5
+ displayName: "CollapseButtonstyle__Container",
6
+ componentId: "RedisUI__sc-1ukbtbz-0"
7
+ })(["display:flex;flex-direction:column;flex:none;"]);
8
+ var CollapseButton = _styled(SideBarItem).withConfig({
9
+ displayName: "CollapseButtonstyle__CollapseButton",
10
+ componentId: "RedisUI__sc-1ukbtbz-1"
11
+ })(["border:0;font:inherit;text-align:start;"]);
12
+ //#endregion
13
+ export { CollapseButton, Container };
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { IconType } from '@redis-ui/icons';
3
+ export interface SideBarCollapseButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'> {
4
+ onToggle: () => void;
5
+ icon: IconType;
6
+ collapseText?: string;
7
+ expandText?: string;
8
+ }
@@ -10,7 +10,7 @@ let react = require("react");
10
10
  //#region src/SideBar/components/Item/Item.tsx
11
11
  var Item = Object.assign(({ tooltipProps, isActive = false, onKeyDown, ...restProps }) => {
12
12
  const itemRef = (0, react.useRef)(null);
13
- const { isExpanded } = require_SideBar_context.useSideBarContext();
13
+ const { isExpanded, showActiveIndicator } = require_SideBar_context.useSideBarContext();
14
14
  const activeLinkAttributes = isActive ? {
15
15
  "data-state": "active",
16
16
  "aria-current": "page"
@@ -29,7 +29,8 @@ var Item = Object.assign(({ tooltipProps, isActive = false, onKeyDown, ...restPr
29
29
  ...activeLinkAttributes,
30
30
  tabIndex,
31
31
  onKeyDown: handleKeyDown,
32
- ref: itemRef
32
+ ref: itemRef,
33
+ $hasActiveIndicator: showActiveIndicator
33
34
  });
34
35
  return isExpanded ? item : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Tooltip.default, {
35
36
  ...tooltipProps,
@@ -10,7 +10,7 @@ import { useRef } from "react";
10
10
  //#region src/SideBar/components/Item/Item.tsx
11
11
  var Item = Object.assign(({ tooltipProps, isActive = false, onKeyDown, ...restProps }) => {
12
12
  const itemRef = useRef(null);
13
- const { isExpanded } = useSideBarContext();
13
+ const { isExpanded, showActiveIndicator } = useSideBarContext();
14
14
  const activeLinkAttributes = isActive ? {
15
15
  "data-state": "active",
16
16
  "aria-current": "page"
@@ -29,7 +29,8 @@ var Item = Object.assign(({ tooltipProps, isActive = false, onKeyDown, ...restPr
29
29
  ...activeLinkAttributes,
30
30
  tabIndex,
31
31
  onKeyDown: handleKeyDown,
32
- ref: itemRef
32
+ ref: itemRef,
33
+ $hasActiveIndicator: showActiveIndicator
33
34
  });
34
35
  return isExpanded ? item : /* @__PURE__ */ jsx(Tooltip, {
35
36
  ...tooltipProps,
@@ -17,7 +17,7 @@ var SideBarItem = styled_components.default.li.withConfig({
17
17
  ";outline-offset:-",
18
18
  ";}",
19
19
  ";& > svg{transition:inherit;}"
20
- ], () => (0, _redislabsdev_redis_ui_styles.useTheme)().core.focus.size, () => (0, _redislabsdev_redis_ui_styles.useTheme)().core.focus.color, () => (0, _redislabsdev_redis_ui_styles.useTheme)().core.focus.size, () => {
20
+ ], () => (0, _redislabsdev_redis_ui_styles.useTheme)().core.focus.size, () => (0, _redislabsdev_redis_ui_styles.useTheme)().core.focus.color, () => (0, _redislabsdev_redis_ui_styles.useTheme)().core.focus.size, ({ $hasActiveIndicator = true }) => {
21
21
  return require_SideBar_utils.useStateStyle(({ item: theme }, state) => {
22
22
  const { states } = theme;
23
23
  return styled_components.css`
@@ -55,16 +55,18 @@ var SideBarItem = styled_components.default.li.withConfig({
55
55
  })}
56
56
  }
57
57
 
58
- &[data-state='active']::before {
59
- content: '';
60
- position: absolute;
61
- left: ${require_SideBar_constants.SIDEBAR_CONSTANTS.item.activeIndicator.left};
62
- top: ${require_SideBar_constants.SIDEBAR_CONSTANTS.item.activeIndicator.top};
63
- bottom: ${require_SideBar_constants.SIDEBAR_CONSTANTS.item.activeIndicator.bottom};
64
- width: ${require_SideBar_constants.SIDEBAR_CONSTANTS.item.activeIndicator.width};
65
- background-color: ${theme.activeIndicator.bgColor};
66
- border-radius: ${require_SideBar_constants.SIDEBAR_CONSTANTS.item.activeIndicator.borderRadius};
67
- }
58
+ ${$hasActiveIndicator && styled_components.css`
59
+ &[data-state='active']::before {
60
+ content: '';
61
+ position: absolute;
62
+ left: ${require_SideBar_constants.SIDEBAR_CONSTANTS.item.activeIndicator.left};
63
+ top: ${require_SideBar_constants.SIDEBAR_CONSTANTS.item.activeIndicator.top};
64
+ bottom: ${require_SideBar_constants.SIDEBAR_CONSTANTS.item.activeIndicator.bottom};
65
+ width: ${require_SideBar_constants.SIDEBAR_CONSTANTS.item.activeIndicator.width};
66
+ background-color: ${theme.activeIndicator.bgColor};
67
+ border-radius: ${require_SideBar_constants.SIDEBAR_CONSTANTS.item.activeIndicator.borderRadius};
68
+ }
69
+ `}
68
70
  `;
69
71
  });
70
72
  });
@@ -1,2 +1,4 @@
1
- export declare const SideBarItem: import("styled-components").StyledComponent<"li", any, {}, never>;
1
+ export declare const SideBarItem: import("styled-components").StyledComponent<"li", any, {
2
+ $hasActiveIndicator?: boolean;
3
+ }, never>;
2
4
  export declare const TooltipContent: import("styled-components").StyledComponent<(props: import("../../..").TypographyBodyProps) => import("react/jsx-runtime").JSX.Element, any, {}, never>;
@@ -15,7 +15,7 @@ var SideBarItem = _styled.li.withConfig({
15
15
  ";outline-offset:-",
16
16
  ";}",
17
17
  ";& > svg{transition:inherit;}"
18
- ], () => useTheme().core.focus.size, () => useTheme().core.focus.color, () => useTheme().core.focus.size, () => {
18
+ ], () => useTheme().core.focus.size, () => useTheme().core.focus.color, () => useTheme().core.focus.size, ({ $hasActiveIndicator = true }) => {
19
19
  return useStateStyle(({ item: theme }, state) => {
20
20
  const { states } = theme;
21
21
  return css`
@@ -53,16 +53,18 @@ var SideBarItem = _styled.li.withConfig({
53
53
  })}
54
54
  }
55
55
 
56
- &[data-state='active']::before {
57
- content: '';
58
- position: absolute;
59
- left: ${SIDEBAR_CONSTANTS.item.activeIndicator.left};
60
- top: ${SIDEBAR_CONSTANTS.item.activeIndicator.top};
61
- bottom: ${SIDEBAR_CONSTANTS.item.activeIndicator.bottom};
62
- width: ${SIDEBAR_CONSTANTS.item.activeIndicator.width};
63
- background-color: ${theme.activeIndicator.bgColor};
64
- border-radius: ${SIDEBAR_CONSTANTS.item.activeIndicator.borderRadius};
65
- }
56
+ ${$hasActiveIndicator && css`
57
+ &[data-state='active']::before {
58
+ content: '';
59
+ position: absolute;
60
+ left: ${SIDEBAR_CONSTANTS.item.activeIndicator.left};
61
+ top: ${SIDEBAR_CONSTANTS.item.activeIndicator.top};
62
+ bottom: ${SIDEBAR_CONSTANTS.item.activeIndicator.bottom};
63
+ width: ${SIDEBAR_CONSTANTS.item.activeIndicator.width};
64
+ background-color: ${theme.activeIndicator.bgColor};
65
+ border-radius: ${SIDEBAR_CONSTANTS.item.activeIndicator.borderRadius};
66
+ }
67
+ `}
66
68
  `;
67
69
  });
68
70
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@redis-ui/components",
3
3
  "license": "UNLICENSED",
4
- "version": "51.4.0",
4
+ "version": "51.5.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "repository": "git@github.com:redislabsdev/redis-ui.git",
@@ -14,6 +14,7 @@ import { SideBar } from '@redis-ui/components';
14
14
  |------|------|---------|-------------|
15
15
  | isExpanded | `boolean` | *required* | Controls whether the sidebar is expanded or collapsed |
16
16
  | expandedWidth | `string` | design-system default | Overrides the sidebar width when expanded |
17
+ | showActiveIndicator | `boolean` | `true` | Shows the line next to the active item. The active item keeps its background either way |
17
18
 
18
19
  The component also accepts all `FlexGroupProps` except `direction`, which is fixed to a vertical sidebar layout.
19
20
 
@@ -37,6 +38,7 @@ The component also accepts all `FlexGroupProps` except `direction`, which is fix
37
38
  - `SideBar.Footer.MetaData` - Footer metadata container.
38
39
  - `SideBar.Footer.Link` - Footer link rendered as body text.
39
40
  - `SideBar.Footer.Text` - Small footer text.
41
+ - `SideBar.CollapseButton` - Full-width expand/collapse toggle styled like an item, for use in the footer instead of `SideBar.Header`.
40
42
 
41
43
  ### SideBar.Header Props
42
44
 
@@ -123,6 +125,17 @@ The group title also accepts standard `HTMLAttributes<HTMLDivElement>` except `c
123
125
  The root button also inherits all `ButtonProps` from the base `Button` component.
124
126
  The tooltip text is used as the collapsed label and tooltip placement defaults to `right`.
125
127
 
128
+ ### SideBar.CollapseButton Props
129
+
130
+ | Prop | Type | Default | Description |
131
+ |------|------|---------|-------------|
132
+ | onToggle | `() => void` | *required* | Called when the button is pressed |
133
+ | icon | `IconType` | *required* | Icon shown in both states, typically `PanelLeftIcon` (requires `@redis-ui/icons` 10.3.0 or later) |
134
+ | collapseText | `string` | `'Collapse'` | Label shown while the sidebar is expanded |
135
+ | expandText | `string` | `'Expand sidebar'` | Accessible name and tooltip while the sidebar is collapsed |
136
+
137
+ The button also accepts standard `ButtonHTMLAttributes<HTMLButtonElement>` except `onClick`.
138
+
126
139
  ### SideBar.Footer Props
127
140
 
128
141
  This footer wrapper inherits `ComposeElementProps`.
@@ -329,6 +342,53 @@ const [activeLink, setActiveLink] = useState(groups[0].items[0].content);
329
342
  </SideBar>
330
343
  ```
331
344
 
345
+ ### CollapseButtonAtBottom
346
+
347
+ > Without `SideBar.Header`, `SideBar.CollapseButton` in the footer takes over the expand/collapse toggle.
348
+ > `showActiveIndicator={false}` drops the line next to the active item and keeps its background.
349
+
350
+ ```tsx
351
+ import { SideBar } from '@redis-ui/components';
352
+ import { PanelLeftIcon } from '@redis-ui/icons';
353
+ import { useState } from 'react';
354
+ import { groups } from './SideBar.data';
355
+
356
+ const [expanded, setExpanded] = useState(true);
357
+ const [activeLink, setActiveLink] = useState(groups[0].items[0].content);
358
+
359
+ <SideBar
360
+ isExpanded={expanded}
361
+ expandedWidth="24rem"
362
+ showActiveIndicator={false}
363
+ style={{ paddingTop: '1rem' }}
364
+ >
365
+ <SideBar.ScrollContainer>
366
+ {groups.map((group, groupIdx) => (
367
+ <SideBar.Group key={group.title ?? `group-${groupIdx}`}>
368
+ {group.title && <SideBar.Group.Title>{group.title}</SideBar.Group.Title>}
369
+ <SideBar.ItemsContainer>
370
+ {group.items.map((item) => (
371
+ <SideBar.Item
372
+ isActive={item.content === activeLink}
373
+ onClick={() => setActiveLink(item.content)}
374
+ key={item.content}
375
+ tooltipProps={{ text: item.content, placement: 'right' }}
376
+ >
377
+ <SideBar.Item.Icon icon={item.icon} />
378
+ <SideBar.Item.Text>{item.content}</SideBar.Item.Text>
379
+ </SideBar.Item>
380
+ ))}
381
+ </SideBar.ItemsContainer>
382
+ </SideBar.Group>
383
+ ))}
384
+ </SideBar.ScrollContainer>
385
+ <SideBar.Footer>
386
+ <SideBar.Divider fullWidth noMargin />
387
+ <SideBar.CollapseButton icon={PanelLeftIcon} onToggle={() => setExpanded(!expanded)} />
388
+ </SideBar.Footer>
389
+ </SideBar>
390
+ ```
391
+
332
392
  ### HeaderAndFooter
333
393
 
334
394
  > `Header` includes toggle button and. Set `onToggle` handler to switch expanded state.