This guide explains how to consume the @ourfuturehealth/react-components package in your React applications.
- Node.js 20.19.0 or higher (Node.js 24 LTS recommended)
- pnpm (recommended) or npm as package manager
- A React application (React 19+ required)
Note: As of v4.0.0, this repository is a monorepo. The React components package is located in
packages/react-components/.
Currently, the React components are not published to npm registry. Install directly from GitHub:
pnpm add @ourfuturehealth/react-components@github:ourfuturehealth/design-system-toolkit#react-v0.4.0:packages/react-componentsnpm install @ourfuturehealth/react-components@github:ourfuturehealth/design-system-toolkit#react-v0.4.0:packages/react-components- Production: Use specific version tags (e.g.,
#react-v0.4.0) - Development: You can use
#main:packages/react-componentsbut ensure your lockfile pins a specific commit
package.json example:
{
"dependencies": {
"@ourfuturehealth/react-components": "github:ourfuturehealth/design-system-toolkit#react-v0.4.0:packages/react-components",
"react": "^19.2.4",
"react-dom": "^19.2.4"
}
}Import components and styles in your React application:
import React from 'react';
import { Button, TextInput } from '@ourfuturehealth/react-components';
import '@ourfuturehealth/react-components/styles/participant';
function App() {
return (
<div>
<TextInput
label="Your name"
hint="Enter your full name"
onChange={(e) => console.log(e.target.value)}
/>
<Button onClick={() => console.log('Clicked')}>Submit</Button>
</div>
);
}
export default App;Import the stylesheet once in your app's entry point:
// main.tsx or App.tsx
import '@ourfuturehealth/react-components/styles/participant';The styles are based on the Our Future Health design system toolkit and include all component styles.
Each application should use one theme. Current theme bundles are:
participantresearch
Use the participant styles export:
import '@ourfuturehealth/react-components/styles/participant';Use the matching themed styles export:
import '@ourfuturehealth/react-components/styles/research';For backward compatibility, @ourfuturehealth/react-components/styles remains available and maps to participant.
To add a new custom React theme stylesheet export, follow docs/theming/adding-a-new-theme.md.
The React components package currently provides the following components:
Button- Call-to-action buttons and linksTextInput- Text input fields with hint and error supportErrorSummary- Page-level validation summaries with linked errorsCard- Content presentation cards for summaries, status, and next stepsCardCallout- Feedback-style callout cards for informational, warning, success, and error messagesCardDoDont- Positive and negative recommendation lists
For complete component documentation and live examples, run Storybook:
pnpm storybookOr see the example consumer app for usage demonstrations.
The package includes full TypeScript definitions. No additional @types/ packages needed.
import type { ButtonProps } from '@ourfuturehealth/react-components';
const MyButton: React.FC<ButtonProps> = (props) => {
return <Button {...props} />;
};The React components work out of the box with Vite. No additional configuration needed.
// vite.config.ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [react()],
});If using Webpack, ensure you have appropriate loaders for CSS:
// webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
],
},
};Error: fatal: Could not read from remote repository
Solution: Ensure you have access to the GitHub repository. If it's a private repository, you may need to configure Git with your credentials or SSH key.
Error: Cannot find module '@ourfuturehealth/react-components'
Solution:
- Verify the package is installed:
ls node_modules/@ourfuturehealth/react-components - Run
pnpm installornpm installagain - Check your
package.jsonhas the correct syntax with:packages/react-componentssuffix
Error: Components appear unstyled
Solution: Ensure you import the styles:
import '@ourfuturehealth/react-components/styles/participant';Import this in your app's entry point (e.g., main.tsx or App.tsx).
Error: Warning: Invalid hook call or peer dependency warnings
Solution: The React components require React 19+. Update your React version:
pnpm add react@^19.2.4 react-dom@^19.2.4Error: Type definitions not found
Solution:
- Ensure
"moduleResolution": "bundler"or"moduleResolution": "node"is set in yourtsconfig.json - Run
pnpm installto ensure type definitions are properly linked
For development and contributing to the React components:
- Clone the repository
- Install dependencies:
pnpm install - Run Storybook:
pnpm storybook - Make changes in
packages/react-components/ - Run tests:
pnpm test:react-components - Lint code:
pnpm lint:react-components - Build all packages:
pnpm build
See the main README.md for detailed setup instructions and the contributing guide for guidelines.
The monorepo includes an example consumer app demonstrating usage:
# Run the example app
pnpm dev:react-consumerThe example app is located in packages/example-react-consumer-app/ and shows how to consume the React components in a real application.
- Check the Storybook for component examples
- Review the example consumer app
- Read the upgrade guide for migration instructions
- Open an issue on GitHub