Last checked with Wasp 0.21 and Radix Themes 3.
This guide depends on external libraries or services, so it may become outdated over time. We do our best to keep it up to date, but make sure to check their documentation for any changes.Radix Themes
This guide shows you how to integrate the Radix Themes component library into your Wasp application.
Setting up Radix Themesโ
1. Install Radix Themesโ
Install the Radix Themes package:
npm install @radix-ui/themes
2. Create a Root Component if it doesn't existโ
Due to how Radix works, we'll need to have a single component that wraps all the pages in our app. In Wasp, this is done through the rootComponent configuration:
app MyApp {
wasp: {
version: "^0.21.0"
},
title: "My App",
client: {
rootComponent: import { Layout } from "@src/Layout",
}
}
If you already have a root component in your Wasp app, open that file and skip to the next step. If you don't have one, create a new file with an empty component that will serve as the root:
- JavaScript
- TypeScript
export function Layout({ children }) {
return children;
}
import type { ReactNode } from "react";
export function Layout({ children }: { children?: ReactNode }) {
return children;
}
3. Add Radix Themes to your root componentโ
In your root component, we'll wrap the children with Radix Theme's Theme component, and import their CSS stylesheet:
- JavaScript
- TypeScript
import "@radix-ui/themes/styles.css";
import { Theme } from "@radix-ui/themes";
export function Layout({ children }) {
return <Theme>{children}</Theme>;
}
import type { ReactNode } from "react";
import "@radix-ui/themes/styles.css";
import { Theme } from "@radix-ui/themes";
export function Layout({ children }: { children?: ReactNode }) {
return <Theme>{children}</Theme>;
}
4. Use Radix Themes componentsโ
Now you can use Radix Themes components anywhere in your application:
- JavaScript
- TypeScript
import { Flex, Text, Button } from "@radix-ui/themes";
export const MainPage = () => {
return (
<Flex direction="column" gap="2">
<Text>Hello from Radix Themes :)</Text>
<Button>Let's go</Button>
</Flex>
);
};
import { Flex, Text, Button } from "@radix-ui/themes";
export const MainPage = () => {
return (
<Flex direction="column" gap="2">
<Text>Hello from Radix Themes :)</Text>
<Button>Let's go</Button>
</Flex>
);
};
That's it!
Customizing the themeโ
You can customize the theme by passing props to the Theme component:
- JavaScript
- TypeScript
import "@radix-ui/themes/styles.css";
import { Theme } from "@radix-ui/themes";
export function Layout({ children }) {
return (
<Theme accentColor="crimson" grayColor="sand" radius="large" scaling="95%">
{children}
</Theme>
);
}
import type { ReactNode } from "react";
import "@radix-ui/themes/styles.css";
import { Theme } from "@radix-ui/themes";
export function Layout({ children }: { children?: ReactNode }) {
return (
<Theme accentColor="crimson" grayColor="sand" radius="large" scaling="95%">
{children}
</Theme>
);
}
See the Radix Themes documentation for more customization options.