Documentation menu
Getting Started
Components
Primitives
- Agent Thinking
- Alert
- Alert Dialog
- Avatar
- Badge
- Breadcrumb
- Button
- Button Group
- Calendar
- Card
- Checkbox
- Command
- Command Palette
- Context Menu
- Data Table
- Dialog
- Dropdown Menu
- Empty
- Field
- Glow Cloud
- Input
- Label
- Medication Schedule
- Period Tabs
- Popover
- Rainbow Button
- Scroll Area
- Select
- Selectable Card
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Tag
- Textarea
- Timeline
- Tooltip
- Use Count Up
Charts and metrics
Patterns
- Confirm Button
- Date Picker
- Embedded
- Empty State
- Entity Drawer
- Error Boundary
- Field Row
- File Dropzone
- Form Dialog
- Kv
- List Editor
- List Page
- Live Time
- Mini Table
- Money
- Note Field
- Note Text
- Page Card
- Page Header
- Page Tabs
- Page Toolbar
- Person Cell
- Picture Field
- Print Card
- Range Switcher
- Row Actions
- Search Input
- Search Select
- Selected Box
- Signature Pad
- Status Badge
- Sub Nav Layout
- Suggest Input
- Tab Icons
- Table Footer
- Theme Accent Picker
- Time Picker
- View All Link
Dashboard cards
Advanced
Device frames
Website widgets
Website screens
Website panels
Patterns
Error Boundary
Catches errors in one screen so it never blanks the whole app.
import { ErrorBoundary } from "@/registry/vcare/ui/error-boundary"
function Broken(): never {
throw new Error("Example error")
}
export default function ErrorBoundaryDemo() {
return (
<ErrorBoundary>
<Broken />
</ErrorBoundary>
)
}Installation
npx shadcn@latest add @vcare/error-boundaryOr install directly from the URL: https://ui.vcarehms.com/r/error-boundary.json
- Add the registry items it uses: button, i18n.
- Copy this file into your project and change the
@/registry/vcare/…imports to your own paths.
components/ui/error-boundary.tsx
import { Component, type ErrorInfo, type ReactNode } from 'react';
import { useTranslation } from '@/registry/vcare/lib/i18n';
import { Button } from '@/registry/vcare/ui/button';
function Fallback({ error, reset }: { error: Error; reset: () => void }) {
const { t } = useTranslation();
return (
<div role="alert" className="grid flex-1 place-items-center p-6 text-center">
<div className="flex max-w-md flex-col items-center space-y-3">
<p className="text-base font-bold">{t('errors.generic')}</p>
<p className="break-words text-xs text-muted-foreground" data-testid="render-error">
{error.message}
</p>
<Button variant="secondary" onClick={reset}>
{t('refresh')}
</Button>
</div>
</div>
);
}
/** Catches render errors in a screen so one broken page never blanks the whole app. */
export class ErrorBoundary extends Component<{ children: ReactNode; resetKey?: string }, { error: Error | null }> {
state = { error: null as Error | null };
static getDerivedStateFromError(error: Error) {
return { error };
}
componentDidCatch(error: Error, info: ErrorInfo) {
console.error('render error', error, info.componentStack);
}
componentDidUpdate(prev: { resetKey?: string }) {
if (prev.resetKey !== this.props.resetKey && this.state.error) this.setState({ error: null });
}
render() {
return this.state.error ? <Fallback error={this.state.error} reset={() => this.setState({ error: null })} /> : this.props.children;
}
}Usage
import { ErrorBoundary } from "@/components/ui/error-boundary"Exports
ErrorBoundary
Dependencies
@vcare/button(registry)@vcare/i18n(registry)
Raw item: /r/error-boundary.json