120k

React Router

Install and configure Force UI for React Router.

For Force UI component installs, set REGISTRY_URL to https://forceui.public.prd.shared.perforce.com/r-react before running CLI commands. See the Force UI registry guide for preset and framework-specific setup.

Choose the setup that matches your starting point.

Use shadcn/create

Build Your Preset

Open shadcn/create and build your preset visually. Choose your style, colors, fonts, icons, and more.

Open shadcn/create

Create Project

Click Create Project, choose your package manager, and copy the generated command.

The generated command will look similar to this:

pnpm dlx shadcn@latest init --preset [CODE] --template react-router

The exact command will include your selected options such as --base, --monorepo, or --rtl.

Add Components

Add the Card component to your project:

pnpm dlx shadcn@latest add @force-ui/card

If you created a monorepo, run the command from apps/web or specify the workspace from the repo root:

pnpm dlx shadcn@latest add @force-ui/card -c apps/web

The command above will add the Card component to your project. You can then import it like this:

app/routes/home.tsx
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "~/components/ui/card"
 
export default function Home() {
  return (
    <Card className="max-w-sm">
      <CardHeader>
        <CardTitle>Project Overview</CardTitle>
        <CardDescription>
          Track progress and recent activity for your React Router app.
        </CardDescription>
      </CardHeader>
      <CardContent>
        Your design system is ready. Start building your next component.
      </CardContent>
    </Card>
  )
}

If you created a monorepo, update apps/web/app/routes/home.tsx and import from @workspace/ui/components/card instead.

Use the CLI

Create Project

Run the init command to scaffold a new React Router project. Follow the prompts to configure your project: base, preset, monorepo, and more.

pnpm dlx shadcn@latest init -t react-router

For a monorepo project, use --monorepo flag:

pnpm dlx shadcn@latest init -t react-router --monorepo

Add Components

Add the Card component to your project:

pnpm dlx shadcn@latest add @force-ui/card

If you created a monorepo, run the command from apps/web or specify the workspace from the repo root:

pnpm dlx shadcn@latest add @force-ui/card -c apps/web

The command above will add the Card component to your project. You can then import it like this:

app/routes/home.tsx
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "~/components/ui/card"
 
export default function Home() {
  return (
    <Card className="max-w-sm">
      <CardHeader>
        <CardTitle>Project Overview</CardTitle>
        <CardDescription>
          Track progress and recent activity for your React Router app.
        </CardDescription>
      </CardHeader>
      <CardContent>
        Your design system is ready. Start building your next component.
      </CardContent>
    </Card>
  )
}

If you created a monorepo, update apps/web/app/routes/home.tsx and import from @workspace/ui/components/card instead.

Existing Project

Create Project

If you need a new React Router project, create one first. Otherwise, skip this step.

pnpm create react-router@latest

create-react-router already configures Tailwind CSS and the default ~/* import alias for you. If you're adding Force UI to an older or custom React Router app, make sure both are configured before continuing.

Run the CLI

Run the shadcn init command to set up Force UI in your project.

pnpm dlx shadcn@latest init

Add Components

You can now start adding components to your project.

pnpm dlx shadcn@latest add @force-ui/button

The command above will add the Button component to your project. You can then import it like this:

app/routes/home.tsx
import { Button } from "~/components/ui/button"
 
export default function Home() {
  return (
    <div className="flex min-h-svh flex-col items-center justify-center">
      <Button>Click me</Button>
    </div>
  )
}