### Getting Started with AddSelect Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products-web-components/src/components/add-select/add-select.mdx A complete example demonstrating how to set up and use the AddSelect component with multiple items. Includes import and HTML structure. ```javascript import '@carbon/ibm-products-web-components/es/components/add-select/index.js'; ``` ```html ``` -------------------------------- ### Run Development Server with Yarn Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/patterns/CreateTearsheet/example/README.md Execute this command to start the local development server for the example. ```bash yarn dev ``` -------------------------------- ### Standard CreateFullPage Example Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/patterns/CreateFullPage/CreateFullPage.mdx This example demonstrates the basic implementation of the CreateFullPage pattern for a standard multi-step workflow. ```jsx import React from 'react'; import { CreateFullPage } from '@carbon/ibm-products'; const App = () => { return ( {/* Steps and content go here */} ); }; export default App; ``` -------------------------------- ### Install @carbon/ibm-products with npm Source: https://github.com/carbon-design-system/ibm-products/blob/main/README.md Use this command to install the package if you prefer npm. ```bash npm install @carbon/ibm-products ``` -------------------------------- ### Install @carbon/ibm-products-web-components Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products-web-components/README.md Install the package using yarn or npm. This is the first step to using the web components. ```shell yarn add @carbon/ibm-products-web-components ``` ```shell npm install @carbon/ibm-products-web-components ``` -------------------------------- ### Create Full Page HTML Structure Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products-web-components/src/patterns/create-full-page/create-full-page.mdx Defines the HTML structure for the Create Full Page pattern, including steps, input fields, and configuration options. This example shows a basic setup with two steps: 'Partition' and 'Configuration'. ```html

Additional configuration options...

