The App UI Kit is a React-based component library for Canva apps. If you're using the starter kit, the App UI Kit is already set up for you. If you're not using the starter kit, this guide will help you get started.
Step 1: Install the App UI Kit
In the project's directory, run the following command:
npm install @canva/app-ui-kit
bash
Step 2: Set up the AppUiProvider
At the root of the application, such as in a project's index.tsx
file:
-
Import the following stylesheet:
import "@canva/app-ui-kit/styles.css";tsx -
Import the
AppUiProvider
component:import { AppUiProvider } from "@canva/app-ui-kit";tsxThis component provides theming and user preferences to App UI Kit components.
-
Wrap the app in the
AppUiProvider
component:<AppUiProvider><App /></AppUiProvider>tsx
Step 3: Start using the components
-
Import components from the
@canva/app-ui-kit
package:import { Button, Rows, Text, Title } from "@canva/app-ui-kit";tsx -
Use them as you would any other React component:
export function App() {return (<Rows spacing="2u"><Rows spacing="1u"><Title>Hello world</Title><Text>This is a paragraph of text.</Text></Rows><Button variant="primary">Click me</Button></Rows>);}tsx
Next steps
Once you're up and running, either:
- Check out the Storybook to explore the available components.
- Play around with the components in your app.