Skip to main content

React

CareOS components are plain React components written in TypeScript. They work with React 18 and 19, in Vite, Create React App, Next.js, Remix and any bundler that handles ESM or CommonJS. The package has no runtime dependencies besides React.

1. Install​

npm install health-components

2. Load the styles once​

src/main.tsx
import 'health-components/styles.css'; // tokens for all five themes + component styles
import 'health-components/fonts.css'; // optional: Roboto from Google Fonts (or self-host it)

All CareOS CSS is scoped: classes start with co-, variables with --co-. It does not restyle your existing elements.

3. Wrap the app in a theme​

src/App.tsx
import { ThemeProvider, PatientBanner, Button, Card } from 'health-components';

export function App() {
return (
<ThemeProvider theme="classic">
<PatientBanner name="Henna West" sex="F" age={38} dob="03/14/1988" mrn="MRN-100231" allergies={['Penicillin']} />
<Card title="Claim lines">
<Button variant="primary" iconLeft="plus">
Add Line
</Button>
</Card>
</ThemeProvider>
);
}

ThemeProvider sets data-co-theme and the base type on a wrapper. You can instead put class="co-root" data-co-theme="classic" on <html> or <body>. Without either, components still render in the default Classic theme.

TypeScript​

Every component exports its props type (ButtonProps, DataTableColumn<T>, MenuItem, ...). Props are documented in JSDoc, so your editor shows meaning and defaults on hover.

import { DataTable, type DataTableColumn } from 'health-components';

type Claim = { id: string; patient: string; amount: number };
const columns: DataTableColumn<Claim>[] = [
{ key: 'patient', label: 'Patient', sortable: true },
{ key: 'amount', label: 'Amount', align: 'right' },
];

Controlled and uncontrolled​

Anything a user changes (a value, an open menu, a selected tab, a sort) works uncontrolled with defaultX, or controlled with x plus its change handler:

const [tab, setTab] = useState('summary');
<Tabs value={tab} onChange={setTab} items={[...]} />;

Overlays​

Modal, Drawer, SuccessDialog and CommandPalette render at the end of <body> through a portal, trap focus, lock page scroll, close on Escape and return focus when they close. They keep the theme of the nearest ThemeProvider.

Toasts​

import { ToastProvider, useToast } from 'health-components';

function SaveButton() {
const toast = useToast();
return <Button onClick={() => toast.show('Draft Saved Successfully')}>Save Draft</Button>;
}

<ToastProvider>
<SaveButton />
</ToastProvider>;

Tokens in JavaScript​

import { tokens, colorValue, tokenVar } from 'health-components/tokens';

colorValue('primary', 'rail'); // '#3B4FD8'
tokenVar('radius-md'); // 'var(--co-radius-md)'