``` -------------------------------- ### Install @carbon/ibm-products Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/README.md Install the @carbon/ibm-products package using either yarn or npm. ```shell $ yarn add @carbon/ibm-products ``` ```shell $ npm install @carbon/ibm-products ``` -------------------------------- ### Install @carbon/ibm-products with Yarn Source: https://github.com/carbon-design-system/ibm-products/blob/main/README.md Use this command to install the package if you prefer Yarn. ```bash yarn add @carbon/ibm-products ``` -------------------------------- ### CreateFullPage with Sections Example Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/patterns/CreateFullPage/CreateFullPage.mdx This example shows how to organize form fields into logical sections within a step of the CreateFullPage pattern. ```jsx import React from 'react'; import { CreateFullPage, CreateFullPageStep } from '@carbon/ibm-products'; import { TextInput } from 'carbon-components-react'; const App = () => { return ( {/* Other steps */} ); }; export default App; ``` -------------------------------- ### Install Dependencies with Yarn Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/patterns/CreateTearsheet/example/README.md Use this command to install project dependencies before running the development server. ```bash yarn install ``` -------------------------------- ### Configure Example in gallery.config.json Source: https://github.com/carbon-design-system/ibm-products/blob/main/examples/carbon-for-ibm-products/APIKeyModal/README.md Use this JSON structure to define an example's label and package configuration, including component flags, feature flags, and template variations. All fields are optional, but a label is usually specified. ```json { "label": "Name of example in gallery", "package-config": { "flags": { "component": { "MyComponent": true }, "feature": { "MyFeature": true } "prefix": "alt-prefix", }, "templates-variation": "templates-react-16" } } ``` -------------------------------- ### Stackblitz Example with Animated Media Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/components/InlineTip/InlineTip.mdx This link directs to a Stackblitz example demonstrating the InlineTip component integrated with animated media. It's useful for seeing a practical, interactive implementation. ```html Example with animated media ``` -------------------------------- ### Set of Actions Example Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products-web-components/examples/set-of-actions/index.html Example demonstrating how to set actions data for a Set of Actions component. Ensure the 'actionsData' is imported and the target element is correctly selected. ```javascript import { actionsData } from './src/example-data.ts'; const setOfActions = document.getElementById('setOfActions'); setOfActions.actionsData = actionsData; ``` -------------------------------- ### Import Guide Banner Component Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products-web-components/src/components/guide-banner/guide-banner.mdx Import the Guide Banner component into your JavaScript project. ```javascript import '@carbon/ibm-products-web-components/es/components/guide-banner/index.js'; ``` -------------------------------- ### Guidebanner Collapsible Example Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/components/Guidebanner/Guidebanner.mdx Demonstrates the collapsible functionality of the Guidebanner component. This example shows the default behavior where the banner can be expanded or collapsed. ```javascript import { Story, Controls, Canvas } from '@storybook/addon-docs/blocks'; import { StackblitzLink } from '../../global/js/utils/story-helper'; import { Guidebanner } from '.'; import * as stories from './Guidebanner.stories'; ``` -------------------------------- ### CreateFullPage with Global Header Integration Example Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/patterns/CreateFullPage/CreateFullPage.mdx This example shows how the CreateFullPage pattern integrates with Carbon's global header and side navigation for a cohesive user experience. ```jsx import React from 'react'; import { CreateFullPage } from '@carbon/ibm-products'; import { Header, HeaderName, SideNav, SideNavItems, SideNavLink } from 'carbon-components-react'; const App = () => { return ( <>
Platform
Link 1
{/* Steps and content go here */}
); }; export default App; ``` -------------------------------- ### Install Playwright Browsers Source: https://github.com/carbon-design-system/ibm-products/blob/main/docs/e2e_testing.md Install the necessary browser binaries for Playwright to execute tests. This command should be run if it's the first time using Playwright in the project. ```bash yarn playwright install ``` -------------------------------- ### CreateFullPage with Header Example Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/patterns/CreateFullPage/CreateFullPage.mdx This example demonstrates how to include breadcrumbs and a page title in the header of the CreateFullPage pattern. ```jsx import React from 'react'; import { CreateFullPage, SimpleHeader } from '@carbon/ibm-products'; import { Breadcrumb, BreadcrumbItem } from 'carbon-components-react'; const App = () => { return ( Home} />} > {/* Steps and content go here */} ); }; export default App; ``` -------------------------------- ### Add Select Component Usage Example Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products-web-components/src/components/add-select/README.md Demonstrates how to use the c4p-add-select component with multiple items and search functionality. This example shows a multi-select configuration with predefined items. ```html ``` -------------------------------- ### Build and Run Storybook Locally Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products-web-components/README.md Install dependencies, build the project, and then run Storybook locally. This is useful for development and testing. ```shell yarn yarn build ``` ```shell yarn storybook-wc ``` -------------------------------- ### Install @carbon/ibm-products-styles with npm Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products-styles/README.md Use this command to add the styles package to your project using npm. ```shell npm install @carbon/ibm-products-styles ``` -------------------------------- ### Start Storybook Locally Source: https://github.com/carbon-design-system/ibm-products/blob/main/docs/e2e_testing.md Start the Storybook service locally. This is a prerequisite for running Playwright tests against components in `@carbon/ibm-products`. ```bash yarn yarn storybook ``` -------------------------------- ### CreateFullPage with Step in Error State Example Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/patterns/CreateFullPage/CreateFullPage.mdx This example illustrates how to handle and display errors within a step of the CreateFullPage pattern, indicating validation issues. ```jsx import React from 'react'; import { CreateFullPage, CreateFullPageStep } from '@carbon/ibm-products'; import { TextInput } from 'carbon-components-react'; const App = () => { return ( {/* Other steps */} ); }; export default App; ``` -------------------------------- ### Basic Guide Banner HTML Structure Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products-web-components/src/components/guide-banner/guide-banner.mdx Render a basic Guide Banner component with a title and a collapsible body. ```html
``` -------------------------------- ### Manual Saving Example Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/components/Saving/Saving.mdx Example of using the Saving component for manual saving. This is used when the user explicitly triggers the save action. ```javascript import { Story, Controls, Source, Canvas } from '@storybook/addon-docs/blocks'; import { CodesandboxLink, stackblitzHref, } from '../../global/js/utils/story-helper'; import { Saving } from '.'; import * as stories from './Saving.stories'; import { stackblitzPrefillConfig } from '../../../previewer/codePreviewer'; stackblitzPrefillConfig({ story: stories.Manual, styles: stories.default.parameters.styles, }), }, ]} /> ``` -------------------------------- ### Install @carbon/ibm-products-styles with Yarn Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products-styles/README.md Use this command to add the styles package to your project using Yarn. ```shell yarn add @carbon/ibm-products-styles ``` -------------------------------- ### Generate API Key Modal Example Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/patterns/GenerateAnAPIKey/GenerateAnAPIKey.mdx A React component example demonstrating the GenerateAnAPIKey pattern, handling both the input phase for a new key and the display of a generated key with download functionality. ```jsx {}} {...modalProps} > {key ? ( <>

API key successfully created

) : ( <>

(Optional description text) To connect securely to [product name], your application or tool needs an API key with permission to access resources such as [product resource name].

)}
``` -------------------------------- ### Basic InterstitialScreen Usage Example Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/components/InterstitialScreen/InterstitialScreen.mdx This example shows the basic structure of an InterstitialScreen with header, body, and footer components, including custom labels for footer buttons. ```jsx { return ( Step 1 content Step 2 content ); }} /> ``` -------------------------------- ### Tearsheet Header Configuration Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/components/Tearsheet/next/Tearsheet.mdx Example of configuring the header with actions and a navigation bar. ```jsx ... } > Any extra content like ProgressIndicator, notifications etc can go here } > ``` -------------------------------- ### Error Empty State with Action Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.mdx Configures the empty state to include a primary action button. Ideal for guiding users to resolve the empty state, e.g., by adding data. Requires Storybook setup. ```javascript import { Story, Controls, Source, Canvas } from '@storybook/addon-docs/blocks'; import * as stories from './ErrorEmptyState.stories'; import { stackblitzPrefillConfig } from '../../../../previewer/codePreviewer'; stackblitzPrefillConfig({ story: stories.withAction, }), }, ]} /> ``` -------------------------------- ### Build Project Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products-utilities/README.md Command to build the project. ```bash yarn build ``` -------------------------------- ### Component Folder Structure Example Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/AGENTS.md Illustrates the standard directory structure for components within `packages/ibm-products/src/components/`. This includes the main component file, stories, tests, and documentation. ```bash ComponentName/ ├── index.tsx // Re-exports ├── ComponentName.tsx // Main component ├── ComponentName.stories.js // Storybook stories ├── component-name-story.scss // Styling for storybook stories ├── ComponentName.mdx // Storybook mdx docs └── __tests__/ │ └── ComponentName-test.js // Unit tests └── docs/ └── overview.mdx // Demo file consumed by external documentation ``` -------------------------------- ### Build All Packages Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/README.md Run this command to build all the packages within the project. ```shell yarn build ``` -------------------------------- ### Import Preview components from @carbon/ibm-products Source: https://github.com/carbon-design-system/ibm-products/blob/main/README.md Import components with the 'preview__' prefix, which are production-ready but may have minor API changes. ```js import { preview__Coachmark } from '@carbon/ibm-products'; ``` -------------------------------- ### Install Storybook Addon for Carbon Themes Source: https://github.com/carbon-design-system/ibm-products/blob/main/config/storybook-addon-carbon-theme/README.md Install the addon using npm or yarn. This package is a dev dependency. ```sh npm install --save-dev @carbon/storybook-addon-theme yarn install --dev @carbon/storybook-addon-theme ``` -------------------------------- ### Import and Upload Storybook Setup Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/patterns/ImportAndUpload/ImportAndUpload.mdx Sets up Storybook for the Import and Upload pattern, including necessary imports from '@storybook/addon-docs/blocks' and local utility files. This is boilerplate for Storybook integration. ```javascript import { Story, Controls, Source, Canvas } from '@storybook/addon-docs/blocks'; import { CodesandboxLink } from '../../global/js/utils/story-helper'; import * as stories from './ImportAndUpload.stories'; ``` -------------------------------- ### Run Playwright Tests Source: https://github.com/carbon-design-system/ibm-products/blob/main/docs/e2e_testing.md Execute all Playwright end-to-end tests. Ensure Playwright browsers are installed via 'yarn playwright install'. ```bash yarn playwright test ``` -------------------------------- ### FullPageError Component - Stackblitz Example Link Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/components/FullPageError/FullPageError.mdx Provides a direct link to an interactive example of the FullPageError component on Stackblitz for further exploration and modification. ```html Stackblitz example ``` -------------------------------- ### Full Tearsheet Usage Example Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/components/Tearsheet/next/Tearsheet.mdx Provides a comprehensive example of the Tearsheet component structure including header actions, navigation, and content areas. ```jsx ... } > Any extra content like ProgressIndicator, notifications etc can go here }> This sticks to bottom of the header , so tablist, tags etc can be rendered here Rendered on the left, spanning the full height. Can be used to display a vertical progress indicator or similar elements. This is the main content area. // Rendered next to the main content area, this section can be used to display summary details or related information. Footer buttons can be rendered here ``` -------------------------------- ### Import Preview Candidate components from @carbon/ibm-products Source: https://github.com/carbon-design-system/ibm-products/blob/main/README.md Import components with the 'previewCandidate__' prefix, which are feature-complete and undergoing validation. ```js import { previewCandidate__Toolbar, previewCandidate__SearchBar, } from '@carbon/ibm-products'; ``` -------------------------------- ### Auto Saving Example Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/components/Saving/Saving.mdx Example of using the Saving component for automatic saving. This is typically used when the saving action is handled implicitly by the system. ```javascript import { Story, Controls, Source, Canvas } from '@storybook/addon-docs/blocks'; import { CodesandboxLink, stackblitzHref, } from '../../global/js/utils/story-helper'; import { Saving } from '.'; import * as stories from './Saving.stories'; import { stackblitzPrefillConfig } from '../../../previewer/codePreviewer'; stackblitzPrefillConfig({ story: stories.Auto, styles: stories.default.parameters.styles, }), }, ]} /> ``` -------------------------------- ### Example Release Candidate Announcement Source: https://github.com/carbon-design-system/ibm-products/blob/main/docs/guides/publishing-releases.md Use this template to announce a release candidate in the Slack channel. It includes details about what a release candidate is, a link to the changelog, and the staging environment. ```text :ibm-products::ibm-products::ibm-products::ibm-products::ibm-products::ibm-products::ibm-products: Hi all! Release candidate v2.45.0-rc.0 of `@carbon/ibm-products` has been created and is ready for testing! What is a release candidate? Before releasing a full version (ie. v2.45.0), we publish prerelease versions / release candidates for testing purposes. This helps to prevent any major bugs making their way to our full versions. If you find any issues with this release candidate, you can report any issues here: https://github.com/carbon-design-system/ibm-products/issues/new/choose. Changelog: https://github.com/carbon-design-system/ibm-products/releases/tag/%40carbon%2Fibm-products%402.45.0-rc.0 Storybook environment for react (Staging): https://carbon-design-system.github.io/ibm-products/staging/react/ ``` -------------------------------- ### CoachmarkFixed Example Usage Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/components/CoachmarkFixed/CoachmarkFixed.mdx Renders the CoachmarkFixed component within a div for example usage. This snippet is typically used within a Storybook Canvas. ```javascript
``` -------------------------------- ### TagSet Component - Many Tags Example Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/components/TagSet/TagSet.mdx Example usage of the TagSet component with more than 10 tags. This showcases how the component handles a larger number of tags. ```javascript import { Story, Controls, Source, Canvas } from '@storybook/addon-docs/blocks'; import { CodesandboxLink } from '../../global/js/utils/story-helper'; import { TagSet } from '.'; import * as stories from './TagSet.stories'; ``` -------------------------------- ### Basic Create Tearsheet Narrow Example Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/patterns/CreateTearsheetNarrow/CreateTearsheet.mdx Demonstrates the fundamental structure of the Create Tearsheet Narrow pattern. Includes a button to open the tearsheet and the Tearsheet component itself with header, body, and footer configurations. ```html
setOpen(false)} preventCloseOnClickOutside >

