@trops/dash-react
v1.0.33
Published
A Dashboard Generator Package.
Readme
dash-react
dash-react is a React UI component library for building dashboards. It provides a curated set of reusable components, theming support, and essential hooks for dashboard applications.
What's Included
- Core UI Components: Button, Panel, Modal, Menu, Container, and more
- Layout Components: LayoutContainer, MainLayout, Workspace, Widget
- Context Hooks: ThemeContext, WidgetContext for component communication
- Theming: Built-in theme tokens and customization via Tailwind CSS
- Utilities: Colors, strings, CSS helpers, and other shared utilities
Requirements
- Node.js + npm
Installation
npm installCommon Commands
npm run storybook
npm run build-storybook
npm run build
npm run build:css
npm run prodMaintainer Guide
Updating Components
Edit component files under:
src/Common/- Core UI components (Button, Panel, Modal, etc.)src/Layout/- Layout primitives (LayoutContainer, etc.)src/Context/- Context providers (ThemeContext, WidgetContext)src/Utils/- Helper utilities (colors, strings, CSS utilities)
If Tailwind styles change, rebuild CSS:
npm run build:cssTesting Components with Storybook
View component changes interactively:
npm run storybookBuild static Storybook for CI/deployment:
npm run build-storybookPublishing Updates
To release a new version:
npm version patch # or minor/major
npm run prod # Builds and creates package
git push origin mainComponent Overview
Layout Components
LayoutContainer- Flexible row/column container for dashboard layoutsMainLayout/MainSection/MainContent- Page-level layout structureContainer- Generic container with spacing utilitiesHeader/SubHeader/Footer- Header and footer sectionsPanel- Styled card/panel containerDashPanel- Dashboard-specific panel wrapper
Interactive Components
Button/ButtonIcon- Action buttonsMenu/MenuItem- Dropdown and list menusToggle- Toggle switch inputModal- Modal overlay dialogsSlidePanelOverlay- Side panel overlayTag- Label/tag component
Feedback & Layout
Notification/NotificationCancel- Alert notificationsErrorBoundary/ErrorMessage- Error handling UIWidget- Base widget wrapperWorkspace- Widget container with context support
Content & Utilities
CodeEditor/CodeRenderer- Code input and displayForm- Form input utilitiesText- Typography helpersDraggable- Drag-and-drop helpers
Theming
Components use ThemeContext to access theme tokens:
import { useTheme } from "@dash/Context";
const MyComponent = () => {
const { currentTheme } = useTheme();
return <div className={currentTheme["bg-primary"]}>{/* ... */}</div>;
};Available theme tokens:
bg-*- Background colors (primary, secondary, danger, etc.)text-*- Text colorsborder-*- Border colors- Variants:
very-light,light,medium,dark,very-dark
Styling Components
Override component styles with common props:
<Panel
backgroundColor="bg-blue-100"
borderColor="border-blue-300"
padding="p-6"
/>Using Context Hooks
The library provides two context hooks:
// Access theme tokens and colors
import { useTheme } from "@dash/Context";
const { currentTheme } = useTheme();
// Access widget instance metadata (when inside a widget)
import { useWidgetContext } from "@dash/Context";
const { uuid, selectedProviders } = useWidgetContext();Documentation
For component library documentation, see docs/INDEX.md.
Using dash-react in an application?
- See the @trops/dash Electron dashboard application for a complete example
- Dash Documentation - Widget development, provider system, and application architecture
Support
For questions or issues: [email protected]
