A generic, reusable PatternFly component library providing a customizable widget-based dashboard with drag-and-drop functionality.
- Node.js 18 or higher
- Yarn 4.10.3 or higher (recommended) or npm
- React 18 (peer dependency)
- React DOM 18 (peer dependency)
yarn add @patternfly/widgetized-dashboardOr with npm:
npm install @patternfly/widgetized-dashboardThis library requires React 18+ and React DOM 18+ as peer dependencies. Make sure these are installed in your project:
yarn add react@^18 react-dom@^18import React from 'react';
import { WidgetLayout, WidgetMapping, ExtendedTemplateConfig } from '@patternfly/widgetized-dashboard';
import { CubeIcon } from '@patternfly/react-icons';
// Define your widgets
const widgetMapping: WidgetMapping = {
'example-widget': {
defaults: { w: 2, h: 3, maxH: 6, minH: 2 },
config: {
title: 'Example Widget',
icon: <CubeIcon />
},
renderWidget: (id) => <div>Widget content goes here</div>
}
};
// Define initial layout (or load from API/localStorage)
const initialTemplate: ExtendedTemplateConfig = {
xl: [
{ i: 'example-widget#1', x: 0, y: 0, w: 2, h: 3, widgetType: 'example-widget', title: 'Example Widget' }
],
lg: [
{ i: 'example-widget#1', x: 0, y: 0, w: 2, h: 3, widgetType: 'example-widget', title: 'Example Widget' }
],
md: [
{ i: 'example-widget#1', x: 0, y: 0, w: 2, h: 3, widgetType: 'example-widget', title: 'Example Widget' }
],
sm: [
{ i: 'example-widget#1', x: 0, y: 0, w: 1, h: 3, widgetType: 'example-widget', title: 'Example Widget' }
]
};
function App() {
return (
<WidgetLayout
widgetMapping={widgetMapping}
initialTemplate={initialTemplate}
onTemplateChange={(template) => {
// Save template to API or localStorage
console.log('Template changed:', template);
}}
/>
);
}- Basic Example - Complete dashboard with drawer
- Locked Layout Example - Dashboard with locked widgets
- Without Drawer Example - Grid layout without widget drawer
The main component that provides the complete dashboard experience with grid layout and widget drawer.
The core layout engine with drag-and-drop functionality (can be used standalone).
The widget selection drawer (can be used standalone with GridLayout).
Individual widget tile wrapper with actions menu (used internally by GridLayout).
-
Clone the repository:
git clone https://github.com/patternfly/widgetized-dashboard.git cd widgetized-dashboard -
Install dependencies:
yarn install
-
Start the development server:
yarn start
This will build the library and start the documentation site at http://localhost:8003
yarn build- Run unit tests:
yarn test - Run linter:
yarn lint - Lint JavaScript:
yarn lint:js - Lint Markdown:
yarn lint:md
- Build the docs:
yarn build:docs - Serve the docs:
yarn serve:docs - In a new terminal window, run:
yarn test:a11y - View the generated report:
yarn serve:a11y
We welcome contributions! Please follow the guidelines below when contributing to this project.
- Follow PatternFly naming conventions
- Include TypeScript definitions for all components and props
- Write unit tests using React Testing Library
- Add documentation examples in
packages/module/patternfly-docs/content/examples/ - Follow the existing code style and linting rules
- Ensure all tests pass before submitting a pull request
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes with appropriate tests
- Run
yarn lintandyarn testto ensure code quality - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a pull request
Please reference PatternFly's AI-assisted development guidelines if you'd like to contribute code generated using AI.
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: GitHub Issues
- Source: GitHub Repository