Core configuration

We recommend you fill out and evaluate these details at a minimum before deploying your topic.

setTopicName(e.target.value)} /> setPartitionCount(e.imaginaryTarget.value)} />
``` -------------------------------- ### TagSet Component - Hundreds of Tags Example Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/components/TagSet/TagSet.mdx Example usage of the TagSet component with hundreds of tags. This configuration includes a searchable modal to display all tags effectively. ```javascript import { Story, Controls, Source, Canvas } from '@storybook/addon-docs/blocks'; import { CodesandboxLink } from '../../global/js/utils/story-helper'; import { TagSet } from '.'; import * as stories from './TagSet.stories'; ``` -------------------------------- ### TagSet Component - Five Tags Example Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/components/TagSet/TagSet.mdx Example usage of the TagSet component with five tags, demonstrating no overflow. Adjust 'max-visible' to observe overflow behavior. ```javascript import { Story, Controls, Source, Canvas } from '@storybook/addon-docs/blocks'; import { CodesandboxLink } from '../../global/js/utils/story-helper'; import { TagSet } from '.'; import * as stories from './TagSet.stories'; ``` -------------------------------- ### Configure Storybook Preview File with Global Decorator Source: https://github.com/carbon-design-system/ibm-products/blob/main/config/storybook-addon-carbon-theme/README.md Set up the global decorator and default theme in your Storybook preview file (`.storybook/preview.js`). This enables the theme switching functionality and sets an initial theme. ```javascript import { withCarbonTheme } from '@carbon/storybook-addon-theme/withCarbonTheme'; import { PARAM_KEY as CARBON_THEME_PARAM_KEY, CARBON_THEMES, } from '@carbon/storybook-addon-theme/constants'; const decorators = [ /// other decorators... withCarbonTheme, ]; const globals = { // other globals... // default value of the theme selector [CARBON_THEME_PARAM_KEY]: CARBON_THEMES.g10, }; export { decorators, globals }; ``` -------------------------------- ### Guidebanner Few Insights Example Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/components/Guidebanner/Guidebanner.mdx Shows the Guidebanner component configured to display a limited number of insights. This is useful for pages with concise introductory information. ```javascript import { Story, Controls, Canvas } from '@storybook/addon-docs/blocks'; import { StackblitzLink } from '../../global/js/utils/story-helper'; import { Guidebanner } from '.'; import * as stories from './Guidebanner.stories'; ``` -------------------------------- ### Import Preview Candidate Components Source: https://github.com/carbon-design-system/ibm-products/blob/main/docs/guides/COMPONENT_STATUS_DEFINITIONS.md Use the 'previewCandidate__' prefix for components that are candidates for preview. These require careful consideration before use. ```typescript // Use previewCandidate__ prefix import { previewCandidate__Toolbar, previewCandidate__SearchBar, } from '@carbon/ibm-products'; ``` -------------------------------- ### Configure Storybook Main File Source: https://github.com/carbon-design-system/ibm-products/blob/main/config/storybook-addon-carbon-theme/README.md Add the theme addon preset to your Storybook's main configuration file (`.storybook/main.js`). ```javascript module.exports = { // other addons... addons: ['@carbon/storybook-addon-theme/preset.js'], }; ``` -------------------------------- ### Import Preview Components Source: https://github.com/carbon-design-system/ibm-products/blob/main/docs/guides/COMPONENT_STATUS_DEFINITIONS.md Use the 'preview__' prefix when importing components that are in preview. These are not yet production-ready. ```typescript // Use preview__ prefix import { preview__PageHeader, preview__Coachmark } from '@carbon/ibm-products'; ``` -------------------------------- ### Initializing the Carousel Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/patterns/Carousel/Carousel.mdx Demonstrates how to initialize the carousel component with basic configuration and event handlers. ```APIDOC ## initCarousel(container, config) ### Description Initializes a carousel on the specified container element. ### Parameters #### Path Parameters * **container** (HTMLElement) - Required - The container element that holds the carousel items * **config** (Object) - Optional - Configuration options * **onViewChangeStart** (Function) - Callback fired when transition starts * **onViewChangeEnd** (Function) - Callback fired when transition completes * **excludeSwipeSupport** (Boolean) - Disable swipe gesture support (default: `false`) * **useMaxHeight** (Boolean) - Use maximum item height instead of minimum (default: `false`) ### Returns Object with methods: * `next()`: Navigate to the next item * `prev()`: Navigate to the previous item (or back in history for ViewStack) * `goToIndex(index)`: Navigate to a specific index * `reset()`: Reset to the first item * `getActiveItem()`: Get the currently active item * `destroyEvents()`: Clean up event listeners ### Callback Response Both `onViewChangeStart` and `onViewChangeEnd` receive an object with: * `currentIndex` (Number): Index of the current item * `lastIndex` (Number): Index of the last item * `totalViews` (Number): Total number of items * `historyStack` (Array): Array of history entries with `{id, title}` objects ``` -------------------------------- ### Example Import Transformation Source: https://github.com/carbon-design-system/ibm-products/blob/main/docs/guides/CANARY_MIGRATION_GUIDE.md Illustrates how the automated tool transforms non-stable component imports by adding PDLC status prefixes and preserving local variable names with aliases. ```javascript // Before import { Toolbar, SearchBar, InlineTip } from '@carbon/ibm-products'; // After import { previewCandidate__Toolbar as Toolbar, previewCandidate__SearchBar as SearchBar, previewCandidate__InlineTip as InlineTip, } from '@carbon/ibm-products'; ``` -------------------------------- ### Import all @carbon/ibm-products styles Source: https://github.com/carbon-design-system/ibm-products/blob/main/README.md Include all styles, including Carbon and experimental styles, by using this import statement. ```scss @use '@carbon/ibm-products/css/index.min.css'; ``` -------------------------------- ### Example Usage of useOverflowItems Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/global/js/hooks/useOverflowItems/useOverflowItems.mdx Demonstrates how to use the useOverflowItems hook in a React component. ```APIDOC ## Example Usage of useOverflowItems ### Description This section shows a typical usage pattern for the `useOverflowItems` hook within a React component. ### Method ```jsx const { visibleItems, hiddenItems, itemRefHandler, offsetRefHandler } = useOverflowItems(items, containerRef, offsetRef, maxVisible, onChange); ``` ### Parameters - **items** (Array) - The array of items to be managed. - **containerRef** (RefObject) - A ref to the container element. - **offsetRef** (RefObject) - An optional ref to an offset element. - **maxVisible** (number) - The maximum number of items to display. - **onChange** (Function) - A callback function for when the visible items change. ### Returns - **visibleItems** (Array) - Items that are currently visible. - **hiddenItems** (Array) - Items that are hidden due to overflow. - **itemRefHandler** (Function) - Handler to attach refs to individual items. - **offsetRefHandler** (Function) - Handler to attach refs to the offset element. ``` -------------------------------- ### Get All Descendant IDs Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products-utilities/src/utils/add-select/add-select-data.md Retrieve an array of all IDs belonging to an item and its descendants. ```typescript const allIds = dataManager.getAllDescendantIds('parent-id'); ``` -------------------------------- ### Guidebanner Many Insights Example Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/components/Guidebanner/Guidebanner.mdx Illustrates the Guidebanner component when displaying a large number of insights. This configuration is suitable for pages with extensive introductory content. ```javascript import { Story, Controls, Canvas } from '@storybook/addon-docs/blocks'; import { StackblitzLink } from '../../global/js/utils/story-helper'; import { Guidebanner } from '.'; import * as stories from './Guidebanner.stories'; ``` -------------------------------- ### Basic Tearsheet Preview Implementation Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products-web-components/src/components/tearsheet-preview/tearsheet.mdx A standard implementation featuring a header, body content with form inputs, and a footer with action buttons. ```html
description
Cancel Create
``` -------------------------------- ### DateTimeFormat Usage Example Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products/src/patterns/DateTimeFormat/DateTimeFormat.mdx Displays the standard implementation of the dateTimeFormat utility via Storybook. ```javascript ``` -------------------------------- ### Get All Descendants Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products-utilities/src/utils/add-select/add-select-data.md Retrieve all items that are descendants of a given item, including children and grandchildren. ```typescript const descendants = dataManager.getItemDescendants('parent-id'); ``` -------------------------------- ### Initialize Set of Tags Component Source: https://github.com/carbon-design-system/ibm-products/blob/main/packages/ibm-products-web-components/examples/set-of-tags/index.html Import example data and assign it to the tagsData property of the Set of Tags component. Ensure the component is present in the DOM. ```javascript import { tagsData } from './src/example-data.ts'; const setOfTags = document.getElementById('setOfTags'); setOfTags.tagsData = tagsData; ``` -------------------------------- ### Import Stable components from @carbon/ibm-products Source: https://github.com/carbon-design-system/ibm-products/blob/main/README.md Import production-ready components that have no prefix. ```js import { PageHeader, SidePanel, Tearsheet } from '@carbon/ibm-products'; ```