You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The configuration of the UI package is handled by the `@medusajs/admin` package. Therefore, you do not need to any additional configuration to use the UI package in your Admin extensions.
88430
88430
88431
88431
88432
-
# Standalone Project
88432
+
# Medusa UI Installation in Standalone Projects
88433
88433
88434
-
How to install and use Medusa UI in a standalone project.
88434
+
Learn how to install and use Medusa UI in a standalone project.
88435
88435
88436
-
## Installation
88436
+
Medusa UI is a React UI library that, while intended for usage within Medusa projects, can also be used in any React project.
88437
88437
88438
-
***
88438
+
The icons package is installed independently from Medusa UI. Learn how to install it in the [Icons](../icons/overview.mdx) guide.
88439
88439
88440
-
Medusa UI is a React UI library and while it's intended for usage within Medusa projects, it can also be used in any React project.
88440
+
## Medusa UI Compatibility
88441
88441
88442
-
### Install Medusa UI
88442
+
To use Medusa UI in your standalone project, you must have:
88443
88443
88444
-
Install the React UI library with the following command:
88444
+
- React 18+ installed. Most React-based frameworks and libraries, such as Next.js and Vite, are compatible with this requirement.
88445
+
- [Tailwind CSS](https://v3.tailwindcss.com/) installed. The components in Medusa UI are styled using Tailwind CSS, so you will need to install it in your project as well.
88446
+
- Medusa UI was built with Tailwind CSS v3, but it may generally support v4 as well.
88447
+
88448
+
***
88449
+
88450
+
## Step 1: Install Medusa UI
88451
+
88452
+
In your standalone project, install the Medusa UI package with the following command:
88445
88453
88446
88454
```bash
88447
88455
npm install @medusajs/ui
88448
88456
```
88449
88457
88450
-
### Configuring Tailwind CSS
88458
+
***
88459
+
88460
+
## Step 2: Install UI Presets
88451
88461
88452
-
The components are styled using Tailwind CSS, and in order to use them, you will need to install Tailwind CSS in your project as well.
88453
-
For more information on how to install Tailwind CSS, please refer to the [Tailwind CSS documentation](https://tailwindcss.com/docs/installation).
88462
+
Medusa UI customizes Tailwind CSS classes to implement its design system. So, you must also install the Medusa UI preset package.
88454
88463
88455
-
All of the classes used for Medusa UI are shipped as a Tailwind CSS customization.
88456
-
You can install it with the following command:
88464
+
To install the Medusa UI preset, run the following command:
88457
88465
88458
88466
```bash
88459
88467
npm install @medusajs/ui-preset
88460
88468
```
88461
88469
88462
-
After you have installed Tailwind CSS and the Medusa UI preset, you need to add the following to your `tailwind.config.js`file:
88470
+
***
88463
88471
88464
-
```tsx
88465
-
module.exports = {
88466
-
presets: [require("@medusajs/ui-preset")],
88467
-
// ...
88468
-
}
88469
-
```
88472
+
## Step 3: Configure Tailwind CSS
88470
88473
88471
-
In order for the styles to be applied correctly to the components, you will also need to ensure that
88472
-
`@medusajs/ui` is included in the content field of your `tailwind.config.js` file:
88474
+
Next, you'll need to configure Tailwind CSS to use the Medusa UI preset and explicitly add the paths to the Medusa UI components as content files.
88473
88475
88474
-
```tsx
88476
+
### Tailwind CSS v3 Configurations
88477
+
88478
+
In Tailwind CSS v3, which is the recommended version to use with Medusa UI, you need to add the following configurations to your `tailwind.config.js` or `tailwind.config.ts` file:
88479
+
88480
+
1. Add the Medusa UI preset to the `presets` array.
88481
+
2. Ensure that the `content` field includes the path to the Medusa UI package.
Medusa UI isn't officially compatible with Tailwind CSS v4 yet, so use it with caution.
88519
+
88520
+
In your CSS file that imports Tailwind CSS, add the following `@config` and `@source` directives:
88521
+
88522
+
```css
88523
+
@import "tailwindcss";
88524
+
@source "../node_modules/@medusajs/ui";
88525
+
@config "@medusajs/ui-preset";
88526
+
```
88527
+
88528
+
This will explicitly include the Medusa UI preset and its components in your Tailwind CSS build, and will apply the preset styles to your project.
88506
88529
88507
88530
***
88508
88531
88509
-
You are now ready to start building your application with Medusa UI. You can import the components like so:
88532
+
## Step 4: Use Medusa UI in Standalone Projects
88533
+
88534
+
You can now start building your application with Medusa UI.
88535
+
88536
+
For example, you can use the `Button` in your custom components:
88510
88537
88511
88538
```tsx
88512
-
import { Button, Drawer } from "@medusajs/ui"
88539
+
import { Button } from "@medusajs/ui"
88540
+
88541
+
export function ButtonDemo() {
88542
+
return <Button>Button</Button>
88543
+
}
88513
88544
```
88514
88545
88515
-
## Updating UI Packages
88546
+
Refer to the documentation of each component to learn about its props and usage.
88516
88547
88517
88548
***
88518
88549
88519
-
Medusa's design-system packages, including `@medusajs/ui`, `@medusajs/ui-preset`, and `@medusajs/ui-icons`, are versioned independently. However, they're still part of the latest Medusa release. So, you can browse the [release notes](https://github.com/medusajs/medusa/releases) to see if there are any breaking changes to these packages.
88550
+
## Update UI Packages in Standalone Projects
88520
88551
88521
-
To update these packages, update their version in your `package.json` file and re-install dependencies. For example:
88552
+
Medusa's design-system packages, including `@medusajs/ui` and `@medusajs/ui-preset`, are versioned independently from other `@medusajs/*` packages. However, they're still released as part of Medusa's releases.
88522
88553
88523
-
```bash
88524
-
npm install @medusajs/ui
88554
+
So, to find latest updates and breaking changes to any of these packages, refer to the [release notes in the Medusa GitHub repository](https://github.com/medusajs/medusa/releases).
88555
+
88556
+
To update these packages in your standalone project, update their version in your `package.json` file and re-install dependencies. For example:
0 commit comments