This guide documents the UI components and design patterns used in the Remitlend frontend.
- Framework: Next.js 16 (App Router)
- Styling: Tailwind CSS
- Icons: Lucide React
- State Management: Zustand (stores)
- API Fetching: Custom
useApihook
Located in frontend/src/app/components/ui, these are atomic components used throughout the application.
Our primary interaction element.
- Props:
variant("primary", "secondary", "outline", "ghost"),size("sm", "md", "lg"),isLoading. - Usage:
import { Button } from "@/components/ui/Button"; <Button variant="primary" onClick={handleMint}> Mint NFT </Button>
Used for grouping content, dashboard widgets, and loan details.
- Props:
title,description,footer,content.
Standard dialog for user confirmations and forms.
- Usage: Controlled via a boolean state.
Located in frontend/src/app/components/global_ui.
- Sidebar: Main navigation for the application.
- Header: Contains the wallet connection button and user profile info.
- DashboardShell: A layout wrapper that includes the Sidebar and Header.
We use a custom useApi hook to handle all interactions with the backend and contract data.
const { data, loading, error, request } = useApi<{ score: number }>();
useEffect(() => {
request({ url: "/api/score/123", method: "GET" });
}, []);- Loading State: Automatically managed.
- Error Handling: Standardized error reporting.
- Caching: Currently uses basic local state (consider React Query for larger apps).
- Mobile First: All layouts must be responsive and work on small screens first.
- Accessible (A11y): Use semantic HTML and appropriate ARIA labels.
- Consistent Spacing: Use Tailwind's standard spacing units (e.g.,
p-4,m-2). - Dark Mode Support: Use Tailwind's
dark:classes for all components.
src/app/components: Reusable UI components.src/app/hooks: Custom React hooks.src/app/stores: Global state management with Zustand.src/app/ui-demo: Examples of using core UI components.