diff --git a/.github/workflows/docs-test.yml b/.github/workflows/docs-test.yml
index d4745003eb..18ce3af969 100644
--- a/.github/workflows/docs-test.yml
+++ b/.github/workflows/docs-test.yml
@@ -260,7 +260,7 @@ jobs:
- name: Get Directories to Scan
if: ${{ steps.pr-files.outputs.files_lt_threshold == 'true' }}
working-directory: www/vale
- run: ./get-files.sh ui/src/content/docs
+ run: ./get-files.sh ui/app
id: directories
- name: Vale Linter
diff --git a/www/.gitignore b/www/.gitignore
index 8fe0088654..9cdc392f1e 100644
--- a/www/.gitignore
+++ b/www/.gitignore
@@ -8,4 +8,5 @@ node_modules
!.yarn/releases
!.yarn/sdks
!.yarn/versions
-.env.local
\ No newline at end of file
+.env.local
+ui-old
\ No newline at end of file
diff --git a/www/apps/api-reference/next.config.mjs b/www/apps/api-reference/next.config.mjs
index 2807418302..d19e939794 100644
--- a/www/apps/api-reference/next.config.mjs
+++ b/www/apps/api-reference/next.config.mjs
@@ -50,7 +50,6 @@ const withMDX = createMDX({
},
ui: {
projectPath: path.resolve("..", "ui"),
- contentPath: "src/content/docs",
},
"user-guide": {
projectPath: path.resolve("..", "user-guide"),
diff --git a/www/apps/book/app/learn/resources/contribution-guidelines/docs/page.mdx b/www/apps/book/app/learn/resources/contribution-guidelines/docs/page.mdx
index 3664f7ba3c..eb16f35f3c 100644
--- a/www/apps/book/app/learn/resources/contribution-guidelines/docs/page.mdx
+++ b/www/apps/book/app/learn/resources/contribution-guidelines/docs/page.mdx
@@ -98,11 +98,11 @@ The API reference's content is split into two types:
### Medusa UI Documentation
-The content of the Medusa UI documentation are located under the `www/apps/ui/src/content/docs` directory. They are MDX files.
+The content of the Medusa UI documentation are located under the `www/apps/ui/app` directory. They are MDX files.
-The UI documentation also shows code examples, which are under the `www/apps/ui/src/examples` directory.
+The UI documentation also shows code examples, which are under the `www/apps/ui/specs/examples` directory.
-The UI component props are generated from the source code and placed into the `www/apps/ui/src/specs` directory. To contribute to these props and their comments, check the comments in the source code under the `packages/design-system/ui` directory.
+The UI component props are generated from the source code and placed into the `www/apps/ui/specs/components` directory. To contribute to these props and their comments, check the comments in the source code under the `packages/design-system/ui` directory.
---
@@ -195,7 +195,7 @@ cd www/vale
# to lint content for the API reference
./run-vale.sh api-reference/markdown error
# to lint content for the Medusa UI documentation
-./run-vale.sh ui/src/content/docs error
+./run-vale.sh ui/app error
# to lint content for the user guide
./run-vale.sh user-guide/app error
```
diff --git a/www/apps/book/generated/edit-dates.mjs b/www/apps/book/generated/edit-dates.mjs
index a34ca19f53..de0bb23b4c 100644
--- a/www/apps/book/generated/edit-dates.mjs
+++ b/www/apps/book/generated/edit-dates.mjs
@@ -109,7 +109,7 @@ export const generatedEditDates = {
"app/learn/fundamentals/api-routes/parse-body/page.mdx": "2025-04-17T08:29:10.145Z",
"app/learn/fundamentals/admin/routing/page.mdx": "2025-07-25T07:35:18.038Z",
"app/learn/resources/contribution-guidelines/admin-translations/page.mdx": "2025-02-11T16:57:46.726Z",
- "app/learn/resources/contribution-guidelines/docs/page.mdx": "2025-05-26T15:55:02.974Z",
+ "app/learn/resources/contribution-guidelines/docs/page.mdx": "2025-08-20T06:41:30.822Z",
"app/learn/resources/usage/page.mdx": "2025-02-26T13:35:34.824Z",
"app/learn/configurations/medusa-config/page.mdx": "2025-07-14T09:28:54.302Z",
"app/learn/configurations/ts-aliases/page.mdx": "2025-07-23T15:32:18.008Z",
diff --git a/www/apps/book/next.config.mjs b/www/apps/book/next.config.mjs
index 50e2c4ed7b..80e536240a 100644
--- a/www/apps/book/next.config.mjs
+++ b/www/apps/book/next.config.mjs
@@ -31,7 +31,6 @@ const withMDX = mdx({
},
ui: {
projectPath: path.resolve("..", "ui"),
- contentPath: "src/content/docs",
},
"user-guide": {
projectPath: path.resolve("..", "user-guide"),
diff --git a/www/apps/book/public/llms-full.txt b/www/apps/book/public/llms-full.txt
index 112714d0d0..be6c6643cc 100644
--- a/www/apps/book/public/llms-full.txt
+++ b/www/apps/book/public/llms-full.txt
@@ -12708,7 +12708,7 @@ The Index Module is a tool to perform highly performant queries across modules,
While modules share the same database by default, Medusa [isolates modules](https://docs.medusajs.com/learn/fundamentals/modules/isolation/index.html.md) to allow using external data sources or different database types.
-So, when you retrieve data across modules using Query, Medusa aggregates the data coming from diffeent modules to create the end result. This approach limits your ability to filter data by linked modules. For example, you can't filter products (created in the Product Module) by their brand (created in the Brand Module).
+So, when you retrieve data across modules using Query, Medusa aggregates the data coming from different modules to create the end result. This approach limits your ability to filter data by linked modules. For example, you can't filter products (created in the Product Module) by their brand (created in the Brand Module).
The Index Module solves this problem by ingesting data into a central data store on application startup. The data store has a relational structure that enables efficiently filtering data ingested from different modules (and their data stores). So, when you retrieve data with the Index Module, you're retrieving it from the Index' data store, not the original data source.
@@ -13072,7 +13072,7 @@ const {
This will return all products whose brand name starts with `Acme`.
-### Use Request Query Configuations
+### Use Request Query Configurations
API routes using the `graph` method can configure default [query configurations](https://docs.medusajs.com/learn/fundamentals/module-links/query#request-query-configurations/index.html.md), such as which fields to retrieve, while also allowing clients to override them using query parameters.
@@ -22879,11 +22879,11 @@ The API reference's content is split into two types:
### Medusa UI Documentation
-The content of the Medusa UI documentation are located under the `www/apps/ui/src/content/docs` directory. They are MDX files.
+The content of the Medusa UI documentation are located under the `www/apps/ui/app` directory. They are MDX files.
-The UI documentation also shows code examples, which are under the `www/apps/ui/src/examples` directory.
+The UI documentation also shows code examples, which are under the `www/apps/ui/specs/examples` directory.
-The UI component props are generated from the source code and placed into the `www/apps/ui/src/specs` directory. To contribute to these props and their comments, check the comments in the source code under the `packages/design-system/ui` directory.
+The UI component props are generated from the source code and placed into the `www/apps/ui/specs/components` directory. To contribute to these props and their comments, check the comments in the source code under the `packages/design-system/ui` directory.
***
@@ -22976,7 +22976,7 @@ cd www/vale
# to lint content for the API reference
./run-vale.sh api-reference/markdown error
# to lint content for the Medusa UI documentation
-./run-vale.sh ui/src/content/docs error
+./run-vale.sh ui/app error
# to lint content for the user guide
./run-vale.sh user-guide/app error
```
@@ -88732,6 +88732,8 @@ Download this reference as an OpenApi YAML file. You can import this file to too
A component for displaying important messages.
+In this guide, you'll learn how to use the Alert component.
+
```tsx
import { Alert } from "@medusajs/ui"
@@ -88741,10 +88743,10 @@ export default function AlertDemo() {
```
-## Usage
-
***
+## Usage
+
```tsx
import { Alert } from "@medusajs/ui"
```
@@ -88753,10 +88755,10 @@ import { Alert } from "@medusajs/ui"
Here's a message
```
-## API Reference
-
***
+## API Reference
+
### Alert Props
This component is based on the div element and supports all of its props
@@ -88764,10 +88766,10 @@ This component is based on the div element and supports all of its props
- variant: (union) The variant of the alert Default: "info"
- dismissible: (boolean) Whether the alert is dismissible Default: false
-## Examples
-
***
+## Examples
+
### Success Alert
```tsx
@@ -88801,7 +88803,7 @@ export default function AlertError() {
```
-### Dismissable Alert
+### Dismissible Alert
```tsx
import { Alert } from "@medusajs/ui"
@@ -88815,7 +88817,9 @@ export default function AlertDismissable() {
# Avatar
-An image element with a fallback for representing the user.
+A component for displaying user avatars with a fallback option.
+
+In this guide, you'll learn how to use the Avatar component.
```tsx
import { Avatar } from "@medusajs/ui"
@@ -88833,8 +88837,6 @@ export default function AvatarDemo() {
## Usage
-***
-
```tsx
import { Avatar } from "@medusajs/ui"
```
@@ -88846,10 +88848,10 @@ import { Avatar } from "@medusajs/ui"
/>
```
-## API Reference
-
***
+## API Reference
+
### Avatar Props
This component is based on the \[Radix UI Avatar]\(https://www.radix-ui.com/primitives/docs/components/avatar) primitive.
@@ -88859,10 +88861,134 @@ This component is based on the \[Radix UI Avatar]\(https://www.radix-ui.com/prim
- variant: (union) The style of the avatar. Default: "rounded"
- size: (union) The size of the avatar's border radius. Default: "base"
+***
+
+## Examples
+
+### Avatar Variants
+
+```tsx
+import { Avatar } from "@medusajs/ui"
+
+export default function AvatarVariants() {
+ return (
+
+ )
+}
+
+```
+
+### Avatar Fallback Only
+
+```tsx
+import { Avatar } from "@medusajs/ui"
+
+export default function AvatarFallback() {
+ return
+}
+
+```
+
+### Avatar Custom Styling
+
+```tsx
+import { Avatar } from "@medusajs/ui"
+
+export default function AvatarCustomStyle() {
+ return (
+
+ )
+}
+
+```
+
+### Avatar Accessibility
+
+You can add the `aria-label` prop to the Avatar component for better accessibility.
+
+```tsx
+import { Avatar } from "@medusajs/ui"
+
+export default function AvatarAccessible() {
+ return (
+
+ )
+}
+
+```
+
# Badge
-Displays a badge
+A component for displaying labels or indicators in a badge style.
+
+In this guide, you'll learn how to use the Badge component.
```tsx
import { Badge } from "@medusajs/ui"
@@ -88875,8 +89001,6 @@ export default function BadgeDemo() {
## Usage
-***
-
```tsx
import { Badge } from "@medusajs/ui"
```
@@ -88885,10 +89009,10 @@ import { Badge } from "@medusajs/ui"
Badge
```
-## API Reference
-
***
+## API Reference
+
### Badge Props
This component is based on the \`div\` element and supports all of its props
@@ -88899,116 +89023,61 @@ This component is based on the \`div\` element and supports all of its props
- rounded: (union) The style of the badge's border radius. Default: "base"
- color: (union) The badge's color. Default: "grey"
-## Examples
-
***
-### Grey
+## Examples
+
+### Badge Colors
```tsx
import { Badge } from "@medusajs/ui"
-export default function BadgeGrey() {
- return Badge
+export default function BadgeAllColors() {
+ return (
+
+ Grey
+ Red
+ Green
+ Blue
+ Orange
+ Purple
+
+ )
}
```
-### Red
+### Badge Sizes
```tsx
import { Badge } from "@medusajs/ui"
-export default function BadgeRed() {
- return Badge
+export default function BadgeAllSizes() {
+ return (
+
+ 2xsmall
+ xsmall
+ small
+ base
+ large
+
+ )
}
```
-### Green
+### Badge Rounded Variants
```tsx
import { Badge } from "@medusajs/ui"
-export default function BadgeGreen() {
- return Badge
-}
-
-```
-
-### Blue
-
-```tsx
-import { Badge } from "@medusajs/ui"
-
-export default function BadgeBlue() {
- return Badge
-}
-
-```
-
-### Orange
-
-```tsx
-import { Badge } from "@medusajs/ui"
-
-export default function BadgeOrange() {
- return Badge
-}
-
-```
-
-### Purple
-
-```tsx
-import { Badge } from "@medusajs/ui"
-
-export default function BadgePurple() {
- return Badge
-}
-
-```
-
-### Small
-
-```tsx
-import { Badge } from "@medusajs/ui"
-
-export default function BadgeSmall() {
- return Badge
-}
-
-```
-
-### Large
-
-```tsx
-import { Badge } from "@medusajs/ui"
-
-export default function BadgeLarge() {
- return Badge
-}
-
-```
-
-### Rounded Full
-
-```tsx
-import { Badge } from "@medusajs/ui"
-
-export default function BadgeRoundedFull() {
- return Badge
-}
-
-```
-
-### Rounded Base
-
-```tsx
-import { Badge } from "@medusajs/ui"
-
-export default function BadgeRoundedBase() {
- return Badge
+export default function BadgeAllRounded() {
+ return (
+
+ Base Rounded
+ Full Rounded
+
+ )
}
```
@@ -89016,7 +89085,9 @@ export default function BadgeRoundedBase() {
# Button
-Displays a button
+A component for rendering buttons using Medusa's design system.
+
+In this guide, you'll learn how to use the Button component.
```tsx
import { Button } from "@medusajs/ui"
@@ -89027,10 +89098,10 @@ export default function ButtonDemo() {
```
-## Usage
-
***
+## Usage
+
```tsx
import { Button } from "@medusajs/ui"
```
@@ -89039,10 +89110,10 @@ import { Button } from "@medusajs/ui"
```
-## API Reference
-
***
+## API Reference
+
### Button Props
This component is based on the \`button\` element and supports all of its props
@@ -89053,66 +89124,58 @@ This component is based on the \`button\` element and supports all of its props
- variant: (union) The button's style. Default: "primary"
- size: (union) The button's size. Default: "base"
-## Examples
-
***
-### Primary
+## Examples
+
+### Button Variants
```tsx
import { Button } from "@medusajs/ui"
-export default function ButtonPrimary() {
- return
+export default function ButtonAllVariants() {
+ return (
+
+ )
}
```
-### Transparent
+### Button Loading State
```tsx
import { Button } from "@medusajs/ui"
-export default function ButtonTransparent() {
- return
+export default function ButtonLoading() {
+ return
}
```
-### Danger
-
-```tsx
-import { Button } from "@medusajs/ui"
-
-export default function ButtonDanger() {
- return
-}
-
-```
-
-### Disabled
-
-```tsx
-import { Button } from "@medusajs/ui"
-
-export default function ButtonDisabled() {
- return
-}
-
-```
-
-### With Icon
+### Button with Icon
```tsx
import { PlusMini } from "@medusajs/icons"
@@ -89128,13 +89191,19 @@ export default function ButtonWithIcon() {
```
-### Loading
+### Button as Link
```tsx
import { Button } from "@medusajs/ui"
-export default function ButtonLoading() {
- return
+export default function ButtonAsLink() {
+ return (
+
+ )
}
```
@@ -89142,7 +89211,9 @@ export default function ButtonLoading() {
# Calendar
-A calendar component that allows picking of a single date or a range of dates.
+A component for displaying a calendar interface with date selection capability.
+
+In this guide, you'll learn how to use the Calendar component.
```tsx
import { Calendar } from "@medusajs/ui"
@@ -89158,8 +89229,6 @@ export default function CalendarDemo() {
## Usage
-***
-
```tsx
import { Calendar } from "@medusajs/ui"
```
@@ -89168,10 +89237,10 @@ import { Calendar } from "@medusajs/ui"
```
-## API Reference
-
***
+## API Reference
+
### Calendar Props
Calendar component used to select a date.
@@ -89188,10 +89257,80 @@ Its props are based on \[React Aria Calendar]\(https://react-spectrum.adobe.com/
- pageBehavior: (PageBehavior) Controls the behavior of paging. Pagination either works by advancing the visible page by visibleDuration (default) or one unit of visibleDuration.
- validationState: (ValidationState) Whether the current selection is valid or invalid according to application logic.
+***
+
+## Examples
+
+### Controlled
+
+```tsx
+import { Calendar } from "@medusajs/ui"
+import { useState } from "react"
+
+export default function CalendarControlled() {
+ const [date, setDate] = useState(null)
+ return (
+
+
+ All Sundays are unavailable for selection.
+
+
+
+ )
+}
+
+```
+
# Checkbox
-A control that allows the user to toggle between checked and not checked.
+A component for rendering checkbox inputs using Medusa's design system.
+
+In this guide, you'll learn how to use the Checkbox component.
```tsx
import { Checkbox, Label } from "@medusajs/ui"
@@ -89211,8 +89350,6 @@ export default function CheckboxDemo() {
## Usage
-***
-
```tsx
import { Checkbox } from "@medusajs/ui"
```
@@ -89221,86 +89358,94 @@ import { Checkbox } from "@medusajs/ui"
```
-## API Reference
-
***
+## API Reference
+
### Checkbox Props
This component is based on the \[Radix UI Checkbox]\(https://www.radix-ui.com/primitives/docs/components/checkbox) primitive.
-## Examples
-
***
-### Default
+## Examples
+
+### Checkbox All States
```tsx
import { Checkbox, Label } from "@medusajs/ui"
-export default function CheckboxDefault() {
+export default function CheckboxAllStates() {
return (
-
+
+ The following checkbox will move from unchecked, to indeterminate, and
+ finally checked each time you click it
+
+
+
+
+
)
}
@@ -89310,7 +89455,9 @@ export default function CheckboxIndeterminate() {
# Code Block
-Allows you to render highlighted code snippets
+A component for displaying code snippets with syntax highlighting and copy functionality.
+
+In this guide, you'll learn how to use the Code Block component.
```tsx
import { CodeBlock, Label } from "@medusajs/ui"
@@ -89325,7 +89472,7 @@ const snippets = [
{
label: "Medusa JS SDK",
language: "jsx",
- code: `// Install the JS SDK in your storefront project: @medusajs/js-sdk\n\nimport Medusa from "@medusajs/js-sdk"\n\nconst medusa = new Medusa({\n baseUrl: import.meta.env.NEXT_PUBLIC_BACKEND_URL || "/",\n publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PAK\n})\nconst { product } = await medusa.store.products.retrieve("prod_123")\nconsole.log(product.id)`,
+ code: `const { product } = await medusa.store.products.retrieve("prod_123")\nconsole.log(product.id)`,
},
]
@@ -89348,8 +89495,6 @@ export default function CodeBlockDemo() {
## Usage
-***
-
```tsx
import { CodeBlock } from "@medusajs/ui"
```
@@ -89369,10 +89514,10 @@ import { CodeBlock } from "@medusajs/ui"
```
-## API Reference
-
***
+## API Reference
+
### CodeBlock Props
This component is based on the \`div\` element and supports all of its props
@@ -89397,11 +89542,11 @@ This component is based on the \`div\` element and supports all of its props
-## Usage Outside Medusa Admin
-
***
-If you're using the `CodeBlock` component in a project other than the Medusa Admin, make sure to include the `TooltipProvider` somewhere up in your component tree, as the `CodeBlock.Header` component uses a [Tooltip](https://docs.medusajs.com/components/tooltip#usage-outside-medusa-admin/index.html.md):
+## Usage Outside Medusa Admin
+
+If you're using the `CodeBlock` component in a project other than the Medusa Admin, make sure to include the `TooltipProvider` somewhere up in your component tree, as the `CodeBlock.Header` component uses a [Tooltip](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/ui/app/components/tooltip#usage-outside-medusa-admin/index.html.md):
```tsx
@@ -89420,11 +89565,11 @@ If you're using the `CodeBlock` component in a project other than the Medusa Adm
```
-## Examples
-
***
-### Single snippet
+## Examples
+
+### Single Snippet
If you want to only show a code sample for one language or API, you can choose to hide the snippet labels:
@@ -89435,7 +89580,7 @@ const snippets = [
{
label: "Medusa JS SDK",
language: "jsx",
- code: `// Install the JS SDK in your storefront project: @medusajs/js-sdk\n\nimport Medusa from "@medusajs/js-sdk"\n\nconst medusa = new Medusa({\n baseUrl: import.meta.env.NEXT_PUBLIC_BACKEND_URL || "/",\n publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PAK\n})\nconst { product } = await medusa.store.products.retrieve("prod_123")\nconsole.log(product.id)`,
+ code: `console.log("Hello, World!")`,
},
]
@@ -89458,7 +89603,7 @@ export default function CodeBlockSingle() {
### No Header
-You could also choose to omit the header entirely:
+You can also omit the header entirely:
```tsx
import { CodeBlock } from "@medusajs/ui"
@@ -89467,7 +89612,7 @@ const snippets = [
{
label: "Medusa JS SDK",
language: "jsx",
- code: `// Install the JS SDK in your storefront project: @medusajs/js-sdk\n\nimport Medusa from "@medusajs/js-sdk"\n\nconst medusa = new Medusa({\n baseUrl: import.meta.env.NEXT_PUBLIC_BACKEND_URL || "/",\n publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PAK\n})\nconst { product } = await medusa.store.products.retrieve("prod_123")\nconsole.log(product.id)`,
+ code: `console.log("Hello, World!")`,
},
]
@@ -89492,7 +89637,7 @@ const snippets = [
{
label: "Medusa JS SDK",
language: "jsx",
- code: `// Install the JS SDK in your storefront project: @medusajs/js-sdk\n\nimport Medusa from "@medusajs/js-sdk"\n\nconst medusa = new Medusa({\n baseUrl: import.meta.env.NEXT_PUBLIC_BACKEND_URL || "/",\n publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PAK\n})\nconst { product } = await medusa.store.products.retrieve("prod_123")\nconsole.log(product.id)`,
+ code: `console.log("Hello, ")\n\nconsole.log("World!")`,
hideLineNumbers: true,
},
]
@@ -89523,7 +89668,7 @@ const snippets = [
{
label: "Medusa JS SDK",
language: "jsx",
- code: `// Install the JS SDK in your storefront project: @medusajs/js-sdk\n\nimport Medusa from "@medusajs/js-sdk"\n\nconst medusa = new Medusa({\n baseUrl: import.meta.env.NEXT_PUBLIC_BACKEND_URL || "/",\n publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PAK\n})\nconst { product } = await medusa.store.products.retrieve("prod_123")\nconsole.log(product.id)`,
+ code: `console.log("Hello, World!")`,
hideCopy: true,
},
]
@@ -89548,7 +89693,9 @@ export default function CodeBlockNoCopy() {
# Command Bar
-Display a command bar with a list of commands
+A component that displays a command bar with a list of commands to perform on a bulk selection of items.
+
+In this guide, you'll learn how to use the Command Bar component.
```tsx
import { Checkbox, CommandBar, Label, Text } from "@medusajs/ui"
@@ -89598,8 +89745,6 @@ export default function CommandBarDemo() {
## Usage
-***
-
```tsx
import { CommandBar } from "@medusajs/ui"
```
@@ -89624,10 +89769,10 @@ import { CommandBar } from "@medusajs/ui"
```
-## API Reference
-
***
+## API Reference
+
### CommandBar Props
The root component of the command bar. This component manages the state of the command bar.
@@ -89667,7 +89812,9 @@ The command component of the command bar. This component is used to display a co
# Command
-Renders an unhighlighted code block, useful for one-liners or API Routes
+A component that renders an unhighlighted code block, useful for one-liners or API routes.
+
+In this guide, you'll learn how to use the Command component.
```tsx
import { Badge, Command } from "@medusajs/ui"
@@ -89691,8 +89838,6 @@ export default function CommandDemo() {
## Usage
-***
-
```tsx
import { Command } from "@medusajs/ui"
```
@@ -89703,21 +89848,21 @@ import { Command } from "@medusajs/ui"
```
-## API Reference
-
***
+## API Reference
+
### Command Props
This component is based on the div element and supports all of its props
-## Usage Outside Medusa Admin
-
***
-If you're using the `Command` component in a project other than the Medusa Admin, make sure to include the `TooltipProvider` somewhere up in your component tree, as the `Command.Copy` component uses a [Tooltip](https://docs.medusajs.com/components/tooltip#usage-outside-medusa-admin/index.html.md):
+## Usage Outside Medusa Admin
+
+If you're using the `Command` component in a project other than the Medusa Admin, make sure to include the `TooltipProvider` somewhere up in your component tree, as the `Command.Copy` component uses a [Tooltip](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/ui/app/components/tooltip#usage-outside-medusa-admin/index.html.md):
```tsx
@@ -89734,7 +89879,9 @@ If you're using the `Command` component in a project other than the Medusa Admin
# Container
-A box used to organise content.
+A component that wraps content in a card-like container. The container is useful to create sections in the Medusa Admin dashboard.
+
+In this guide, you'll learn how to use the Container component.
```tsx
import { Container } from "@medusajs/ui"
@@ -89747,8 +89894,6 @@ export default function ContainerDemo() {
## Usage
-***
-
```tsx
import { Container } from "@medusajs/ui"
```
@@ -89757,21 +89902,21 @@ import { Container } from "@medusajs/ui"
Container
```
-## API Reference
-
***
+## API Reference
+
### Container Props
This component is based on the \`div\` element and supports all of its props
-## Examples
-
***
-### In a layout
+## Examples
+
+### In a Layout
```tsx
import { Container, Heading } from "@medusajs/ui"
@@ -89802,7 +89947,9 @@ export default function ContainerLayout() {
# Copy
-Displays a tooltipped button that puts string contents into the user's clipboard.
+A component that wraps content in a button with copy functionality. It is useful for quickly copying text to the clipboard, such as code snippets or configuration commands.
+
+In this guide, you'll learn how to use the Copy component.
```tsx
import { Copy } from "@medusajs/ui"
@@ -89815,8 +89962,6 @@ export default function CopyDemo() {
## Usage
-***
-
```tsx
import { Copy } from "@medusajs/ui"
```
@@ -89825,10 +89970,10 @@ import { Copy } from "@medusajs/ui"
```
-## API Reference
-
***
+## API Reference
+
### Copy Props
This component is based on the \`button\` element and supports all of its props
@@ -89838,11 +89983,11 @@ This component is based on the \`button\` element and supports all of its props
- asChild: (boolean) Whether to remove the wrapper \`button\` element and use the
passed child element instead. Default: false
-## Usage Outside Medusa Admin
-
***
-If you're using the `Copy` component in a project other than the Medusa Admin, make sure to include the `TooltipProvider` somewhere up in your component tree, as the `Copy` component uses a [Tooltip](https://docs.medusajs.com/components/tooltip#usage-outside-medusa-admin/index.html.md):
+## Usage Outside Medusa Admin
+
+If you're using the `Copy` component in a project other than the Medusa Admin, make sure to include the `TooltipProvider` somewhere up in your component tree, as the `Copy` component uses a [Tooltip](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/ui/app/components/tooltip#usage-outside-medusa-admin/index.html.md):
```tsx
@@ -89850,11 +89995,11 @@ If you're using the `Copy` component in a project other than the Medusa Admin, m
```
-## Examples
-
***
-### With custom display
+## Examples
+
+### Copy with Custom Display
```tsx
import { Code, Copy } from "@medusajs/ui"
@@ -89869,9 +90014,9 @@ export default function CopyDemo() {
```
-### As child
+### Copy Display As Child
-Using the `asChild` prop, you can render the `` as it's child. This is useful if you want to render a custom button, to prevent rendering a button inside a button.
+Using the `asChild` prop, you can render the `` as its child. This is useful if you want to render a custom button, to prevent rendering a button inside a button.
```tsx
import { PlusMini } from "@medusajs/icons"
@@ -89895,7 +90040,9 @@ export default function CopyAsChild() {
# Currency Input
-Input component for currency values
+A component for rendering form inputs for money amounts, showing the currency in the input.
+
+In this guide, you'll learn how to use the Currency Input component.
```tsx
import { CurrencyInput } from "@medusajs/ui"
@@ -89912,8 +90059,6 @@ export default function CurrencyInputDemo() {
## Usage
-***
-
```tsx
import { CurrencyInput } from "@medusajs/ui"
```
@@ -89922,10 +90067,10 @@ import { CurrencyInput } from "@medusajs/ui"
```
-## API Reference
-
***
+## API Reference
+
### CurrencyInput Props
This component is based on the input element and supports all of its props
@@ -89989,11 +90134,102 @@ This component is based on the input element and supports all of its props
- step: (number) Incremental value change on arrow down and arrow up key press
- transformRawValue: (signature) Transform the raw value form the input before parsing
-## Examples
-
***
-### Base
+## Examples
+
+### Controlled
+
+```tsx
+import { useState } from "react"
+import { CurrencyInput } from "@medusajs/ui"
+
+export default function CurrencyInputControlled() {
+ const [value, setValue] = useState("")
+ const formatValue = (val: string | undefined) => {
+ if (!val) {
+ return ""
+ }
+ return new Intl.NumberFormat("en-US", {
+ style: "currency",
+ currency: "USD",
+ }).format(parseFloat(val))
+ }
+ return (
+
+ )
+}
+
+```
+
+### Sizes
+
+#### Base
```tsx
import { CurrencyInput } from "@medusajs/ui"
@@ -90008,7 +90244,7 @@ export default function CurrencyInputBase() {
```
-### Small
+#### Small
```tsx
import { CurrencyInput } from "@medusajs/ui"
@@ -90024,17 +90260,15 @@ export default function CurrencyInputSmall() {
```
-# DataTable
+# Data Table
-A Table component with advanced functionalities like pagination, filtering, and more.
+A component to display a table of data with advanced functionalities like pagination, filtering, and more.
+
+In this guide, you'll learn how to use the DataTable component.
The `DataTable` component is useful if you're displaying large data with functionalities like pagination, filtering, sorting, and searching. It's also the recommended table component to use when creating customizations in the Medusa Admin.
-This component is available after Medusa UI v4.0.4 (or Medusa v2.4.0). It is built on top of the [Table](https://docs.medusajs.com/components/table/index.html.md) component. If you want a table with more control over its styling and functionality, use that component instead.
-
-## Simple Example
-
-***
+This component is available after Medusa UI v4.0.4 (or Medusa v2.4.0). It is built on top of the [Table](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/ui/app/components/table/index.html.md) component. If you want a table with more control over its styling and functionality, use that component instead.
```tsx
import { createDataTableColumnHelper, useDataTable, DataTable, Heading } from "@medusajs/ui"
@@ -90087,8 +90321,6 @@ export default function ProductTable () {
## Usage
-***
-
You import the `DataTable` component from `@medusajs/ui`.
```tsx
@@ -90097,7 +90329,7 @@ import {
} from "@medusajs/ui"
```
-### Columns Preparation
+### Data Table Columns Preparation
Before using the `DataTable` component, you need to prepare its columns using the `createDataTableColumnHelper` utility:
@@ -90129,14 +90361,14 @@ const columns = [
]
```
-The `createDataTableColumnHelper` utility is a function that returns a helper used to generates column configurations for the `DataTable` component.
+The `createDataTableColumnHelper` utility is a function that returns a helper used to generate column configurations for the `DataTable` component.
For each column in the table, use the `accessor` method of the column helper to specify configurations for a specific column. The `accessor` method accepts the column's key in the table's data as the first parameter, and an object with the following properties as the second parameter:
- `header`: The table header text for the column.
- `enableSorting`: (optional) A boolean that indicates whether data in the table can be sorted by this column. More on sorting in [this section](#configure-sorting-in-datatable).
-### Create Table Instance
+### Create Data Table Instance
The `DataTable` component expects a table instance created using the `useDataTable` hook. Import that hook from `@medusajs/ui`:
@@ -90194,10 +90426,10 @@ In the `DataTable` component, you pass the following child components:
Refer to the examples later on this page to learn how to add pagination, filtering, and other functionalities using the `DataTable` component.
-## API Reference
-
***
+## API Reference
+
### DataTable Props
This component creates a data table with filters, pagination, sorting, and more.
@@ -90251,33 +90483,39 @@ to sort the table's data.
- tooltip: (string) The tooltip to show when hovering over the sorting menu.
-## Example with Data Fetching
-
***
+## Example with Data Fetching
+
Refer to [this Admin Components guide](https://docs.medusajs.com/resources/admin-components/components/data-table/index.html.md) for an example on using the `DataTable` component with data fetching from the Medusa application.
-## Handle Row Click
-
***
+## Handle Row Click
+
```tsx
-import { createDataTableColumnHelper, useDataTable, DataTable, Heading } from "@medusajs/ui"
+import {
+ createDataTableColumnHelper,
+ useDataTable,
+ DataTable,
+ Heading,
+ usePrompt,
+} from "@medusajs/ui"
const products = [
{
id: "1",
title: "Shirt",
- price: 10
+ price: 10,
},
{
id: "2",
title: "Pants",
- price: 20
- }
+ price: 20,
+ },
]
-const columnHelper = createDataTableColumnHelper()
+const columnHelper = createDataTableColumnHelper<(typeof products)[0]>()
const columns = [
columnHelper.accessor("title", {
@@ -90290,27 +90528,33 @@ const columns = [
}),
]
-export default function ProductTable () {
+export default function ProductTable() {
+ const prompt = usePrompt()
+
const table = useDataTable({
columns,
data: products,
getRowId: (product) => product.id,
rowCount: products.length,
isLoading: false,
- onRowClick: (event, row) => {
- alert(`You clicked row #${row.id}`)
- }
+ onRowClick: async (event, row) => {
+ await prompt({
+ title: "Row Clicked",
+ description: `You clicked row #${row.id}`,
+ })
+ },
})
-
+
return (
-
- Products
+
+ Products
)
}
+
```
In many cases, you want to perform an action when a row is clicked. Most commonly, you may want to open the details page of the row when it's clicked.
@@ -90332,15 +90576,15 @@ const table = useDataTable({
The value of `onRowClick` is a function that accepts two parameters:
-- `event`: An instance of the [MouseClickEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) object.
+- `event`: An instance of the [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) object.
- `row`: The data of the row that was clicked.
In the above example, you use a `navigate` function, retrieved through the `useNavigate` hook from `react-router-dom`, to navigate to the details page of the row that was clicked.
-## Configure Cell Rendering
-
***
+## Configure Cell Rendering
+
```tsx
import { createDataTableColumnHelper, useDataTable, DataTable, Heading, Badge } from "@medusajs/ui"
@@ -90443,10 +90687,10 @@ const columns = [
The `cell` property's value is a function that returns a string or a React node to be rendered in the cell. The function receives as a parameter an object having a `getValue` property to get the raw value of the cell.
-## Configure Search in DataTable
-
***
+## Configure Search in DataTable
+
```tsx
import { createDataTableColumnHelper, useDataTable, DataTable, Heading } from "@medusajs/ui"
import { useMemo, useState } from "react"
@@ -90572,10 +90816,10 @@ return (
This will show a search input at the top of the table, in the data table's toolbar.
-## Configure Pagination in DataTable
-
***
+## Configure Pagination in DataTable
+
```tsx
import { DataTable, Heading, createDataTableColumnHelper, useDataTable, type DataTablePaginationState } from "@medusajs/ui"
import { useMemo, useState } from "react"
@@ -90812,10 +91056,10 @@ return (
This will show the pagination controls at the end of the table.
-## Configure Filters in DataTable
-
***
+## Configure Filters in DataTable
+
```tsx
import { DataTable, DataTableFilteringState, Heading, createDataTableColumnHelper, createDataTableFilterHelper, useDataTable } from "@medusajs/ui"
import { useMemo, useState } from "react"
@@ -91073,7 +91317,7 @@ return (
This will show a filter menu at the top of the table, in the data table's toolbar.
-### Filtering Date Values
+### Filtering Date Values in DataTable
```tsx
import { DataTable, DataTableFilteringState, Heading, createDataTableColumnHelper, createDataTableFilterHelper, useDataTable } from "@medusajs/ui"
@@ -91303,7 +91547,7 @@ const shownProducts = useMemo(() => {
}, [filtering])
```
-### Initial Filter Values
+### Initial Filter Values in DataTable
```tsx
import { DataTable, DataTableFilteringState, Heading, createDataTableColumnHelper, createDataTableFilterHelper, useDataTable } from "@medusajs/ui"
@@ -91425,10 +91669,10 @@ const [filtering, setFiltering] = useState({
The user can still change the filter values, but the initial values will be applied when the table is first rendered.
-## Configure Sorting in DataTable
-
***
+## Configure Sorting in DataTable
+
```tsx
import { DataTable, DataTableSortingState, Heading, createDataTableColumnHelper, useDataTable } from "@medusajs/ui"
import { useMemo, useState } from "react"
@@ -91634,7 +91878,7 @@ return (
This will show a sorting menu at the top of the table, in the data table's toolbar.
-### Initial Sort Values
+### Initial Sort Values in DataTable
```tsx
import { DataTable, DataTableSortingState, Heading, createDataTableColumnHelper, useDataTable } from "@medusajs/ui"
@@ -91735,10 +91979,10 @@ const [sorting, setSorting] = useState({
The user can still change the sort values, but the initial values will be applied when the table is first rendered.
-## Perform Bulk Actions on DataTable Rows
-
***
+## Perform Bulk Actions on DataTable Rows
+
```tsx
import { DataTable, DataTableRowSelectionState, Heading, createDataTableColumnHelper, createDataTableCommandHelper, useDataTable } from "@medusajs/ui"
import { useState } from "react"
@@ -91926,7 +92170,9 @@ This will show a command bar when the user has selected at least one row in the
# Date Picker
-A date picker component with range and presets.
+A component for rendering date picker inputs with range and presets.
+
+In this guide, you'll learn how to use the Date Picker component.
```tsx
import { DatePicker } from "@medusajs/ui"
@@ -91943,8 +92189,6 @@ export default function DatePickerDemo() {
## Usage
-***
-
```tsx
import { DatePicker } from "@medusajs/ui"
```
@@ -91953,10 +92197,10 @@ import { DatePicker } from "@medusajs/ui"
```
-## API Reference
-
***
+## API Reference
+
### DatePicker Props
- aria-describedby: (string) Identifies the element (or elements) that describes the object.
@@ -91995,10 +92239,10 @@ import { DatePicker } from "@medusajs/ui"
when the value is missing or invalid, or mark the field as required
or invalid via ARIA.
-## Examples
-
***
+## Examples
+
### Controlled Date Picker
Manage and store the value of the date picker in a state variable for controlled behavior. This is also useful for form integration.
@@ -92051,7 +92295,7 @@ export default function DatePickerWithTime() {
```
-### Min/Max Values
+### Date Picker Min/Max Values
Restrict date selection to a specific range by setting minimum and maximum values.
@@ -92080,7 +92324,7 @@ export default function DatePickerMinMax() {
```
-### Disabled Dates
+### Date Picker Disabled Dates
Disable specific dates like weekends and holidays to prevent selection of unavailable dates.
@@ -92115,7 +92359,7 @@ export default function DatePickerBusinessHours() {
```
-### Granularity Options
+### Date Picker Granularity Options
Different levels of time precision from date-only to second-precision selection.
@@ -92170,7 +92414,7 @@ export default function DatePickerGranularity() {
```
-### Form Integration
+### Date Picker Form Integration
The following example shows how to use the date picker in a form, with simulated form submission.
@@ -92252,7 +92496,9 @@ export default function DatePickerForm() {
# Drawer
-A triggerable drawer that overlaps whatever page it's on.
+A component for rendering a sliding panel that overlays the main content.
+
+In this guide, you'll learn how to use the Drawer component.
```tsx
import { Button, Drawer, Text } from "@medusajs/ui"
@@ -92285,8 +92531,6 @@ export default function DrawerDemo() {
## Usage
-***
-
```tsx
import { Drawer } from "@medusajs/ui"
```
@@ -92304,10 +92548,10 @@ import { Drawer } from "@medusajs/ui"
```
-## API Reference
-
***
+## API Reference
+
### Drawer Props
This component is based on the \[Radix UI Dialog]\(https://www.radix-ui.com/primitives/docs/components/dialog) primitives.
@@ -92359,9 +92603,75 @@ This component is based on the \`div\` element and supports all of its props.
+***
+
+## Examples
+
+### Drawer with Form
+
+This example shows a simple form inside a Drawer, demonstrating how to use form elements and handle submission.
+
+```tsx
+import { useState } from "react"
+import { Button, Drawer, Input, Label } from "@medusajs/ui"
+
+export default function DrawerWithForm() {
+ const [name, setName] = useState("")
+ const [open, setOpen] = useState(false)
+ const [submitted, setSubmitted] = useState(false)
+
+ function handleSubmit(e: React.FormEvent) {
+ e.preventDefault()
+ setSubmitted(true)
+ setOpen(false)
+ }
+
+ return (
+
+ )
+}
+
+```
+
+
# Dropdown Menu
-Displays a menu to the user—such as a set of actions or functions—triggered by a button.
+A component for rendering dropdown menus that display a set of actions or options to users.
+
+In this guide, you'll learn how to use the Dropdown Menu component.
```tsx
import { EllipsisHorizontal, PencilSquare, Plus, Trash } from "@medusajs/icons"
@@ -92398,8 +92708,6 @@ export default function DropdownMenuDemo() {
## Usage
-***
-
```tsx
import { DropdownMenu } from "@medusajs/ui"
```
@@ -92415,16 +92723,36 @@ import { DropdownMenu } from "@medusajs/ui"
```
-## API Reference
-
***
+## API Reference
+
### DropdownMenu Props
This component is based on the \[Radix UI Dropdown Menu]\(https://www.radix-ui.com/primitives/docs/components/dropdown-menu) primitive.
+### DropdownMenu.Trigger Props
+
+This component is based on the \[Radix UI Dropdown Menu Trigger]\(https://www.radix-ui.com/primitives/docs/components/dropdown-menu#trigger) primitive.
+
+
+
+### DropdownMenu.Content Props
+
+This component is based on the \[Radix UI Dropdown Menu Content]\(https://www.radix-ui.com/primitives/docs/components/dropdown-menu#content) primitive.
+
+- sideOffset: (undefined) Default: 8
+- collisionPadding: (undefined) Default: 8
+- align: (undefined) Default: "center"
+
+### DropdownMenu.Item Props
+
+This component is based on the \[Radix UI Dropdown Menu Item]\(https://www.radix-ui.com/primitives/docs/components/dropdown-menu#item) primitive.
+
+
+
### DropdownMenu.Shortcut Props
This component is based on the \`span\` element and supports all of its props
@@ -92437,13 +92765,31 @@ This component is based on the \`span\` element and supports all of its props
-## Examples
+### DropdownMenu.RadioGroup Props
+
+This component is based on the \[Radix UI Dropdown Menu RadioGroup]\(https://www.radix-ui.com/primitives/docs/components/dropdown-menu#radiogroup) primitive.
+
+
+
+### DropdownMenu.RadioItem Props
+
+This component is based on the \[Radix UI Dropdown Menu RadioItem]\(https://www.radix-ui.com/primitives/docs/components/dropdown-menu#radioitem) primitive.
+
+
+
+### DropdownMenu.Shortcut Props
+
+This component is based on the \`span\` element and supports all of its props
+
+
***
+## Examples
+
### Sorting
-Implementing collection sorting choices using a Dropdown Menu:
+This example shows how to display collection sorting choices using a Dropdown Menu.
```tsx
import { EllipsisHorizontal } from "@medusajs/icons"
@@ -92491,19 +92837,154 @@ export default function DropdownMenuSorting() {
-
-
Sorting: {sort}
-
+ Sorting: {sort}
)
}
```
+### Dropdown with Submenu
+
+```tsx
+import { DropdownMenu, IconButton } from "@medusajs/ui"
+import { BarsArrowDown } from "@medusajs/icons"
+
+export default function DropdownMenuSubmenu() {
+ return (
+
+
+
+
+
+
+
+ Edit
+
+
+ More Actions
+
+
+ Duplicate
+ Archive
+
+
+ Delete
+
+
+ )
+}
+
+```
+
+### Disabled Items and Using Icons
+
+```tsx
+import { DropdownMenu, IconButton } from "@medusajs/ui"
+import { Trash, BarsThree } from "@medusajs/icons"
+
+export default function DropdownMenuDisabledAndIcons() {
+ return (
+
+
+
+
+
+
+
+ Edit
+
+
+ Delete
+
+
+
+ )
+}
+
+```
+
+### Keyboard Shortcuts (with handling)
+
+This example shows how to visually display keyboard shortcuts in the menu and handle them in your application logic.
+
+You can use the {osShortcut}E and {osShortcut}D shortcuts to trigger the actions of the dropdown items.
+
+```tsx
+import { useEffect, useCallback } from "react"
+import { DropdownMenu, IconButton, toast, Toaster } from "@medusajs/ui"
+import { Keyboard } from "@medusajs/icons"
+
+function getOsShortcut() {
+ const isMacOs =
+ typeof navigator !== "undefined"
+ ? navigator.userAgent.toLowerCase().indexOf("mac") !== 0
+ : true
+
+ return isMacOs ? "⌘" : "Ctrl"
+}
+
+export default function DropdownMenuWithShortcuts() {
+ const osShortcut = getOsShortcut()
+ const handleEdit = useCallback(() => {
+ toast.success("Success", {
+ description: "Edit shortcut triggered!",
+ })
+ }, [])
+
+ const handleDelete = useCallback(() => {
+ toast.success("Success", {
+ description: "Delete shortcut triggered!",
+ })
+ }, [])
+
+ useEffect(() => {
+ function handleKeydown(e: KeyboardEvent) {
+ if (e.metaKey && e.key.toLowerCase() === "e") {
+ e.preventDefault()
+ handleEdit()
+ }
+ if (e.metaKey && e.key.toLowerCase() === "d") {
+ e.preventDefault()
+ handleDelete()
+ }
+ }
+ window.addEventListener("keydown", handleKeydown)
+ return () => window.removeEventListener("keydown", handleKeydown)
+ }, [handleEdit, handleDelete])
+
+ return (
+ <>
+
+
+
+
+
+
+
+
+ Edit
+ {osShortcut}E
+
+
+ Delete
+ {osShortcut}D
+
+
+
+
+ >
+ )
+}
+
+```
+
# Focus Modal
-A modal component that spans the whole screen
+A component for rendering a modal dialog shown over the main content.
+
+In this guide, you'll learn how to use the Focus Modal component.
```tsx
import { Button, FocusModal, Heading, Input, Label, Text } from "@medusajs/ui"
@@ -92516,7 +92997,7 @@ export default function FocusModalDemo() {
-
+ Edit Variant
@@ -92535,6 +93016,9 @@ export default function FocusModalDemo() {
+
+
+
)
@@ -92544,8 +93028,6 @@ export default function FocusModalDemo() {
## Usage
-***
-
```tsx
import { FocusModal } from "@medusajs/ui"
```
@@ -92560,10 +93042,10 @@ import { FocusModal } from "@medusajs/ui"
```
-### API Reference
-
***
+## API Reference
+
### FocusModal Props
This component is based on the \[Radix UI Dialog]\(https://www.radix-ui.com/primitives/docs/components/dialog) primitives.
@@ -92607,35 +93089,155 @@ This component is based on the \`div\` element and supports all of its props
-## Example: Control Open State
-
***
+## Examples
+
+### Control Focus Modal Open State
+
```tsx
+import { Button, FocusModal, Heading, Input, Label, Text } from "@medusajs/ui"
import { useState } from "react"
-const MyModal = () => {
+export default function FocusModalControlled() {
const [open, setOpen] = useState(false)
return (
-
- Trigger
+
+
+
+
+
+ Edit Variant
+
+
+
+
+ Create API key
+
+ Create and manage API keys. You can create multiple keys to
+ organize your applications.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+```
+
+### Using Form in Focus Modal
+
+```tsx
+import { Button, FocusModal, Input, Label } from "@medusajs/ui"
+import { useState } from "react"
+
+export default function FocusModalForm() {
+ const [open, setOpen] = useState(false)
+ const [value, setValue] = useState("")
+
+ function handleSubmit(e: React.FormEvent) {
+ e.preventDefault()
+ setOpen(false)
+ }
+
+ return (
+
+
+
+
+
+
+
+ Create Item
+
+
+
+
+ {value && (
+
+ Form submitted with name: {value}
+
+ )}
+
+ )
+}
+
+```
+
+### Nested Focus Modals
+
+A focus modal can open another focus modal. These focus modals will be stacked on top of each other. You can nest as many focus modals as you want.
+
+```tsx
+import { Button, FocusModal } from "@medusajs/ui"
+
+export default function NestedFocusModals() {
+ return (
+
+
+
+
- Title
- Content
+
+ Outer Modal
+
+
+
This is the outer modal.
+
+
+
+
+
+
+ Nested Modal
+
+
+
This is a nested focus modal for additional information.
+
+
+
+
)
}
+
```
# Heading
-Text component used for page titles and other headers
+A component used for page titles and other headers.
+
+In this guide, you'll learn how to use the Heading component.
```tsx
import { Heading } from "@medusajs/ui"
@@ -92654,8 +93256,6 @@ export default function HeadingDemo() {
## Usage
-***
-
```tsx
import { Heading } from "@medusajs/ui"
```
@@ -92664,10 +93264,10 @@ import { Heading } from "@medusajs/ui"
A Title
```
-## API Reference
-
***
+## API Reference
+
### Heading Props
This component is based on the heading element (\`h1\`, \`h2\`, etc...) depeneding on the specified level
@@ -92678,7 +93278,9 @@ and supports all of its props
# Icon Badge
-Displays an icon badge
+A component that displays an icon in a badge.
+
+In this guide, you'll learn how to use the Icon Badge component.
```tsx
import { BuildingTax } from "@medusajs/icons"
@@ -92696,8 +93298,6 @@ export default function IconBadgeDemo() {
## Usage
-***
-
```tsx
import { IconBadge } from "@medusajs/ui"
import { BuildingTax } from "@medusajs/icons"
@@ -92709,10 +93309,10 @@ import { BuildingTax } from "@medusajs/icons"
```
-## API Reference
-
***
+## API Reference
+
### IconBadge Props
This component is based on the \`span\` element and supports all of its props
@@ -92722,133 +93322,59 @@ This component is based on the \`span\` element and supports all of its props
- color: (union) The badge's color. Default: "grey"
- size: (union) The badge's size. Default: "base"
-## Examples
-
***
-### Grey
+## Examples
+
+### Colors
```tsx
-import { BuildingTax } from "@medusajs/icons"
import { IconBadge } from "@medusajs/ui"
+import { BuildingTax } from "@medusajs/icons"
-export default function IconBadgeGrey() {
+export default function IconBadgeAllColors() {
return (
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
)
}
```
-### Red
+### Sizes
```tsx
-import { BuildingTax } from "@medusajs/icons"
import { IconBadge } from "@medusajs/ui"
-
-export default function IconBadgeRed() {
- return (
-
-
-
- )
-}
-
-```
-
-### Green
-
-```tsx
import { BuildingTax } from "@medusajs/icons"
-import { IconBadge } from "@medusajs/ui"
-export default function IconBadgeGreen() {
+export default function IconBadgeAllSizes() {
return (
-
-
-
- )
-}
-
-```
-
-### Blue
-
-```tsx
-import { BuildingTax } from "@medusajs/icons"
-import { IconBadge } from "@medusajs/ui"
-
-export default function IconBadgeBlue() {
- return (
-
-
-
- )
-}
-
-```
-
-### Orange
-
-```tsx
-import { BuildingTax } from "@medusajs/icons"
-import { IconBadge } from "@medusajs/ui"
-
-export default function IconBadgeOrange() {
- return (
-
-
-
- )
-}
-
-```
-
-### Purple
-
-```tsx
-import { BuildingTax } from "@medusajs/icons"
-import { IconBadge } from "@medusajs/ui"
-
-export default function IconBadgePurple() {
- return (
-
-
-
- )
-}
-
-```
-
-### Base
-
-```tsx
-import { BuildingTax } from "@medusajs/icons"
-import { IconBadge } from "@medusajs/ui"
-
-export default function IconBadgeBase() {
- return (
-
-
-
- )
-}
-
-```
-
-### Large
-
-```tsx
-import { BuildingTax } from "@medusajs/icons"
-import { IconBadge } from "@medusajs/ui"
-
-export default function IconBadgeLarge() {
- return (
-
-
-
+
+
+
+
+
+
+
+
)
}
@@ -92857,7 +93383,9 @@ export default function IconBadgeLarge() {
# Icon Button
-Displays an icon button
+A component that displays an icon in a button.
+
+In this guide, you'll learn how to use the Icon Button component.
```tsx
import { PlusMini } from "@medusajs/icons"
@@ -92875,8 +93403,6 @@ export default function IconButtonDemo() {
## Usage
-***
-
```tsx
import { IconButton } from "@medusajs/ui"
import { Plus } from "@medusajs/icons"
@@ -92888,10 +93414,10 @@ import { Plus } from "@medusajs/icons"
```
-## API Reference
-
***
+## API Reference
+
### IconButton Props
This component is based on the \`button\` element and supports all of its props
@@ -92902,19 +93428,73 @@ This component is based on the \`button\` element and supports all of its props
- variant: (union) The button's style. Default: "primary"
- size: (union) The button's size. Default: "base"
-## Examples
-
***
-### Primary
+## Examples
+
+### Icon Button Variants
+
+```tsx
+import { IconButton } from "@medusajs/ui"
+import { PlusMini } from "@medusajs/icons"
+
+export default function IconButtonAllVariants() {
+ return (
+
+ )
+}
+
+```
+
+### Error State
You can leverage the native `aria-invalid` property to show an error state on your input:
@@ -93247,7 +93771,9 @@ export default function InputError() {
# Kbd
-Renders a badge-styled kbd element
+A component that renders a badge-styled keyboard (`kbd`) element.
+
+In this guide, you'll learn how to use the Kbd component.
```tsx
import { Kbd } from "@medusajs/ui"
@@ -93260,8 +93786,6 @@ export default function KbdDemo() {
## Usage
-***
-
```tsx
import { Kbd } from "@medusajs/ui"
```
@@ -93270,10 +93794,10 @@ import { Kbd } from "@medusajs/ui"
Ctrl + Shift + A
```
-## API Reference
-
***
+## API Reference
+
### Kbd Props
This component is based on the \`kbd\` element and supports all of its props
@@ -93282,7 +93806,9 @@ This component is based on the \`kbd\` element and supports all of its props
# Label
-Renders an accessible label associated with controls.
+A component that renders an accessible label associated with input fields.
+
+In this guide, you'll learn how to use the Label component.
```tsx
import { Label } from "@medusajs/ui"
@@ -93295,8 +93821,6 @@ export default function LabelDemo() {
## Usage
-***
-
```tsx
import { Label } from "@medusajs/ui"
```
@@ -93305,10 +93829,10 @@ import { Label } from "@medusajs/ui"
```
-## API Reference
-
***
+## API Reference
+
### Label Props
This component is based on the \[Radix UI Label]\(https://www.radix-ui.com/primitives/docs/components/label) primitive.
@@ -93316,125 +93840,95 @@ This component is based on the \[Radix UI Label]\(https://www.radix-ui.com/primi
- size: (union) The label's size. Default: "base"
- weight: (union) The label's font weight. Default: "regular"
-## Examples
-
***
-### Base Regular
+## Examples
+
+### All Sizes
```tsx
import { Label } from "@medusajs/ui"
-export default function LabelBaseRegular() {
+export default function LabelAllSizes() {
return (
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
)
}
```
-### Base Plus
+### With Form Inputs
```tsx
-import { Label } from "@medusajs/ui"
+import { Label, Input } from "@medusajs/ui"
+import { Textarea, RadioGroup } from "@medusajs/ui"
-export default function LabelBasePlus() {
+export default function LabelWithInputs() {
return (
-
- )
-}
-
-```
-
-### Large Regular
-
-```tsx
-import { Label } from "@medusajs/ui"
-
-export default function LabelLargeRegular() {
- return (
-
- )
-}
-
-```
-
-### Large Plus
-
-```tsx
-import { Label } from "@medusajs/ui"
-
-export default function LabelLargePlus() {
- return (
-
- )
-}
-
-```
-
-### Small Regular
-
-```tsx
-import { Label } from "@medusajs/ui"
-
-export default function LabelSmallRegular() {
- return (
-
- )
-}
-
-```
-
-### Small Plus
-
-```tsx
-import { Label } from "@medusajs/ui"
-
-export default function LabelSmallPlus() {
- return (
-
- )
-}
-
-```
-
-### X-Small Regular
-
-```tsx
-import { Label } from "@medusajs/ui"
-
-export default function LabelXSmallRegular() {
- return (
-
- )
-}
-
-```
-
-### X-Small Plus
-
-```tsx
-import { Label } from "@medusajs/ui"
-
-export default function LabelXSmallPlus() {
- return (
-
+
)
}
@@ -93443,7 +93937,9 @@ export default function LabelXSmallPlus() {
# Progress Accordion
-A set of expandable content panels, specifically designed for implementing multi-step tasks
+A component that renders a set of expandable content, specifically designed for implementing multi-step tasks.
+
+In this guide, you'll learn how to use the Progress Accordion component.
```tsx
import { ProgressAccordion, Text } from "@medusajs/ui"
@@ -93487,8 +93983,6 @@ export default function ProgressAccordionDemo() {
## Usage
-***
-
```tsx
import { ProgressAccordion } from "@medusajs/ui"
```
@@ -93514,10 +94008,10 @@ import { ProgressAccordion } from "@medusajs/ui"
```
-## API Reference
-
***
+## API Reference
+
### ProgressAccordion Props
This component is based on the \[Radix UI Accordion]\(https://radix-ui.com/primitives/docs/components/accordion) primitves.
@@ -93528,11 +94022,11 @@ This component is based on the \[Radix UI Accordion]\(https://radix-ui.com/primi
- status: (union) The current status. Default: "not-started"
-## Examples
-
***
-### Single
+## Examples
+
+### Only One Accordion Open
```tsx
import { ProgressAccordion, Text } from "@medusajs/ui"
@@ -93574,7 +94068,7 @@ export default function ProgressAccordionSingle() {
```
-### Multiple
+### Allow Multiple Accordions to Open
```tsx
import { ProgressAccordion, Text } from "@medusajs/ui"
@@ -93616,10 +94110,163 @@ export default function ProgressAccordionSingle() {
```
+### Set Status Indicator
+
+```tsx
+import { ProgressAccordion, Text } from "@medusajs/ui"
+
+export default function ProgressAccordionStatus() {
+ return (
+
+ )
+}
+
+```
+
+### Disabled Accordion Item
+
+```tsx
+import { ProgressAccordion, Text } from "@medusajs/ui"
+
+export default function ProgressAccordionDisabled() {
+ return (
+
+
+
+ General
+
+
+ This step is enabled.
+
+
+
+
+ Shipping
+
+
+
+ This step is disabled and cannot be opened.
+
+
+
+
+
+
+ )
+}
+
+```
+
# Progress Tabs
-A set of layered content panels, known as tabs, specifically designed for implementing multi-step tasks
+A component that renders tabbed content, specifically designed for implementing multi-step tasks.
+
+In this guide, you'll learn how to use the Progress Tabs component.
```tsx
import { ProgressTabs, Text } from "@medusajs/ui"
@@ -93680,8 +94327,6 @@ export default function ProgressTabsDemo() {
## Usage
-***
-
```tsx
import { ProgressTabs } from "@medusajs/ui"
```
@@ -93693,7 +94338,7 @@ import { ProgressTabs } from "@medusajs/ui"
General
- Shipping
+ Shipping
Payment
@@ -93702,19 +94347,19 @@ import { ProgressTabs } from "@medusajs/ui"
{/* Content */}
-
- {/* Content */}
-
-
- {/* Content */}
+
+ {/* Content */}
+
+
+ {/* Content */}
```
-## API Reference
-
***
+## API Reference
+
### ProgressTabs Props
This component is based on the \[Radix UI Tabs]\(https://radix-ui.com/primitives/docs/components/tabs) primitves.
@@ -93727,14 +94372,165 @@ This component is based on the \[Radix UI Tabs]\(https://radix-ui.com/primitives
Mainly so arrow navigation is done accordingly (left & right vs. up & down)
- value: (string) The value for the selected tab, if controlled
-### ProgressTabs.ProgressIndicator Props
+### ProgressTabs.Trigger Props
-- status: (union) The current status.
+- status: (union) Default: "not-started"
+
+***
+
+## Examples
+
+### Set Status Indicator
+
+```tsx
+import { ProgressTabs, Text } from "@medusajs/ui"
+
+export default function ProgressTabsStatus() {
+ return (
+
+
+
+
+
+ General
+
+
+ Shipping
+
+
+ Payment
+
+
+
+
+
+ General step is completed.
+
+
+ Shipping step is in progress.
+
+
+ Payment step has not started.
+
+
+
+ This is the General step.
+
+
+ This is the Shipping step.
+
+
+ This is the Payment step.
+
+
+
+
+
+
+
+
+ )
+}
+
+```
+
+### Disabled Tab
+
+```tsx
+import { ProgressTabs, Text } from "@medusajs/ui"
+
+export default function ProgressTabsDisabled() {
+ return (
+
+
+
+
+ General
+
+ Shipping
+
+ Payment
+
+
+
+
+ This is the General step.
+
+
+ This is the Shipping step (disabled).
+
+
+ This is the Payment step.
+
+
+
+
+ )
+}
+
+```
# Prompt
-Displays a dialog triggered by a button
+A component that displays a dialog prompting the user for their approval. It's useful when confirming destructive actions.
+
+This component is useful if you want to control the prompt's content, format, and design. For a simpler approach that follows Medusa's prompt format, refer to the [usePrompt hook](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/ui/app/hooks/use-prompt/index.html.md).
+
+In this guide, you'll learn how to use the Prompt component.
```tsx
import { Button, Prompt } from "@medusajs/ui"
@@ -93765,8 +94561,6 @@ export default function PromptDemo() {
## Usage
-***
-
```tsx
import { Prompt } from "@medusajs/ui"
```
@@ -93787,10 +94581,10 @@ import { Prompt } from "@medusajs/ui"
```
-## API Reference
-
***
+## API Reference
+
### Prompt Props
This component is based on the \[Radix UI Alert Dialog]\(https://www.radix-ui.com/primitives/docs/components/alert-dialog) primitives.
@@ -93809,9 +94603,47 @@ This component is based on the \`div\` element and supports all of its props
+***
+
+## Examples
+
+### Confirmation Variant
+
+The `confirmation` variant is useful when confirming an operation that isn't destructive, such as deleting an item.
+
+```tsx
+import { Button, Prompt } from "@medusajs/ui"
+
+export default function PromptConfirmation() {
+ return (
+
+
+
+
+
+
+ Confirm Action
+
+ Are you sure you want to proceed? This action can be undone.
+
+
+
+ Cancel
+ Confirm
+
+
+
+ )
+}
+
+```
+
+
# Radio Group
-A set of checkable buttons—known as radio buttons—where no more than one of the buttons can be checked at a time.
+A component that renders a group of radio buttons using Medusa's design system.
+
+In this guide, you'll learn how to use the Radio Group component.
```tsx
import { Label, RadioGroup } from "@medusajs/ui"
@@ -93845,8 +94677,6 @@ export default function RadioGroupDemo() {
## Usage
-***
-
```tsx
import { RadioGroup } from "@medusajs/ui"
```
@@ -93859,21 +94689,21 @@ import { RadioGroup } from "@medusajs/ui"
```
-## API Reference
-
***
+## API Reference
+
### RadioGroup Props
This component is based on the \[Radix UI Radio Group]\(https://www.radix-ui.com/primitives/docs/components/radio-group) primitives.
-## Examples
-
***
-### With Descriptions
+## Examples
+
+### Radio Group with Descriptions
```tsx
import { Label, RadioGroup, Text } from "@medusajs/ui"
@@ -93920,7 +94750,44 @@ export default function RadioGroupDescriptions() {
```
-### With a disabled item
+### Controlled Radio Group
+
+```tsx
+import { Label, RadioGroup } from "@medusajs/ui"
+import * as React from "react"
+
+export default function RadioGroupControlled() {
+ const [value, setValue] = React.useState("1")
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Selected value: {value}
+
+ )
+}
+
+```
+
+### Radio Group with a Disabled Item
```tsx
import { Label, RadioGroup } from "@medusajs/ui"
@@ -93952,10 +94819,47 @@ export default function RadioGroupDisabled() {
```
+***
+
+## Radio Choice Box
+
+The `RadioGroup.ChoiceBox` component allows you to show a group of radio buttons, each in a box with a label and description.
+
+```tsx
+import { RadioGroup } from "@medusajs/ui"
+
+export default function RadioGroupChoiceBox() {
+ return (
+
+
+
+
+
+ )
+}
+
+```
+
+{/* TODO add API reference */}
+
# Select
-Displays a list of options for the user to pick from—triggered by a button.
+A component that displays a select form input using Medusa's design system.
+
+In this guide, you'll learn how to use the Select component.
```tsx
import { Select } from "@medusajs/ui"
@@ -93998,8 +94902,6 @@ const currencies = [
## Usage
-***
-
```tsx
import { Select } from "@medusajs/ui"
```
@@ -94019,10 +94921,10 @@ import { Select } from "@medusajs/ui"
```
-## API Reference
-
***
+## API Reference
+
### Select Props
This component is based on \[Radix UI Select]\(https://www.radix-ui.com/primitives/docs/components/select).
@@ -94073,11 +94975,11 @@ It's based on \[Radix UI Select Content]\(https://www.radix-ui.com/primitives/do
- sideOffset: (number) The distance of the content pop-up in pixels from the select input. Only available when position is set to popper. Default: 8
- collisionPadding: (union) The distance in pixels from the boundary edges where collision detection should occur. Only available when position is set to popper. Default: 24
-## Examples
-
***
-### Small
+## Examples
+
+### Small Select
```tsx
import { Select } from "@medusajs/ui"
@@ -94118,7 +95020,7 @@ const currencies = [
```
-### Item-Aligned Position
+### Select Item-Aligned Position
```tsx
import { Select } from "@medusajs/ui"
@@ -94159,7 +95061,7 @@ const currencies = [
```
-### Disabled
+### Disabled Select
```tsx
import { Select } from "@medusajs/ui"
@@ -94200,7 +95102,7 @@ const currencies = [
```
-### Grouped Items
+### Select with Grouped Items
```tsx
import { Select } from "@medusajs/ui"
@@ -94264,7 +95166,7 @@ const data = [
```
-### Controlled
+### Controlled Select
```tsx
import { Select } from "@medusajs/ui"
@@ -94311,21 +95213,21 @@ const currencies = [
# Status Badge
-Displays a status badge
+A component that displays the status of an item in a badge style. It's useful to indicate states like "Active", "Published", or "Draft".
+
+In this guide, you'll learn how to use the Status Badge component.
```tsx
import { StatusBadge } from "@medusajs/ui"
export default function StatusBadgeDemo() {
- return Status
+ return Draft
}
```
## Usage
-***
-
```tsx
import { StatusBadge } from "@medusajs/ui"
```
@@ -94334,82 +95236,36 @@ import { StatusBadge } from "@medusajs/ui"
Active
```
-## API Reference
-
***
+## API Reference
+
### StatusBadge Props
This component is based on the span element and supports all of its props
- color: (union) The status's color. Default: "grey"
-## Examples
-
***
-### Grey
+## Examples
+
+### Status Badge Colors
```tsx
import { StatusBadge } from "@medusajs/ui"
-export default function StatusBadgeGrey() {
- return Status
-}
-
-```
-
-### Red
-
-```tsx
-import { StatusBadge } from "@medusajs/ui"
-
-export default function StatusBadgeRed() {
- return Status
-}
-
-```
-
-### Green
-
-```tsx
-import { StatusBadge } from "@medusajs/ui"
-
-export default function StatusBadgeGreen() {
- return Status
-}
-
-```
-
-### Blue
-
-```tsx
-import { StatusBadge } from "@medusajs/ui"
-
-export default function StatusBadgeBlue() {
- return Status
-}
-
-```
-
-### Orange
-
-```tsx
-import { StatusBadge } from "@medusajs/ui"
-
-export default function StatusBadgeOrange() {
- return Status
-}
-
-```
-
-### Purple
-
-```tsx
-import { StatusBadge } from "@medusajs/ui"
-
-export default function StatusBadgePurple() {
- return Status
+export default function StatusBadgeAllColors() {
+ return (
+
+ Active
+ Error
+ Pending
+ Info
+ Archived
+ Draft
+
+ )
}
```
@@ -94417,7 +95273,9 @@ export default function StatusBadgePurple() {
# Switch
-A control that allows the user to toggle between checked and not checked.
+A component for toggling between two states, typically on and off. It's essentially a checkbox in the form of a switch.
+
+In this guide, you'll learn how to use the Switch component.
```tsx
import { Label, Switch } from "@medusajs/ui"
@@ -94435,8 +95293,6 @@ export default function SwitchDemo() {
## Usage
-***
-
```tsx
import { Switch } from "@medusajs/ui"
```
@@ -94445,39 +95301,77 @@ import { Switch } from "@medusajs/ui"
```
-## API Reference
-
***
+## API Reference
+
### Switch Props
This component is based on the \[Radix UI Switch]\(https://www.radix-ui.com/primitives/docs/components/switch) primitive.
- size: (union) The switch's size. Default: "base"
-## Examples
-
***
-### Small
+## Examples
+
+### Switch Sizes
```tsx
import { Label, Switch } from "@medusajs/ui"
-export default function SwitchSmall() {
+export default function SwitchAllSizes() {
return (
-
- )
-}
-
-```
-
# Table
-A Table component for displaying data.
+A component that displays data in a structured table format.
-If you're looking to add a table in your Medusa Admin Extensions with features like pagination and filters, refer to the [DataTable](https://docs.medusajs.com/components/data-table/index.html.md) component instead.
+In this guide, you'll learn how to use the Table component.
+
+If you're looking to add a table to your Medusa Admin customizations with advanced features like filters, search, sorting, and bulk actions, refer to the [DataTable](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/ui/app/components/data-table/index.html.md) component instead.
```tsx
import { Table } from "@medusajs/ui"
@@ -94636,8 +95494,6 @@ export default function TableDemo() {
## Usage
-***
-
```tsx
import { Table } from "@medusajs/ui"
```
@@ -94661,10 +95517,10 @@ import { Table } from "@medusajs/ui"
```
-## API Reference
-
***
+## API Reference
+
### Table Props
This component is based on the table element and its various children:
@@ -94703,10 +95559,10 @@ This component is based on the \`div\` element and supports all of its props
- nextPage: (signature) A function that handles navigating to the next page.
This function should handle retrieving data for the next page.
-## Examples
-
***
+## Examples
+
### Table with Pagination
```tsx
@@ -94851,14 +95707,16 @@ export default function TableDemo() {
# Tabs
-A set of layered content panels, known as tabs, that display content one panel at a time
+A component that displays tabbed content.
+
+In this guide, you'll learn how to use the Tabs component.
```tsx
import { Tabs, Text } from "@medusajs/ui"
export default function TabsDemo() {
return (
-
+
General
@@ -94900,6 +95758,10 @@ export default function TabsDemo() {
+
+ Use the left and right arrow keys to navigate between the tabs. You must
+ focus on a tab first.
+
)
}
@@ -94908,8 +95770,6 @@ export default function TabsDemo() {
## Usage
-***
-
```tsx
import { Tabs } from "@medusajs/ui"
```
@@ -94927,10 +95787,10 @@ import { Tabs } from "@medusajs/ui"
```
-## API Reference
-
***
+## API Reference
+
### Tabs Props
This component is based on the \[Radix UI Tabs]\(https://radix-ui.com/primitives/docs/components/tabs) primitves
@@ -94943,10 +95803,175 @@ This component is based on the \[Radix UI Tabs]\(https://radix-ui.com/primitives
Mainly so arrow navigation is done accordingly (left & right vs. up & down)
- value: (string) The value for the selected tab, if controlled
+***
+
+## Examples
+
+### Controlled Tabs
+
+```tsx
+import { Tabs, Text } from "@medusajs/ui"
+import { useState } from "react"
+
+export default function TabsControlled() {
+ const [value, setValue] = useState("general")
+ return (
+
+
+
+ General
+ Shipping
+ Payment
+
+
+
+ This is the General tab (controlled).
+
+
+ This is the Shipping tab (controlled).
+
+
+ This is the Payment tab (controlled).
+
+
+
+
+ Use the left and right arrow keys to navigate between the tabs. You must
+ focus on a tab first.
+
+
+ )
+}
+
+```
+
+### Tabs with a Disabled Tab
+
+```tsx
+import { Tabs, Text } from "@medusajs/ui"
+
+export default function TabsDisabled() {
+ return (
+
+
+ This is the General tab with an icon.
+
+
+ This is the Shipping tab with an icon.
+
+
+ This is the Payment tab with an icon.
+
+
+
+
+ Use the left and right arrow keys to navigate between the tabs. You must
+ focus on a tab first.
+
+
+ )
+}
+
+```
+
+### Vertical Tabs
+
+The `orientation` prop doesn't change the layout of the tabs, but it allows you to navigate between the tabs using the up and down arrow keys. You'll need to manually style the tabs vertically.
+
+```tsx
+import { Tabs, Text } from "@medusajs/ui"
+
+export default function TabsVertical() {
+ return (
+
+
+
+ General
+ Shipping
+ Payment
+
+
+
+ This is the General tab (vertical).
+
+
+ This is the Shipping tab (vertical).
+
+
+ This is the Payment tab (vertical).
+
+
+
+
+ Use the up and down arrow keys to navigate between the tabs. You must
+ focus on a tab first.
+
+
+ )
+}
+
+```
+
# Text
-Displays basic text.
+A component that displays text using the typography styles from Medusa's design system.
+
+In this guide, you'll learn how to use the Text component.
```tsx
import { Text } from "@medusajs/ui"
@@ -94959,8 +95984,6 @@ export default function TextDemo() {
## Usage
-***
-
```tsx
import { Text } from "@medusajs/ui"
```
@@ -94969,10 +95992,10 @@ import { Text } from "@medusajs/ui"
Text
```
-## API Reference
-
***
+## API Reference
+
### Text Props
This component is based on the \`p\` element and supports all of its props
@@ -94985,51 +96008,69 @@ This component is based on the \`p\` element and supports all of its props
- family: (union) The text's font family. Default: "sans"
- leading: (union) The text's line height. Default: "normal"
-## Examples
-
***
-### All variations
+## Examples
+
+### Text Sizes
```tsx
import { Text } from "@medusajs/ui"
-export default function TextExamples() {
+export default function TextSizes() {
return (
-
-
- Base Size, Regular Weight, Sans-Serif
-
-
- Base Size, Plus Weight, Sans-Serif
-
-
- Large Size, Regular Weight, Sans-Serif
-
-
- Large Size, Plus Weight, Sans-Serif
-
-
- XLarge Size, Regular Weight, Sans-Serif
-
-
- XLarge Size, Plus Weight, Sans-Serif
-
-
- Base Size, Regular Weight, Mono
-
-
- Large Size, Regular Weight, Mono
-
-
- Large Size, Plus Weight, Mono
-
-
- XLarge Size, Regular Weight, Mono
-
-
- XLarge Size, Plus Weight, Mono
-
+
+ Base size
+ Large size
+ XLarge size
+
+ )
+}
+
+```
+
+### Text Weights
+
+```tsx
+import { Text } from "@medusajs/ui"
+
+export default function TextWeights() {
+ return (
+
+ Regular weight
+ Plus weight
+
+ )
+}
+
+```
+
+### Text Fonts
+
+```tsx
+import { Text } from "@medusajs/ui"
+
+export default function TextFonts() {
+ return (
+
+ Sans font
+ Mono font
+
+ )
+}
+
+```
+
+### Text Leading
+
+```tsx
+import { Text } from "@medusajs/ui"
+
+export default function TextLeading() {
+ return (
+
+ Normal leading
+ Compact leading
)
}
@@ -95039,7 +96080,9 @@ export default function TextExamples() {
# Textarea
-Displays a form textarea.
+A component that displays a textarea field using Medusa's design system.
+
+In this guide, you'll learn how to use the Textarea component.
```tsx
import { Textarea } from "@medusajs/ui"
@@ -95052,8 +96095,6 @@ export default function TextAreaDemo() {
## Usage
-***
-
```tsx
import { Textarea } from "@medusajs/ui"
```
@@ -95062,19 +96103,70 @@ import { Textarea } from "@medusajs/ui"
```
-## API Reference
-
***
+## API Reference
+
### Textarea Props
This component is based on the \`textarea\` element and supports all of its props
-# Toast
+***
-A succinct message that is displayed temporarily.
+## Examples
+
+### Controlled Textarea
+
+```tsx
+import { useState } from "react"
+import { Textarea } from "@medusajs/ui"
+
+export default function TextareaControlled() {
+ const [value, setValue] = useState("")
+ return (
+
+
+ )
+}
+
+```
+
+### Disabled Textarea
+
+```tsx
+import { Textarea } from "@medusajs/ui"
+
+export default function TextareaDisabled() {
+ return (
+
+ )
+}
+
+```
+
+
+# Toaster and Toast Messages
+
+A component and utility for displaying brief messages to users, typically used for notifications or alerts. Toast messages appear momentarily on top of the application UI.
+
+You can display multiple toast messages at once, and they will be stacked neatly.
+
+In this guide, you'll learn how to use the Toaster component.
```tsx
import { Button, Toaster, toast } from "@medusajs/ui"
@@ -95100,54 +96192,63 @@ export default function ToasterDemo() {
## Usage
-***
-
-Import the `toast` utility and `Toaster` component from `@medusajs/ui`:
+First, import the `toast` utility and `Toaster` component from `@medusajs/ui`:
```tsx
import { Toaster, toast } from "@medusajs/ui"
```
-Then, add the `Toaster` component somewhere in your tree:
+Then, add the `Toaster` component somewhere in your tree hierarchy. For example, in your main application layout:
-```tsx
-
+```tsx highlights={[["6"]]}
+export default function AppLayout({ children }) {
+ return (
+
+
+ {children}
+
+
+
+ )
+}
```
-Finally, use the `toast` utility to display a toast:
+Finally, use the `toast` utility in your components to display a toast message:
-```tsx
-return (
-
-)
+```tsx highlights={[["5", "info", "Display an informational message"]]}
+export default function MyComponent() {
+ return (
+
+ )
+}
```
-## API Reference
-
***
+## API Reference
+
### Toast Utility Functions
-The `toast` utility has the following functions to display different variants of toasts:
+The `toast` utility has the following functions to display different variants of toast messages:
-- `info`
-- `error`
-- `success`
-- `warning`
-- `loading`
+- `info`: Display a toast message with an informational style.
+- `error`: Display a toast message with an error style.
+- `success`: Display a toast message with a success style.
+- `warning`: Display a toast message with a warning style.
+- `loading`: Display a toast message with a loading style.
Each of these functions accept two parameters:
1. A string indicating the title of the toast.
-2. An object of props to pass to the underlying `Toast` component.
+2. An object of [Toast component props](#toast-props).
### Toast Props
@@ -95173,160 +96274,131 @@ This component is based on the \[Toaster component of the Sonner library]\(https
Default: 4000
+***
+
## Examples
-***
+### Toast Variants
+
+The following example assumes you already have the `Toaster` component in [your application's tree](#usage).
+
+```tsx
+import {
+ CheckCircle,
+ ExclamationCircle,
+ InformationCircle,
+ Spinner,
+ XCircle,
+} from "@medusajs/icons"
+import { Button, toast } from "@medusajs/ui"
+
+export default function ToasterAllVariants() {
+ return (
+
+
+
+
+
+
+
+ )
+}
+
+```
### Dismissable Toast
+The following example assumes you already have the `Toaster` component in [your application's tree](#usage).
+
```tsx
-import { Button, Toaster, toast } from "@medusajs/ui"
+import { Button, toast } from "@medusajs/ui"
export default function DismissableToaster() {
return (
- <>
-
-
- >
+
)
}
```
-### Warning
+### Toast with Action
+
+The following example assumes you already have the `Toaster` component in [your application's tree](#usage).
```tsx
-import { Button, Toaster, toast } from "@medusajs/ui"
-
-export default function ToasterWarning() {
- return (
- <>
-
-
- >
- )
-}
-
-```
-
-### Error
-
-```tsx
-import { Button, Toaster, toast } from "@medusajs/ui"
-
-export default function ToasterError() {
- return (
- <>
-
-
- >
- )
-}
-
-```
-
-### Success
-
-```tsx
-import { Button, Toaster, toast } from "@medusajs/ui"
-
-export default function ToasterSuccess() {
- return (
- <>
-
-
- >
- )
-}
-
-```
-
-### Loading
-
-```tsx
-import { Button, Toaster, toast } from "@medusajs/ui"
-
-export default function ToasterLoading() {
- return (
- <>
-
-
- >
- )
-}
-
-```
-
-### With Action
-
-```tsx
-import { Button, Toaster, toast } from "@medusajs/ui"
+import { Button, toast } from "@medusajs/ui"
export default function ToasterWithAction() {
return (
- <>
-
-
- >
+
)
}
@@ -95335,7 +96407,9 @@ export default function ToasterWithAction() {
# Tooltip
-A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it.
+A component that displays a pop-up with additional information when hovering over or focusing on an element.
+
+In this guide, you'll learn how to use the Tooltip component.
```tsx
import { InformationCircleSolid } from "@medusajs/icons"
@@ -95354,17 +96428,17 @@ export default function TooltipDemo() {
## Usage
```tsx
-import { Tooltip, TooltipProvider } from "@medusajs/ui"
+import { Tooltip } from "@medusajs/ui"
```
```tsx
Trigger
```
-## API Reference
-
***
+## API Reference
+
### Tooltip Props
This component is based on the \[Radix UI Tooltip]\(https://www.radix-ui.com/primitives/docs/components/tooltip) primitive.
@@ -95380,10 +96454,10 @@ This component is based on the \[Radix UI Tooltip]\(https://www.radix-ui.com/pri
- onPointerDownOutside: (signature) Event handler called when the a \`pointerdown\` event happens outside of the \`Tooltip\`.
Can be prevented.
-## Usage Outside Medusa Admin
-
***
+## Usage Outside Medusa Admin with TooltipProvider
+
If you're using the `Tooltip` component in a project other than the Medusa Admin, make sure to include the `TooltipProvider` somewhere up in your component tree:
```tsx
@@ -95394,93 +96468,134 @@ If you're using the `Tooltip` component in a project other than the Medusa Admin
### TooltipProvider Reference
-***
-
### TooltipProvider Props
- delayDuration: (number) The duration from when the pointer enters the trigger until the tooltip gets opened. Default: 100
- skipDelayDuration: (number) How much time a user has to enter another trigger without incurring a delay again. Default: 300
- disableHoverableContent: (boolean) When \`true\`, trying to hover the content will result in the tooltip closing as the pointer leaves the trigger.
-
-# Introduction
-
-Primitives for building Medusa applications.
-
-Welcome to Medusa UI, a React implementation of the Medusa design system.
-It is a collection of components, hooks, utility functions, icons, and [Tailwind CSS](https://tailwindcss.com/) classes that can be used to build
-a consistent user interface across the Medusa Admin and other Medusa applications.
-
-## Packages
-
***
-Medusa UI is split into multiple packages. Each package is published to npm
-and can be installed separately.
+## Examples
-- `@medusajs/ui` - React components, hooks, and utility functions used
- in Medusa UI.
-- `@medusajs/ui-preset` - Tailwind CSS preset containing all the classes
- used in Medusa UI.
-- `@medusajs/icons` - Icons used in Medusa UI.
+### Changing Tooltip Side
-## About
+```tsx
+import { Tooltip } from "@medusajs/ui"
+import {
+ ArrowLongDown,
+ ArrowLongLeft,
+ ArrowLongRight,
+ ArrowLongUp,
+} from "@medusajs/icons"
-***
+export default function TooltipSides() {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
-At its core, Medusa UI is a styled and slightly opinionated implementation of [Radix Primitives](https://www.radix-ui.com/primitives).
-Our team have also referenced the fantastic [shadcn/ui](https://ui.shadcn.com/) for inspiration in certain implementations.
-
-Our team strongly believe in keeping the components simple and
-composable, much like Medusa's foundation. This allows you to build whatever you need. Our team have tried to avoid overloading
-the component API and, instead, leveraged the native HTML API, which gets implemented
-and respected accordingly, and passed to the underlying elements.
-
-
-# Installation
-
-How to install and setup Medusa UI.
-
-
-
-# Medusa Admin Extension
-
-How to install and use Medusa UI for building Admin extensions.
-
-## Installation
-
-***
-
-The `@medusajs/ui` package is a already installed as a dependency of the `@medusajs/admin` package. Due to this you can simply import the package and use it in your local Admin extensions.
-
-If you are building a Admin extension as part of a Medusa plugin, you can install the package as a dependency of your plugin.
-
-```bash
-npm install @medusajs/ui
```
-## Configuration
+### Set Tooltip Max Width
+
+```tsx
+import { Tooltip } from "@medusajs/ui"
+import { InformationCircleSolid } from "@medusajs/icons"
+
+export default function TooltipMaxWidth() {
+ return (
+
+
+
+ )
+}
+
+```
+
+
+# Install Medusa UI for Medusa Admin Customizations
+
+In this guide, you'll learn how to use Medusa UI for building Medusa Admin customizations.
+
+## Use Medusa UI in Medusa Admin
+
+The `@medusajs/ui` and `@medusajs/icons` packages are already installed as dependencies of the `@medusajs/admin-sdk` package in your Medusa project. They're installed by default in your Medusa plugins as well.
+
+So, you can import the packages and use them in your Medusa Admin customizations without any additional installation steps.
+
+For example, to use the UI and icon packages in a UI route:
+
+```tsx title="src/admin/routes/custom/page.tsx"
+import { defineRouteConfig } from "@medusajs/admin-sdk"
+import { ChatBubbleLeftRight } from "@medusajs/icons"
+import { Container, Heading } from "@medusajs/ui"
+
+const CustomPage = () => {
+ return (
+
+
+ This is my custom route
+
+
+ )
+}
+
+export const config = defineRouteConfig({
+ label: "Custom Route",
+ icon: ChatBubbleLeftRight,
+})
+
+export default CustomPage
+```
+
+In this example, you use the [Container](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/ui/app/components/container/index.html.md) and [Heading](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/ui/app/components/heading/index.html.md) components in the UI route. You also use the `ChatBubbleLeftRight` icon from the [Icons package](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/ui/app/icons/overview/index.html.md) for the UI route's sidebar item.
***
-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.
+## Related Resources
+
+If you're building Medusa Admin customizations, check out the following documentation guides:
+
+- [Admin Widgets](https://docs.medusajs.com/docs/learn/fundamentals/admin/widgets/index.html.md): Insert custom components into existing Medusa Admin pages.
+- [Admin UI Routes](https://docs.medusajs.com/docs/learn/fundamentals/admin/ui-routes/index.html.md): Add new pages to the Medusa Admin.
+- [Admin Components & Layouts](https://docs.medusajs.com/resources/admin-components/index.html.md): Use Medusa UI to implement common Medusa Admin components and layouts for a consistent design in your customizations.
-# Medusa UI Installation in Standalone Projects
+# Install Medusa UI in Standalone Projects
-Learn how to install and use Medusa UI in a standalone project.
+In this guide, you'll learn how to install and use Medusa UI in a standalone project.
-Medusa UI is a React UI library that, while intended for usage within Medusa projects, can also be used in any React project.
+Medusa UI is a React UI library that, while intended for use within Medusa projects, can also be used in any React project.
-The icons package is installed independently from Medusa UI. Learn how to install it in the [Icons](../icons/overview.mdx) guide.
+The icons package is installed independently from Medusa UI. Learn how to install it in the [Icons](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/ui/app/icons/overview/index.html.md) guide.
+
+***
## Medusa UI Compatibility
To use Medusa UI in your standalone project, you must have:
- React 18+ installed. Most React-based frameworks and libraries, such as Next.js and Vite, are compatible with this requirement.
-- [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.
- - Medusa UI was built with Tailwind CSS v3, but it may generally support v4 as well.
+- [Tailwind CSS](https://v3.tailwindcss.com/) installed. The components in Medusa UI are styled using Tailwind CSS, so you'll need to install it in your project as well.
+ - Medusa UI was built with Tailwind CSS v3, but it may also support v4.
***
@@ -95488,7 +96603,7 @@ To use Medusa UI in your standalone project, you must have:
In your standalone project, install the Medusa UI package with the following command:
-```bash
+```bash npm2yarn
npm install @medusajs/ui
```
@@ -95496,12 +96611,12 @@ npm install @medusajs/ui
## Step 2: Install UI Presets
-Medusa UI customizes Tailwind CSS classes to implement its design system. So, you must also install the Medusa UI preset package.
+Medusa UI customizes Tailwind CSS classes to implement its design system, so you must also install the Medusa UI preset package.
To install the Medusa UI preset, run the following command:
-```bash
-npm install @medusajs/ui-preset
+```bash npm2yarn
+npm install @medusajs/ui-preset --save-dev
```
***
@@ -95517,7 +96632,7 @@ In Tailwind CSS v3, which is the recommended version to use with Medusa UI, you
1. Add the Medusa UI preset to the `presets` array.
2. Ensure that the `content` field includes the path to the Medusa UI package.
-```js title="tailwind.config.js"
+```js title="tailwind.config.js" highlights={[["5"]]}
module.exports = {
presets: [require("@medusajs/ui-preset")],
content: [
@@ -95530,7 +96645,7 @@ module.exports = {
If your project is in a monorepo, you'll need to resolve the path to the `@medusajs/ui` package from the monorepo root:
-```tsx title="tailwind.config.js"
+```tsx title="tailwind.config.js" highlights={monorepoHighlights}
const path = require("path")
const uiPath = path.resolve(
@@ -95554,7 +96669,7 @@ module.exports = {
Medusa UI isn't officially compatible with Tailwind CSS v4 yet, so use it with caution.
-In your CSS file that imports Tailwind CSS, add the following `@config` and `@source` directives:
+In your CSS file that imports Tailwind CSS, add the following `@import`, `@config`, and `@source` directives:
```css
@import "tailwindcss";
@@ -95562,7 +96677,7 @@ In your CSS file that imports Tailwind CSS, add the following `@config` and `@so
@config "@medusajs/ui-preset";
```
-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.
+This will explicitly include the Medusa UI preset and its components in your Tailwind CSS build and apply the preset styles to your project.
***
@@ -95586,9 +96701,9 @@ Refer to the documentation of each component to learn about its props and usage.
## Update UI Packages in Standalone Projects
-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.
+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.
-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).
+So, to find the 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).
To update these packages in your standalone project, update their version in your `package.json` file and re-install dependencies. For example:
@@ -95602,15 +96717,73 @@ To update these packages in your standalone project, update their version in you
```
-# clx
+# Page Not Found
-Utility function for working with classNames.
+The page you were looking for isn't available.
-## Usage
+If you think this is a mistake, please [report this issue on GitHub](https://github.com/medusajs/medusa/issues/new?assignees=\&labels=type%3A+docs\&template=docs.yml).
+
+- [Get Started Docs](https://docs.medusajs.com//index.html.md)
+- [Commerce Modules](https://docs.medusajs.com/resources/commerce-modules/index.html.md)
+- [Admin API reference](https://docs.medusajs.com/api/admin)
+- [Store API reference](https://docs.medusajs.com/api/store)
+
+
+# Medusa UI Documentation
+
+Welcome to Medusa UI, a React implementation of the Medusa design system.
+
+Medusa UI is a collection of components, hooks, utility functions, icons, and [Tailwind CSS](https://tailwindcss.com/) classes that can be used to build
+a consistent user interface across the Medusa Admin and client applications.
***
-The `clx` function is a utility function for working with classNames. It is built using [clsx](https://www.npmjs.com/package/clsx) and [tw-merge](https://www.npmjs.com/package/tw-merge) and is intended to be used with [Tailwind CSS](https://tailwindcss.com/).
+## Packages
+
+Medusa UI is split into multiple packages. Each package is published to npm
+and can be installed separately.
+
+- `@medusajs/ui` - React components, hooks, and utility functions used
+ in Medusa UI.
+- `@medusajs/ui-preset` - Tailwind CSS preset containing all the classes
+ used in Medusa UI.
+- `@medusajs/icons` - Icons used in Medusa UI.
+
+Learn how to install and use these packages either for [Medusa Admin](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/ui/app/installation/medusa-admin-extension/index.html.md) customizations or a [standalone project](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/ui/app/installation/standalone-project/index.html.md).
+
+***
+
+## How Medusa UI is Built
+
+At its core, Medusa UI is a styled and slightly opinionated implementation of [Radix Primitives](https://www.radix-ui.com/primitives).
+Our team has also referenced the fantastic [shadcn/ui](https://ui.shadcn.com/) for inspiration in certain implementations.
+
+Our team strongly believes in keeping the components simple and
+composable, much like Medusa's foundation. This allows you to build whatever you need.
+
+Our team has tried to avoid overloading
+the component API and, instead, has leveraged the native HTML API, which gets implemented
+and respected accordingly, and passed to the underlying elements.
+
+
+# clx
+
+`clx` is a utility function that adds class names to your components, with support for conditional classes and merging Tailwind CSS classes.
+
+In this guide, you'll learn how to use the `clx` utility function.
+
+## Usage
+
+The `clx` function is built using [clsx](https://www.npmjs.com/package/clsx) and [tw-merge](https://www.npmjs.com/package/tw-merge). It is intended to be used with [Tailwind CSS](https://tailwindcss.com/) to efficiently add classes to your components.
+
+`clx` is useful for:
+
+- Conditionally apply classes based on props or state. For example, you can apply the `hidden` class if a component's `open` state variable is `false`.
+- Merge multiple strings into a single class name string. For example, you can apply class names to the component, and allow passing additional class names as props.
+- Override conflicting Tailwind CSS classes. For example, if you specify a `p-2` class name on your component, and you pass a `p-4` class name as a prop, the `p-4` class will take precedence.
+ - The last class name specified will take precedence over any previous class names.
+
+For example:
```tsx
import { clx } from "@medusajs/ui"
@@ -95638,11 +96811,48 @@ const Box = ({ className, children, mt }: BoxProps) => {
)
}
-
```
-In the above example the utility is used to apply a base style, a margin top that is dependent on the `mt` prop and a custom className.
-The Box component accepts a `className` prop that is merged with the other classNames, and the underlying usage of `tw-merge` ensures that all Tailwind CSS classes are merged without style conflicts.
+In the above example, you use `clx` to:
+
+- Apply a base style.
+- Apply a margin top that depends on the `mt` prop.
+- Add class names passed as a prop.
+
+`clx` ensures that Tailwind CSS classes are merged without style conflicts.
+
+***
+
+## API Reference
+
+### clx Parameters
+
+`clx` accepts any number of arguments, each of them can be of the following types:
+
+- `string`: A string of class names to apply.
+
+```tsx
+clx("flex items-center justify-between")
+```
+
+- `Record`: An object whose keys are the class names to apply, and the values are booleans indicating whether to apply the class names.
+
+```tsx
+clx({
+ "flex items-center justify-between": isFlex,
+})
+```
+
+- `Array`: An array of strings or objects to apply.
+
+```tsx
+clx([
+ "flex items-center justify-between",
+ {
+ "hidden": isHidden,
+ },
+])
+```
# B2B Recipe
diff --git a/www/apps/book/scripts/prepare.mjs b/www/apps/book/scripts/prepare.mjs
index 1dbbb4cf71..b6749283c5 100644
--- a/www/apps/book/scripts/prepare.mjs
+++ b/www/apps/book/scripts/prepare.mjs
@@ -265,7 +265,7 @@ async function main() {
},
},
{
- dir: path.join(process.cwd(), "..", "ui", "src", "content", "docs"),
+ dir: path.join(process.cwd(), "..", "ui", "app"),
options: {
parserOptions: {
ComponentExample: {
@@ -273,12 +273,18 @@ async function main() {
process.cwd(),
"..",
"ui",
- "src",
+ "specs",
"examples"
),
},
ComponentReference: {
- specsPath: path.join(process.cwd(), "..", "ui", "src", "specs"),
+ specsPath: path.join(
+ process.cwd(),
+ "..",
+ "ui",
+ "specs",
+ "components"
+ ),
},
},
},
diff --git a/www/apps/cloud/next.config.mjs b/www/apps/cloud/next.config.mjs
index a737c442c9..502aafdc3e 100644
--- a/www/apps/cloud/next.config.mjs
+++ b/www/apps/cloud/next.config.mjs
@@ -30,7 +30,6 @@ const withMDX = mdx({
},
ui: {
projectPath: path.resolve("..", "ui"),
- contentPath: "src/content/docs",
},
resources: {
projectPath: path.resolve("..", "resources"),
diff --git a/www/apps/resources/app/nextjs-starter/guides/customize-stripe/page.mdx b/www/apps/resources/app/nextjs-starter/guides/customize-stripe/page.mdx
index c154351cae..1814cfa8c5 100644
--- a/www/apps/resources/app/nextjs-starter/guides/customize-stripe/page.mdx
+++ b/www/apps/resources/app/nextjs-starter/guides/customize-stripe/page.mdx
@@ -740,7 +740,7 @@ export const paymentInfoMap: Record<
For every payment method you want to customize its display, add an entry in the `paymentInfoMap` object. The key should match the [type enum in Stripe's Payment Element](https://docs.stripe.com/api/payment_methods/object#payment_method_object-type), and the value is an object with the following properties:
- `title`: The title to display for the payment method.
-- `icon`: A JSX element representing the icon for the payment method. You can use icons from [Medusa UI](!ui!/icons) or custom icons.
+- `icon`: A JSX element representing the icon for the payment method. You can use icons from [Medusa UI](!ui!/icons/overview) or custom icons.
### Test it out
diff --git a/www/apps/resources/next.config.mjs b/www/apps/resources/next.config.mjs
index 1e30c666e2..1bb6b412ef 100644
--- a/www/apps/resources/next.config.mjs
+++ b/www/apps/resources/next.config.mjs
@@ -33,7 +33,6 @@ const withMDX = mdx({
},
ui: {
projectPath: path.resolve("..", "ui"),
- contentPath: "src/content/docs",
},
"user-guide": {
projectPath: path.resolve("..", "user-guide"),
diff --git a/www/apps/ui/.content.eslintrc.mjs b/www/apps/ui/.content.eslintrc.mjs
index 07e2e6627f..2bf2814dd3 100644
--- a/www/apps/ui/.content.eslintrc.mjs
+++ b/www/apps/ui/.content.eslintrc.mjs
@@ -150,7 +150,7 @@ export default [
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
"@typescript-eslint/ban-types": "off",
- "@typescript-eslint/no-require-imports": "warn",
+ "@typescript-eslint/no-require-imports": "off",
},
},
]
diff --git a/www/apps/ui/.env.example b/www/apps/ui/.env.example
index 6f79aaa3ac..d51fa7e024 100644
--- a/www/apps/ui/.env.example
+++ b/www/apps/ui/.env.example
@@ -1,11 +1,19 @@
-NEXT_PUBLIC_DOCS_URL=
-NEXT_PUBLIC_BASE_URL=
-NEXT_PUBLIC_BASE_PATH=/ui
+NEXT_PUBLIC_SEGMENT_API_KEY=
NEXT_PUBLIC_DOCS_ALGOLIA_INDEX_NAME=
NEXT_PUBLIC_API_ALGOLIA_INDEX_NAME=
NEXT_PUBLIC_ALGOLIA_API_KEY=
NEXT_PUBLIC_ALGOLIA_APP_ID=
-NEXT_PUBLIC_SEGMENT_API_KEY=
+NEXT_PUBLIC_ENV=
+NEXT_PUBLIC_BASE_URL=
+NEXT_PUBLIC_BASE_PATH=
+NEXT_PUBLIC_DOCS_URL=
+NEXT_PUBLIC_RESOURCES_URL=
+NEXT_PUBLIC_UI_URL=
+NEXT_PUBLIC_API_URL=
+NEXT_PUBLIC_USER_GUIDE_URL=
+ALGOLIA_WRITE_API_KEY=
+ANALYZE_BUNDLE=
+CLOUDINARY_CLOUD_NAME=
NEXT_PUBLIC_GA_ID=
NEXT_PUBLIC_INTEGRATION_ID=
NEXT_PUBLIC_REO_DEV_CLIENT_ID=
\ No newline at end of file
diff --git a/www/apps/ui/.gitignore b/www/apps/ui/.gitignore
index f44890178b..fd3dbb571a 100644
--- a/www/apps/ui/.gitignore
+++ b/www/apps/ui/.gitignore
@@ -4,6 +4,7 @@
/node_modules
/.pnp
.pnp.js
+.yarn/install-state.gz
# testing
/coverage
@@ -33,6 +34,3 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
-
-# contentlayer
-.contentlayer
diff --git a/www/apps/ui/.yarnrc.yml b/www/apps/ui/.yarnrc.yml
deleted file mode 100644
index 1b1262b240..0000000000
--- a/www/apps/ui/.yarnrc.yml
+++ /dev/null
@@ -1 +0,0 @@
-nmMode: hardlinks-local
\ No newline at end of file
diff --git a/www/apps/ui/app/colors/overview/page.mdx b/www/apps/ui/app/colors/overview/page.mdx
new file mode 100644
index 0000000000..5d98e25c02
--- /dev/null
+++ b/www/apps/ui/app/colors/overview/page.mdx
@@ -0,0 +1,39 @@
+---
+generate_toc: true
+---
+
+import { Colors } from "@/components/Colors"
+
+export const metadata = {
+ title: `Medusa UI Colors`,
+}
+
+# {metadata.title}
+
+In this guide, you'll learn about the color classes available in Medusa UI and how to use them.
+
+## Overview
+
+Medusa UI provides Tailwind CSS classes for colors from the Medusa design system. These classes can be used to style components and elements consistently across your Medusa and standalone applications.
+
+To view the colors in the list below in dark mode, switch the documentation's theme from the menu in the top right.
+
+To copy a color's Tailwind CSS class from the list below, click on it.
+
+### How to Use the Medusa UI Colors
+
+You can use the color classes in your Medusa Admin customizations or standalone projects that have the `@medusajs/ui` package installed.
+
+You can apply the color classes as CSS classes to any element.
+
+For example, to set the background color of the document's body:
+
+```tsx
+
+ ...
+
+```
+
+---
+
+
\ No newline at end of file
diff --git a/www/apps/ui/src/content/docs/components/alert.mdx b/www/apps/ui/app/components/alert/page.mdx
similarity index 51%
rename from www/apps/ui/src/content/docs/components/alert.mdx
rename to www/apps/ui/app/components/alert/page.mdx
index 369c07af9d..e8492465c0 100644
--- a/www/apps/ui/src/content/docs/components/alert.mdx
+++ b/www/apps/ui/app/components/alert/page.mdx
@@ -1,15 +1,22 @@
----
-title: "Alert"
-description: "A component for displaying important messages."
-component: true
----
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Alert`,
+}
+
+# {metadata.title}
+
+A component for displaying important messages.
+
+In this guide, you'll learn how to use the Alert component.
-## Usage
-
---
+## Usage
+
```tsx
import { Alert } from "@medusajs/ui"
```
@@ -18,16 +25,16 @@ import { Alert } from "@medusajs/ui"
Here's a message
```
-## API Reference
-
---
+## API Reference
+
-## Examples
-
---
+## Examples
+
### Success Alert
@@ -40,6 +47,7 @@ import { Alert } from "@medusajs/ui"
-### Dismissable Alert
+### Dismissible Alert
+
+
-
\ No newline at end of file
diff --git a/www/apps/ui/app/components/avatar/page.mdx b/www/apps/ui/app/components/avatar/page.mdx
new file mode 100644
index 0000000000..6dd5112a37
--- /dev/null
+++ b/www/apps/ui/app/components/avatar/page.mdx
@@ -0,0 +1,59 @@
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Avatar`,
+}
+
+# {metadata.title}
+
+A component for displaying user avatars with a fallback option.
+
+In this guide, you'll learn how to use the Avatar component.
+
+
+
+## Usage
+
+```tsx
+import { Avatar } from "@medusajs/ui"
+```
+
+```tsx
+
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Examples
+
+### Avatar Variants
+
+
+
+### Avatar Sizes
+
+
+
+### Avatar Fallback Only
+
+
+
+### Avatar Custom Styling
+
+
+
+### Avatar Accessibility
+
+You can add the `aria-label` prop to the Avatar component for better accessibility.
+
+
diff --git a/www/apps/ui/app/components/badge/page.mdx b/www/apps/ui/app/components/badge/page.mdx
new file mode 100644
index 0000000000..32b15f0be6
--- /dev/null
+++ b/www/apps/ui/app/components/badge/page.mdx
@@ -0,0 +1,46 @@
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Badge`,
+}
+
+# {metadata.title}
+
+A component for displaying labels or indicators in a badge style.
+
+In this guide, you'll learn how to use the Badge component.
+
+
+
+## Usage
+
+```tsx
+import { Badge } from "@medusajs/ui"
+```
+
+```tsx
+Badge
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Examples
+
+### Badge Colors
+
+
+
+### Badge Sizes
+
+
+
+### Badge Rounded Variants
+
+
\ No newline at end of file
diff --git a/www/apps/ui/app/components/button/page.mdx b/www/apps/ui/app/components/button/page.mdx
new file mode 100644
index 0000000000..90679062b6
--- /dev/null
+++ b/www/apps/ui/app/components/button/page.mdx
@@ -0,0 +1,56 @@
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Button`,
+}
+
+# {metadata.title}
+
+A component for rendering buttons using Medusa's design system.
+
+In this guide, you'll learn how to use the Button component.
+
+
+
+---
+
+## Usage
+
+```tsx
+import { Button } from "@medusajs/ui"
+```
+
+```tsx
+
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Examples
+
+### Button Variants
+
+
+
+### Button Sizes
+
+
+
+### Button Loading State
+
+
+
+### Button with Icon
+
+
+
+### Button as Link
+
+
diff --git a/www/apps/ui/app/components/calendar/page.mdx b/www/apps/ui/app/components/calendar/page.mdx
new file mode 100644
index 0000000000..639efd1a6a
--- /dev/null
+++ b/www/apps/ui/app/components/calendar/page.mdx
@@ -0,0 +1,46 @@
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Calendar`,
+}
+
+# {metadata.title}
+
+A component for displaying a calendar interface with date selection capability.
+
+In this guide, you'll learn how to use the Calendar component.
+
+
+
+## Usage
+
+```tsx
+import { Calendar } from "@medusajs/ui"
+```
+
+```tsx
+
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Examples
+
+### Controlled
+
+
+
+### Min/Max Dates
+
+
+
+### Unavailable Dates
+
+
diff --git a/www/apps/ui/app/components/checkbox/page.mdx b/www/apps/ui/app/components/checkbox/page.mdx
new file mode 100644
index 0000000000..39461edee3
--- /dev/null
+++ b/www/apps/ui/app/components/checkbox/page.mdx
@@ -0,0 +1,42 @@
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Checkbox`,
+}
+
+# {metadata.title}
+
+A component for rendering checkbox inputs using Medusa's design system.
+
+In this guide, you'll learn how to use the Checkbox component.
+
+
+
+## Usage
+
+```tsx
+import { Checkbox } from "@medusajs/ui"
+```
+
+```tsx
+
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Examples
+
+### Checkbox All States
+
+
+
+### Controlled Checkbox
+
+
diff --git a/www/apps/ui/src/content/docs/components/code-block.mdx b/www/apps/ui/app/components/code-block/page.mdx
similarity index 70%
rename from www/apps/ui/src/content/docs/components/code-block.mdx
rename to www/apps/ui/app/components/code-block/page.mdx
index 897e288e4b..9e121a1421 100644
--- a/www/apps/ui/src/content/docs/components/code-block.mdx
+++ b/www/apps/ui/app/components/code-block/page.mdx
@@ -1,15 +1,24 @@
---
-title: "Code Block"
-description: "Allows you to render highlighted code snippets"
-component: true
+generate_toc: true
---
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Code Block`,
+}
+
+# {metadata.title}
+
+A component for displaying code snippets with syntax highlighting and copy functionality.
+
+In this guide, you'll learn how to use the Code Block component.
+
## Usage
----
-
```tsx
import { CodeBlock } from "@medusajs/ui"
```
@@ -29,11 +38,10 @@ import { CodeBlock } from "@medusajs/ui"
```
+---
## API Reference
----
-
-## Usage Outside Medusa Admin
-
---
-If you're using the `CodeBlock` component in a project other than the Medusa Admin, make sure to include the `TooltipProvider` somewhere up in your component tree, as the `CodeBlock.Header` component uses a [Tooltip](/components/tooltip#usage-outside-medusa-admin):
+## Usage Outside Medusa Admin
+
+If you're using the `CodeBlock` component in a project other than the Medusa Admin, make sure to include the `TooltipProvider` somewhere up in your component tree, as the `CodeBlock.Header` component uses a [Tooltip](../tooltip/page.mdx#usage-outside-medusa-admin):
```tsx
@@ -64,11 +72,11 @@ If you're using the `CodeBlock` component in a project other than the Medusa Adm
```
-## Examples
-
---
-### Single snippet
+## Examples
+
+### Single Snippet
If you want to only show a code sample for one language or API, you can choose to hide the snippet labels:
@@ -76,7 +84,7 @@ If you want to only show a code sample for one language or API, you can choose t
### No Header
-You could also choose to omit the header entirely:
+You can also omit the header entirely:
@@ -86,4 +94,4 @@ You could also choose to omit the header entirely:
### No Copy Button
-
+
diff --git a/www/apps/ui/src/content/docs/components/command-bar.mdx b/www/apps/ui/app/components/command-bar/page.mdx
similarity index 62%
rename from www/apps/ui/src/content/docs/components/command-bar.mdx
rename to www/apps/ui/app/components/command-bar/page.mdx
index ca4f1bb594..cee41d0ee9 100644
--- a/www/apps/ui/src/content/docs/components/command-bar.mdx
+++ b/www/apps/ui/app/components/command-bar/page.mdx
@@ -1,15 +1,24 @@
---
-title: "Command Bar"
-description: "Display a command bar with a list of commands"
-component: true
+generate_toc: true
---
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Command Bar`,
+}
+
+# {metadata.title}
+
+A component that displays a command bar with a list of commands to perform on a bulk selection of items.
+
+In this guide, you'll learn how to use the Command Bar component.
+
## Usage
----
-
```tsx
import { CommandBar } from "@medusajs/ui"
```
@@ -34,14 +43,15 @@ import { CommandBar } from "@medusajs/ui"
```
-## API Reference
-
---
+## API Reference
+
+]} hideFeedback />
+
diff --git a/www/apps/ui/src/content/docs/components/command.mdx b/www/apps/ui/app/components/command/page.mdx
similarity index 61%
rename from www/apps/ui/src/content/docs/components/command.mdx
rename to www/apps/ui/app/components/command/page.mdx
index defde5fe8e..5e1f040de0 100644
--- a/www/apps/ui/src/content/docs/components/command.mdx
+++ b/www/apps/ui/app/components/command/page.mdx
@@ -1,15 +1,20 @@
----
-title: "Command"
-description: "Renders an unhighlighted code block, useful for one-liners or API Routes"
-component: true
----
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Command`,
+}
+
+# {metadata.title}
+
+A component that renders an unhighlighted code block, useful for one-liners or API routes.
+
+In this guide, you'll learn how to use the Command component.
## Usage
----
-
```tsx
import { Command } from "@medusajs/ui"
```
@@ -20,17 +25,17 @@ import { Command } from "@medusajs/ui"
```
-## API Reference
-
---
+## API Reference
+
-## Usage Outside Medusa Admin
-
---
-If you're using the `Command` component in a project other than the Medusa Admin, make sure to include the `TooltipProvider` somewhere up in your component tree, as the `Command.Copy` component uses a [Tooltip](/components/tooltip#usage-outside-medusa-admin):
+## Usage Outside Medusa Admin
+
+If you're using the `Command` component in a project other than the Medusa Admin, make sure to include the `TooltipProvider` somewhere up in your component tree, as the `Command.Copy` component uses a [Tooltip](../tooltip/page.mdx#usage-outside-medusa-admin):
```tsx
@@ -42,4 +47,4 @@ If you're using the `Command` component in a project other than the Medusa Admin
/>
-```
\ No newline at end of file
+```
diff --git a/www/apps/ui/app/components/container/page.mdx b/www/apps/ui/app/components/container/page.mdx
new file mode 100644
index 0000000000..31b45ca0ae
--- /dev/null
+++ b/www/apps/ui/app/components/container/page.mdx
@@ -0,0 +1,38 @@
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Container`,
+}
+
+# {metadata.title}
+
+A component that wraps content in a card-like container. The container is useful to create sections in the Medusa Admin dashboard.
+
+In this guide, you'll learn how to use the Container component.
+
+
+
+## Usage
+
+```tsx
+import { Container } from "@medusajs/ui"
+```
+
+```tsx
+Container
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Examples
+
+### In a Layout
+
+
diff --git a/www/apps/ui/app/components/copy/page.mdx b/www/apps/ui/app/components/copy/page.mdx
new file mode 100644
index 0000000000..e838159a62
--- /dev/null
+++ b/www/apps/ui/app/components/copy/page.mdx
@@ -0,0 +1,56 @@
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Copy`,
+}
+
+# {metadata.title}
+
+A component that wraps content in a button with copy functionality. It is useful for quickly copying text to the clipboard, such as code snippets or configuration commands.
+
+In this guide, you'll learn how to use the Copy component.
+
+
+
+## Usage
+
+```tsx
+import { Copy } from "@medusajs/ui"
+```
+
+```tsx
+
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Usage Outside Medusa Admin
+
+If you're using the `Copy` component in a project other than the Medusa Admin, make sure to include the `TooltipProvider` somewhere up in your component tree, as the `Copy` component uses a [Tooltip](../tooltip/page.mdx#usage-outside-medusa-admin):
+
+```tsx
+
+
+
+```
+
+---
+
+## Examples
+
+### Copy with Custom Display
+
+
+
+### Copy Display As Child
+
+Using the `asChild` prop, you can render the `` as its child. This is useful if you want to render a custom button, to prevent rendering a button inside a button.
+
+
diff --git a/www/apps/ui/app/components/currency-input/page.mdx b/www/apps/ui/app/components/currency-input/page.mdx
new file mode 100644
index 0000000000..b27eb56966
--- /dev/null
+++ b/www/apps/ui/app/components/currency-input/page.mdx
@@ -0,0 +1,56 @@
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Currency Input`,
+}
+
+# {metadata.title}
+
+A component for rendering form inputs for money amounts, showing the currency in the input.
+
+In this guide, you'll learn how to use the Currency Input component.
+
+
+
+## Usage
+
+```tsx
+import { CurrencyInput } from "@medusajs/ui"
+```
+
+```tsx
+
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Examples
+
+### Controlled Currency Input
+
+
+
+### Disabled Currency Input
+
+
+
+### Currency Input with Error State
+
+
+
+### Currency Input Sizes
+
+#### Base
+
+
+
+#### Small
+
+
\ No newline at end of file
diff --git a/www/apps/ui/src/content/docs/components/data-table.mdx b/www/apps/ui/app/components/data-table/page.mdx
similarity index 97%
rename from www/apps/ui/src/content/docs/components/data-table.mdx
rename to www/apps/ui/app/components/data-table/page.mdx
index 79cb9f592c..d1db30d050 100644
--- a/www/apps/ui/src/content/docs/components/data-table.mdx
+++ b/www/apps/ui/app/components/data-table/page.mdx
@@ -1,26 +1,33 @@
---
-title: "DataTable"
-description: "A Table component with advanced functionalities like pagination, filtering, and more."
+generate_toc: true
---
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+import { Feedback } from "@/components/Feedback"
+
+export const metadata = {
+ title: `Data Table`,
+}
+
+# {metadata.title}
+
+A component to display a table of data with advanced functionalities like pagination, filtering, and more.
+
+In this guide, you'll learn how to use the DataTable component.
+
The `DataTable` component is useful if you're displaying large data with functionalities like pagination, filtering, sorting, and searching. It's also the recommended table component to use when creating customizations in the Medusa Admin.
-This component is available after Medusa UI v4.0.4 (or Medusa v2.4.0). It is built on top of the [Table](/components/table) component. If you want a table with more control over its styling and functionality, use that component instead.
+This component is available after Medusa UI v4.0.4 (or Medusa v2.4.0). It is built on top of the [Table](../table/page.mdx) component. If you want a table with more control over its styling and functionality, use that component instead.
-## Simple Example
-
----
-
## Usage
----
-
You import the `DataTable` component from `@medusajs/ui`.
```tsx
@@ -29,7 +36,7 @@ import {
} from "@medusajs/ui"
```
-### Columns Preparation
+### Data Table Columns Preparation
Before using the `DataTable` component, you need to prepare its columns using the `createDataTableColumnHelper` utility:
@@ -61,14 +68,14 @@ const columns = [
]
```
-The `createDataTableColumnHelper` utility is a function that returns a helper used to generates column configurations for the `DataTable` component.
+The `createDataTableColumnHelper` utility is a function that returns a helper used to generate column configurations for the `DataTable` component.
For each column in the table, use the `accessor` method of the column helper to specify configurations for a specific column. The `accessor` method accepts the column's key in the table's data as the first parameter, and an object with the following properties as the second parameter:
- `header`: The table header text for the column.
- `enableSorting`: (optional) A boolean that indicates whether data in the table can be sorted by this column. More on sorting in [this section](#configure-sorting-in-datatable).
-### Create Table Instance
+### Create Data Table Instance
The `DataTable` component expects a table instance created using the `useDataTable` hook. Import that hook from `@medusajs/ui`:
@@ -126,10 +133,10 @@ In the `DataTable` component, you pass the following child components:
Refer to the examples later on this page to learn how to add pagination, filtering, and other functionalities using the `DataTable` component.
-## API Reference
-
---
+## API Reference
+
-## Example with Data Fetching
-
---
+## Example with Data Fetching
+
Refer to [this Admin Components guide](https://docs.medusajs.com/resources/admin-components/components/data-table) for an example on using the `DataTable` component with data fetching from the Medusa application.
-## Handle Row Click
-
---
+## Handle Row Click
+
In many cases, you want to perform an action when a row is clicked. Most commonly, you may want to open the details page of the row when it's clicked.
@@ -175,15 +182,15 @@ const table = useDataTable({
The value of `onRowClick` is a function that accepts two parameters:
-- `event`: An instance of the [MouseClickEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) object.
+- `event`: An instance of the [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) object.
- `row`: The data of the row that was clicked.
In the above example, you use a `navigate` function, retrieved through the `useNavigate` hook from `react-router-dom`, to navigate to the details page of the row that was clicked.
-## Configure Cell Rendering
-
---
+## Configure Cell Rendering
+
The `accessor` method of the `createDataTableColumnHelper` utility accepts a `cell` property that you can use to customize the rendering of the cell content.
@@ -226,10 +233,10 @@ const columns = [
The `cell` property's value is a function that returns a string or a React node to be rendered in the cell. The function receives as a parameter an object having a `getValue` property to get the raw value of the cell.
-## Configure Search in DataTable
-
---
+## Configure Search in DataTable
+
The object passed to the `useDataTable` hook accepts a `search` property that you can use to enable and configure the search functionality in the `DataTable` component:
@@ -294,10 +301,10 @@ return (
This will show a search input at the top of the table, in the data table's toolbar.
-## Configure Pagination in DataTable
-
---
+## Configure Pagination in DataTable
+
The object passed to the `useDataTable` hook accepts a `pagination` property that you can use to enable and configure the pagination functionality in the `DataTable` component.
@@ -390,10 +397,10 @@ return (
This will show the pagination controls at the end of the table.
-## Configure Filters in DataTable
-
---
+## Configure Filters in DataTable
+
The object passed to the `useDataTable` hook accepts a `filters` property that you can use to enable and configure the filtering functionality in the `DataTable` component.
@@ -553,7 +560,7 @@ return (
This will show a filter menu at the top of the table, in the data table's toolbar.
-### Filtering Date Values
+### Filtering Date Values in DataTable
@@ -645,7 +652,7 @@ const shownProducts = useMemo(() => {
}, [filtering])
```
-### Initial Filter Values
+### Initial Filter Values in DataTable
@@ -659,10 +666,10 @@ const [filtering, setFiltering] = useState({
The user can still change the filter values, but the initial values will be applied when the table is first rendered.
-## Configure Sorting in DataTable
-
---
+## Configure Sorting in DataTable
+
The object passed to the `useDataTable` hook accepts a `sorting` property that you can use to enable and configure the sorting functionality in the `DataTable` component.
@@ -785,7 +792,7 @@ return (
This will show a sorting menu at the top of the table, in the data table's toolbar.
-### Initial Sort Values
+### Initial Sort Values in DataTable
@@ -800,10 +807,10 @@ const [sorting, setSorting] = useState({
The user can still change the sort values, but the initial values will be applied when the table is first rendered.
-## Perform Bulk Actions on DataTable Rows
-
---
+## Perform Bulk Actions on DataTable Rows
+
The object passed to the `useDataTable` hook accepts a `commands` object property that you can use to add custom actions to the `DataTable` component.
@@ -913,4 +920,4 @@ return (
)
```
-This will show a command bar when the user has selected at least one row in the table.
\ No newline at end of file
+This will show a command bar when the user has selected at least one row in the table.
diff --git a/www/apps/ui/src/content/docs/components/date-picker.mdx b/www/apps/ui/app/components/date-picker/page.mdx
similarity index 71%
rename from www/apps/ui/src/content/docs/components/date-picker.mdx
rename to www/apps/ui/app/components/date-picker/page.mdx
index 11b1d31052..5bccd25af4 100644
--- a/www/apps/ui/src/content/docs/components/date-picker.mdx
+++ b/www/apps/ui/app/components/date-picker/page.mdx
@@ -1,15 +1,20 @@
----
-title: "Date Picker"
-description: "A date picker component with range and presets."
-component: true
----
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Date Picker`,
+}
+
+# {metadata.title}
+
+A component for rendering date picker inputs with range and presets.
+
+In this guide, you'll learn how to use the Date Picker component.
## Usage
----
-
```tsx
import { DatePicker } from "@medusajs/ui"
```
@@ -18,16 +23,16 @@ import { DatePicker } from "@medusajs/ui"
```
-## API Reference
-
---
+## API Reference
+
-## Examples
-
---
+## Examples
+
### Controlled Date Picker
Manage and store the value of the date picker in a state variable for controlled behavior. This is also useful for form integration.
@@ -40,7 +45,7 @@ Enable time selection with different granularity levels for precise scheduling.
-### Min/Max Values
+### Date Picker Min/Max Values
Restrict date selection to a specific range by setting minimum and maximum values.
@@ -48,7 +53,7 @@ In the example below, you can only select dates within the next 30 days. Dates o
-### Disabled Dates
+### Date Picker Disabled Dates
Disable specific dates like weekends and holidays to prevent selection of unavailable dates.
@@ -56,14 +61,14 @@ The example below disables weekends and holidays like Christmas.
-### Granularity Options
+### Date Picker Granularity Options
Different levels of time precision from date-only to second-precision selection.
-### Form Integration
+### Date Picker Form Integration
The following example shows how to use the date picker in a form, with simulated form submission.
-
+
\ No newline at end of file
diff --git a/www/apps/ui/src/content/docs/components/drawer.mdx b/www/apps/ui/app/components/drawer/page.mdx
similarity index 51%
rename from www/apps/ui/src/content/docs/components/drawer.mdx
rename to www/apps/ui/app/components/drawer/page.mdx
index a1ea942cec..0a3d1b8623 100644
--- a/www/apps/ui/src/content/docs/components/drawer.mdx
+++ b/www/apps/ui/app/components/drawer/page.mdx
@@ -1,15 +1,24 @@
---
-title: "Drawer"
-description: "A triggerable drawer that overlaps whatever page it's on."
-component: true
+generate_toc: true
---
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Drawer`,
+}
+
+# {metadata.title}
+
+A component for rendering a sliding panel that overlays the main content.
+
+In this guide, you'll learn how to use the Drawer component.
+
## Usage
----
-
```tsx
import { Drawer } from "@medusajs/ui"
```
@@ -27,10 +36,10 @@ import { Drawer } from "@medusajs/ui"
```
-## API Reference
-
---
+## API Reference
+
\ No newline at end of file
+]} />
+
+---
+
+## Examples
+
+### Drawer with Form
+
+This example shows a simple form inside a Drawer, demonstrating how to use form elements and handle submission.
+
+
\ No newline at end of file
diff --git a/www/apps/ui/app/components/dropdown-menu/page.mdx b/www/apps/ui/app/components/dropdown-menu/page.mdx
new file mode 100644
index 0000000000..550000da1d
--- /dev/null
+++ b/www/apps/ui/app/components/dropdown-menu/page.mdx
@@ -0,0 +1,79 @@
+---
+generate_toc: true
+---
+
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+import { getOsShortcut, Kbd } from "docs-ui"
+
+export const osShortcut = getOsShortcut()
+
+export const metadata = {
+ title: `Dropdown Menu`,
+}
+
+# {metadata.title}
+
+A component for rendering dropdown menus that display a set of actions or options to users.
+
+In this guide, you'll learn how to use the Dropdown Menu component.
+
+
+
+## Usage
+
+```tsx
+import { DropdownMenu } from "@medusajs/ui"
+```
+
+```tsx
+
+ Trigger
+
+ Edit
+ Add
+ Delete
+
+
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Examples
+
+### Sorting
+
+This example shows how to display collection sorting choices using a Dropdown Menu.
+
+
+
+### Dropdown with Submenu
+
+
+
+### Disabled Items and Using Icons
+
+
+
+### Keyboard Shortcuts (with handling)
+
+This example shows how to visually display keyboard shortcuts in the menu and handle them in your application logic.
+
+You can use the {osShortcut}E and {osShortcut}D shortcuts to trigger the actions of the dropdown items.
+
+
diff --git a/www/apps/ui/app/components/focus-modal/page.mdx b/www/apps/ui/app/components/focus-modal/page.mdx
new file mode 100644
index 0000000000..bf9420ca75
--- /dev/null
+++ b/www/apps/ui/app/components/focus-modal/page.mdx
@@ -0,0 +1,66 @@
+---
+generate_toc: true
+---
+
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Focus Modal`,
+}
+
+# {metadata.title}
+
+A component for rendering a modal dialog shown over the main content.
+
+In this guide, you'll learn how to use the Focus Modal component.
+
+
+
+## Usage
+
+```tsx
+import { FocusModal } from "@medusajs/ui"
+```
+
+```tsx
+
+ Trigger
+
+ Title
+ Content
+
+
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+
+## Examples
+
+### Control Focus Modal Open State
+
+
+
+### Using Form in Focus Modal
+
+
+
+### Nested Focus Modals
+
+A focus modal can open another focus modal. These focus modals will be stacked on top of each other. You can nest as many focus modals as you want.
+
+
diff --git a/www/apps/ui/app/components/heading/page.mdx b/www/apps/ui/app/components/heading/page.mdx
new file mode 100644
index 0000000000..bb50de4129
--- /dev/null
+++ b/www/apps/ui/app/components/heading/page.mdx
@@ -0,0 +1,30 @@
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Heading`,
+}
+
+# {metadata.title}
+
+A component used for page titles and other headers.
+
+In this guide, you'll learn how to use the Heading component.
+
+
+
+## Usage
+
+```tsx
+import { Heading } from "@medusajs/ui"
+```
+
+```tsx
+A Title
+```
+
+---
+
+## API Reference
+
+
diff --git a/www/apps/ui/app/components/icon-badge/page.mdx b/www/apps/ui/app/components/icon-badge/page.mdx
new file mode 100644
index 0000000000..47396d412d
--- /dev/null
+++ b/www/apps/ui/app/components/icon-badge/page.mdx
@@ -0,0 +1,45 @@
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Icon Badge`,
+}
+
+# {metadata.title}
+
+A component that displays an icon in a badge.
+
+In this guide, you'll learn how to use the Icon Badge component.
+
+
+
+## Usage
+
+```tsx
+import { IconBadge } from "@medusajs/ui"
+import { BuildingTax } from "@medusajs/icons"
+```
+
+```tsx
+
+
+
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Examples
+
+### Colors
+
+
+
+### Sizes
+
+
diff --git a/www/apps/ui/app/components/icon-button/page.mdx b/www/apps/ui/app/components/icon-button/page.mdx
new file mode 100644
index 0000000000..decee20f16
--- /dev/null
+++ b/www/apps/ui/app/components/icon-button/page.mdx
@@ -0,0 +1,55 @@
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Icon Button`,
+}
+
+# {metadata.title}
+
+A component that displays an icon in a button.
+
+In this guide, you'll learn how to use the Icon Button component.
+
+
+
+## Usage
+
+```tsx
+import { IconButton } from "@medusajs/ui"
+import { Plus } from "@medusajs/icons"
+```
+
+```tsx
+
+
+
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Examples
+
+
+### Icon Button Variants
+
+
+
+
+### Icon Button Sizes
+
+
+
+### Icon Button Loading State
+
+
+
+### Disabled Icon Button
+
+
\ No newline at end of file
diff --git a/www/apps/ui/src/content/docs/components/inline-tip.mdx b/www/apps/ui/app/components/inline-tip/page.mdx
similarity index 54%
rename from www/apps/ui/src/content/docs/components/inline-tip.mdx
rename to www/apps/ui/app/components/inline-tip/page.mdx
index 84903fbbf5..8562946033 100644
--- a/www/apps/ui/src/content/docs/components/inline-tip.mdx
+++ b/www/apps/ui/app/components/inline-tip/page.mdx
@@ -1,15 +1,20 @@
----
-title: "Inline Tip"
-description: "A component for displaying a note or tip inline."
-component: true
----
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Inline Tip`,
+}
+
+# {metadata.title}
+
+A component for displaying a note or tip inline.
+
+In this guide, you'll learn how to use the Inline Tip component.
## Usage
----
-
```tsx
import { InlineTip } from "@medusajs/ui"
```
@@ -22,16 +27,16 @@ import { InlineTip } from "@medusajs/ui"
```
-## API Reference
-
---
+## API Reference
+
-## Examples
-
---
+## Examples
+
### Success Inline Tip
@@ -42,4 +47,4 @@ import { InlineTip } from "@medusajs/ui"
### Error Inline Tip
-
+
diff --git a/www/apps/ui/src/content/docs/components/input.mdx b/www/apps/ui/app/components/input/page.mdx
similarity index 53%
rename from www/apps/ui/src/content/docs/components/input.mdx
rename to www/apps/ui/app/components/input/page.mdx
index 9038cd8a7c..b9617beecd 100644
--- a/www/apps/ui/src/content/docs/components/input.mdx
+++ b/www/apps/ui/app/components/input/page.mdx
@@ -1,15 +1,20 @@
----
-title: "Input"
-description: "Renders a form input field"
-component: true
----
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Input`,
+}
+
+# {metadata.title}
+
+A component that renders a form input field using Medusa's design system.
+
+In this guide, you'll learn how to use the Input component.
## Usage
----
-
```tsx
import { Input } from "@medusajs/ui"
```
@@ -18,16 +23,16 @@ import { Input } from "@medusajs/ui"
```
-## API Reference
-
---
+## API Reference
+
-## Examples
-
---
+## Examples
+
### Password
@@ -40,12 +45,16 @@ import { Input } from "@medusajs/ui"
-### Small
+### Small Size
-### Error state
+### Controlled
+
+
+
+### Error State
You can leverage the native `aria-invalid` property to show an error state on your input:
-
+
diff --git a/www/apps/ui/app/components/kbd/page.mdx b/www/apps/ui/app/components/kbd/page.mdx
new file mode 100644
index 0000000000..599037b4b0
--- /dev/null
+++ b/www/apps/ui/app/components/kbd/page.mdx
@@ -0,0 +1,30 @@
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Kbd`,
+}
+
+# {metadata.title}
+
+A component that renders a badge-styled keyboard (`kbd`) element.
+
+In this guide, you'll learn how to use the Kbd component.
+
+
+
+## Usage
+
+```tsx
+import { Kbd } from "@medusajs/ui"
+```
+
+```tsx
+Ctrl + Shift + A
+```
+
+---
+
+## API Reference
+
+
diff --git a/www/apps/ui/app/components/label/page.mdx b/www/apps/ui/app/components/label/page.mdx
new file mode 100644
index 0000000000..a1dfb020c9
--- /dev/null
+++ b/www/apps/ui/app/components/label/page.mdx
@@ -0,0 +1,42 @@
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Label`,
+}
+
+# {metadata.title}
+
+A component that renders an accessible label associated with input fields.
+
+In this guide, you'll learn how to use the Label component.
+
+
+
+## Usage
+
+```tsx
+import { Label } from "@medusajs/ui"
+```
+
+```tsx
+
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Examples
+
+### Label Sizes
+
+
+
+### Label with Form Inputs
+
+
diff --git a/www/apps/ui/app/components/progress-accordion/page.mdx b/www/apps/ui/app/components/progress-accordion/page.mdx
new file mode 100644
index 0000000000..a6866e536f
--- /dev/null
+++ b/www/apps/ui/app/components/progress-accordion/page.mdx
@@ -0,0 +1,78 @@
+---
+generate_toc: true
+---
+
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Progress Accordion`,
+}
+
+# {metadata.title}
+
+A component that renders a set of expandable content, specifically designed for implementing multi-step tasks.
+
+In this guide, you'll learn how to use the Progress Accordion component.
+
+
+
+## Usage
+
+```tsx
+import { ProgressAccordion } from "@medusajs/ui"
+```
+
+```tsx
+
+
+
+ General
+
+
+ {/* Content */}
+
+
+
+
+ Shipping
+
+
+ {/* Content */}
+
+
+
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Examples
+
+### Only One Accordion Open
+
+
+
+### Allow Multiple Accordions to Open
+
+
+
+### Set Status Indicator
+
+
+
+### Controlled Accordion Open State
+
+
+
+### Disabled Accordion Item
+
+
\ No newline at end of file
diff --git a/www/apps/ui/app/components/progress-tabs/page.mdx b/www/apps/ui/app/components/progress-tabs/page.mdx
new file mode 100644
index 0000000000..917bcf0eeb
--- /dev/null
+++ b/www/apps/ui/app/components/progress-tabs/page.mdx
@@ -0,0 +1,74 @@
+---
+generate_toc: true
+---
+
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Progress Tabs`,
+}
+
+# {metadata.title}
+
+A component that renders tabbed content, specifically designed for implementing multi-step tasks.
+
+In this guide, you'll learn how to use the Progress Tabs component.
+
+
+
+## Usage
+
+```tsx
+import { ProgressTabs } from "@medusajs/ui"
+```
+
+```tsx
+
+
+
+ General
+
+
+ Shipping
+
+
+ Payment
+
+
+
+ {/* Content */}
+
+
+ {/* Content */}
+
+
+ {/* Content */}
+
+
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Examples
+
+### Set Status Indicator
+
+
+
+### Controlled Active Tab
+
+
+
+### Disabled Tab
+
+
diff --git a/www/apps/ui/app/components/prompt/page.mdx b/www/apps/ui/app/components/prompt/page.mdx
new file mode 100644
index 0000000000..e00ddd00b4
--- /dev/null
+++ b/www/apps/ui/app/components/prompt/page.mdx
@@ -0,0 +1,66 @@
+---
+generate_toc: true
+---
+
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Prompt`,
+}
+
+# {metadata.title}
+
+A component that displays a dialog prompting the user for their approval. It's useful when confirming destructive actions.
+
+
+
+This component is useful if you want to control the prompt's content, format, and design. For a simpler approach that follows Medusa's prompt format, refer to the [usePrompt hook](../../hooks/use-prompt/page.mdx).
+
+
+
+In this guide, you'll learn how to use the Prompt component.
+
+
+
+## Usage
+
+```tsx
+import { Prompt } from "@medusajs/ui"
+```
+
+```tsx
+
+ Trigger
+
+
+ Title
+ Description
+
+
+ Cancel
+ Delete
+
+
+
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Examples
+
+### Confirmation Prompt Variant
+
+The `confirmation` variant is useful when confirming an operation that isn't destructive, such as deleting an item.
+
+
diff --git a/www/apps/ui/app/components/radio-group/page.mdx b/www/apps/ui/app/components/radio-group/page.mdx
new file mode 100644
index 0000000000..c0e7a084ca
--- /dev/null
+++ b/www/apps/ui/app/components/radio-group/page.mdx
@@ -0,0 +1,60 @@
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Radio Group`,
+}
+
+# {metadata.title}
+
+A component that renders a group of radio buttons using Medusa's design system.
+
+In this guide, you'll learn how to use the Radio Group component.
+
+
+
+## Usage
+
+```tsx
+import { RadioGroup } from "@medusajs/ui"
+```
+
+```tsx
+
+
+
+
+
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Examples
+
+### Radio Group with Descriptions
+
+
+
+### Controlled Radio Group
+
+
+
+### Radio Group with a Disabled Item
+
+
+
+---
+
+## Radio Choice Box
+
+The `RadioGroup.ChoiceBox` component allows you to show a group of radio buttons, each in a box with a label and description.
+
+
+
+{/* TODO add API reference */}
\ No newline at end of file
diff --git a/www/apps/ui/src/content/docs/components/select.mdx b/www/apps/ui/app/components/select/page.mdx
similarity index 60%
rename from www/apps/ui/src/content/docs/components/select.mdx
rename to www/apps/ui/app/components/select/page.mdx
index 3d8893f1e8..5ad334339e 100644
--- a/www/apps/ui/src/content/docs/components/select.mdx
+++ b/www/apps/ui/app/components/select/page.mdx
@@ -1,15 +1,24 @@
---
-title: "Select"
-description: "Displays a list of options for the user to pick from—triggered by a button."
-component: true
+generate_toc: true
---
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Select`,
+}
+
+# {metadata.title}
+
+A component that displays a select form input using Medusa's design system.
+
+In this guide, you'll learn how to use the Select component.
+
## Usage
----
-
```tsx
import { Select } from "@medusajs/ui"
```
@@ -29,10 +38,10 @@ import { Select } from "@medusajs/ui"
```
-## API Reference
-
---
+## API Reference
+
-## Examples
-
---
-### Small
+## Examples
+
+### Small Select
-### Item-Aligned Position
+### Select Item-Aligned Position
-### Disabled
+### Disabled Select
-### Grouped Items
+### Select with Grouped Items
-### Controlled
+### Controlled Select
-
+
diff --git a/www/apps/ui/app/components/status-badge/page.mdx b/www/apps/ui/app/components/status-badge/page.mdx
new file mode 100644
index 0000000000..9a635c27d7
--- /dev/null
+++ b/www/apps/ui/app/components/status-badge/page.mdx
@@ -0,0 +1,38 @@
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Status Badge`,
+}
+
+# {metadata.title}
+
+A component that displays the status of an item in a badge style. It's useful to indicate states like "Active", "Published", or "Draft".
+
+In this guide, you'll learn how to use the Status Badge component.
+
+
+
+## Usage
+
+```tsx
+import { StatusBadge } from "@medusajs/ui"
+```
+
+```tsx
+Active
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Examples
+
+### Status Badge Colors
+
+
\ No newline at end of file
diff --git a/www/apps/ui/app/components/switch/page.mdx b/www/apps/ui/app/components/switch/page.mdx
new file mode 100644
index 0000000000..570e4d9560
--- /dev/null
+++ b/www/apps/ui/app/components/switch/page.mdx
@@ -0,0 +1,46 @@
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Switch`,
+}
+
+# {metadata.title}
+
+A component for toggling between two states, typically on and off. It's essentially a checkbox in the form of a switch.
+
+In this guide, you'll learn how to use the Switch component.
+
+
+
+## Usage
+
+```tsx
+import { Switch } from "@medusajs/ui"
+```
+
+```tsx
+
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Examples
+
+### Switch Sizes
+
+
+
+### Controlled Switch
+
+
+
+### Disabled Switch
+
+
\ No newline at end of file
diff --git a/www/apps/ui/src/content/docs/components/table.mdx b/www/apps/ui/app/components/table/page.mdx
similarity index 54%
rename from www/apps/ui/src/content/docs/components/table.mdx
rename to www/apps/ui/app/components/table/page.mdx
index 1c49cf1cb2..7419eb2b6f 100644
--- a/www/apps/ui/src/content/docs/components/table.mdx
+++ b/www/apps/ui/app/components/table/page.mdx
@@ -1,11 +1,23 @@
---
-title: "Table"
-description: "A Table component for displaying data."
+generate_toc: true
---
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Table`,
+}
+
+# {metadata.title}
+
+A component that displays data in a structured table format.
+
+In this guide, you'll learn how to use the Table component.
+
-If you're looking to add a table in your Medusa Admin Extensions with features like pagination and filters, refer to the [DataTable](/components/data-table) component instead.
+If you're looking to add a table to your Medusa Admin customizations with advanced features like filters, search, sorting, and bulk actions, refer to the [DataTable](../data-table/page.mdx) component instead.
@@ -13,8 +25,6 @@ If you're looking to add a table in your Medusa Admin Extensions with features l
## Usage
----
-
```tsx
import { Table } from "@medusajs/ui"
```
@@ -38,19 +48,19 @@ import { Table } from "@medusajs/ui"
```
-## API Reference
-
---
+## API Reference
+
-## Examples
-
---
+## Examples
+
### Table with Pagination
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/www/apps/ui/app/components/tabs/page.mdx b/www/apps/ui/app/components/tabs/page.mdx
new file mode 100644
index 0000000000..572d25b906
--- /dev/null
+++ b/www/apps/ui/app/components/tabs/page.mdx
@@ -0,0 +1,61 @@
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Tabs`,
+}
+
+# {metadata.title}
+
+A component that displays tabbed content.
+
+In this guide, you'll learn how to use the Tabs component.
+
+
+
+## Usage
+
+```tsx
+import { Tabs } from "@medusajs/ui"
+```
+
+```tsx
+
+
+ Tab 1
+ Tab 2
+ Tab 3
+
+ Panel 1
+ Panel 2
+ Panel 3
+
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Examples
+
+### Controlled Tabs
+
+
+
+### Tabs with a Disabled Tab
+
+
+
+### Tabs with Icons
+
+
+
+### Vertical Tabs
+
+The `orientation` prop doesn't change the layout of the tabs, but it allows you to navigate between the tabs using the up and down arrow keys. You'll need to manually style the tabs vertically.
+
+
\ No newline at end of file
diff --git a/www/apps/ui/app/components/text/page.mdx b/www/apps/ui/app/components/text/page.mdx
new file mode 100644
index 0000000000..3d9f971003
--- /dev/null
+++ b/www/apps/ui/app/components/text/page.mdx
@@ -0,0 +1,50 @@
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Text`,
+}
+
+# {metadata.title}
+
+A component that displays text using the typography styles from Medusa's design system.
+
+In this guide, you'll learn how to use the Text component.
+
+
+
+## Usage
+
+```tsx
+import { Text } from "@medusajs/ui"
+```
+
+```tsx
+Text
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Examples
+
+### Text Sizes
+
+
+
+### Text Weights
+
+
+
+### Text Fonts
+
+
+
+### Text Leading
+
+
diff --git a/www/apps/ui/app/components/textarea/page.mdx b/www/apps/ui/app/components/textarea/page.mdx
new file mode 100644
index 0000000000..5552f77162
--- /dev/null
+++ b/www/apps/ui/app/components/textarea/page.mdx
@@ -0,0 +1,42 @@
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Textarea`,
+}
+
+# {metadata.title}
+
+A component that displays a textarea field using Medusa's design system.
+
+In this guide, you'll learn how to use the Textarea component.
+
+
+
+## Usage
+
+```tsx
+import { Textarea } from "@medusajs/ui"
+```
+
+```tsx
+
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Examples
+
+### Controlled Textarea
+
+
+
+### Disabled Textarea
+
+
diff --git a/www/apps/ui/app/components/toast/page.mdx b/www/apps/ui/app/components/toast/page.mdx
new file mode 100644
index 0000000000..b59f569004
--- /dev/null
+++ b/www/apps/ui/app/components/toast/page.mdx
@@ -0,0 +1,119 @@
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Toaster and Toast Messages`,
+}
+
+# {metadata.title}
+
+
+A component and utility for displaying brief messages to users, typically used for notifications or alerts. Toast messages appear momentarily on top of the application UI.
+
+You can display multiple toast messages at once, and they will be stacked neatly.
+
+In this guide, you'll learn how to use the Toaster component.
+
+
+
+## Usage
+
+First, import the `toast` utility and `Toaster` component from `@medusajs/ui`:
+
+```tsx
+import { Toaster, toast } from "@medusajs/ui"
+```
+
+Then, add the `Toaster` component somewhere in your tree hierarchy. For example, in your main application layout:
+
+```tsx highlights={[["6"]]}
+export default function AppLayout({ children }) {
+ return (
+
+
+ {children}
+
+
+
+ )
+}
+```
+
+Finally, use the `toast` utility in your components to display a toast message:
+
+```tsx highlights={[["5", "info", "Display an informational message"]]}
+export default function MyComponent() {
+ return (
+
+ )
+}
+```
+
+---
+
+## API Reference
+
+### Toast Utility Functions
+
+The `toast` utility has the following functions to display different variants of toast messages:
+
+- `info`: Display a toast message with an informational style.
+- `error`: Display a toast message with an error style.
+- `success`: Display a toast message with a success style.
+- `warning`: Display a toast message with a warning style.
+- `loading`: Display a toast message with a loading style.
+
+Each of these functions accept two parameters:
+
+1. A string indicating the title of the toast.
+2. An object of [Toast component props](#toast-props).
+
+### Toast Props
+
+
+
+### Toaster Props
+
+
+
+---
+
+## Examples
+
+### Toast Variants
+
+
+
+The following example assumes you already have the `Toaster` component in [your application's tree](#usage).
+
+
+
+
+
+### Dismissable Toast
+
+
+
+The following example assumes you already have the `Toaster` component in [your application's tree](#usage).
+
+
+
+
+
+### Toast with Action
+
+
+
+The following example assumes you already have the `Toaster` component in [your application's tree](#usage).
+
+
+
+
diff --git a/www/apps/ui/app/components/tooltip/page.mdx b/www/apps/ui/app/components/tooltip/page.mdx
new file mode 100644
index 0000000000..8587fb0469
--- /dev/null
+++ b/www/apps/ui/app/components/tooltip/page.mdx
@@ -0,0 +1,59 @@
+import { ComponentExample } from "@/components/ComponentExample"
+import { ComponentReference } from "@/components/ComponentReference"
+
+export const metadata = {
+ title: `Tooltip`,
+}
+
+# {metadata.title}
+
+
+A component that displays a pop-up with additional information when hovering over or focusing on an element.
+
+In this guide, you'll learn how to use the Tooltip component.
+
+
+
+## Usage
+
+```tsx
+import { Tooltip } from "@medusajs/ui"
+```
+
+```tsx
+Trigger
+```
+
+---
+
+## API Reference
+
+
+
+---
+
+## Usage Outside Medusa Admin with TooltipProvider
+
+If you're using the `Tooltip` component in a project other than the Medusa Admin, make sure to include the `TooltipProvider` somewhere up in your component tree:
+
+```tsx
+
+ Trigger
+
+```
+
+### TooltipProvider Reference
+
+
+
+---
+
+## Examples
+
+### Changing Tooltip Side
+
+
+
+### Set Tooltip Max Width
+
+
diff --git a/www/apps/ui/src/app/favicon.ico b/www/apps/ui/app/favicon.ico
similarity index 100%
rename from www/apps/ui/src/app/favicon.ico
rename to www/apps/ui/app/favicon.ico
diff --git a/www/apps/ui/src/styles/globals.css b/www/apps/ui/app/globals.css
similarity index 78%
rename from www/apps/ui/src/styles/globals.css
rename to www/apps/ui/app/globals.css
index 3c92254990..0e8da8bc7d 100644
--- a/www/apps/ui/src/styles/globals.css
+++ b/www/apps/ui/app/globals.css
@@ -3,32 +3,38 @@
@tailwind utilities;
@layer base {
+
html {
@apply antialiased;
text-rendering: optimizeLegibility;
}
- .html {
- @apply text-medusa-fg-base;
+
+ body {
+ @apply overflow-x-hidden;
}
*::selection {
@apply bg-medusa-bg-highlight;
}
- pre *::selection {
- @apply !bg-medusa-contrast-bg-highlight;
+ *:not(.code-block-elm) {
+ scrollbar-color: var(--docs-border-base) var(--docs-bg-base);
}
- * {
- scrollbar-color: var(--docs-border-base) var(--docs-bg-base);
+ .code-block-elm {
+ scrollbar-color: var(--docs-contrast-border-base) transparent;
}
aside * {
scrollbar-color: var(--docs-border-base) var(--docs-bg-subtle);
}
- body {
- @apply text-ui-fg-base;
+ body[data-modal="opened"] {
+ @apply !overflow-hidden;
+ }
+
+ .text-wrap {
+ text-wrap: wrap;
}
/* Hack to hide navbar / toc when some components like prompt are opened. */
@@ -36,14 +42,6 @@
body[data-scroll-locked] .z-10 {
z-index: 0 !important;
}
-
- body[data-modal="opened"] {
- @apply !overflow-hidden text-ui-fg-base;
- }
-
- .text-wrap {
- text-wrap: wrap;
- }
}
.grecaptcha-badge {
diff --git a/www/apps/ui/app/hooks/use-prompt/page.mdx b/www/apps/ui/app/hooks/use-prompt/page.mdx
new file mode 100644
index 0000000000..c253d2475f
--- /dev/null
+++ b/www/apps/ui/app/hooks/use-prompt/page.mdx
@@ -0,0 +1,59 @@
+import { HookValues } from "@/components/HookValues"
+import { ComponentReference } from "@/components/ComponentReference"
+import { ComponentExample } from "@/components/ComponentExample"
+
+export const metadata = {
+ title: `usePrompt`,
+}
+
+# {metadata.title}
+
+
+
+This hook returns a function that prompts the user to confirm an action.
+
+In this guide, you'll learn how to use the `usePrompt` hook.
+
+
+
+## Usage
+
+```tsx
+import { usePrompt } from "@medusajs/ui"
+```
+
+```tsx
+const dialog = usePrompt()
+const actionFunction = async () => {
+ const confirmed = await dialog({
+ title: "Are you sure?",
+ description: "Please confirm this action",
+ })
+}
+```
+
+---
+
+## API Reference
+
+### usePrompt Return Value
+
+
+
+### Returned Dialog Parameters
+
+The dialog function returned by `usePrompt` accepts an object having the following properties:
+
+
+
+### Dialog Return Value
+
+The dialog function returns a Promise that resolves to a boolean indicating whether the user confirmed the action.
+
+---
+
+## Examples
+
+### Prompt with Verification Text
+
+
\ No newline at end of file
diff --git a/www/apps/ui/app/hooks/use-toggle-state/page.mdx b/www/apps/ui/app/hooks/use-toggle-state/page.mdx
new file mode 100644
index 0000000000..d876033463
--- /dev/null
+++ b/www/apps/ui/app/hooks/use-toggle-state/page.mdx
@@ -0,0 +1,38 @@
+import { HookValues } from "@/components/HookValues"
+import { ComponentExample } from "@/components/ComponentExample"
+
+export const metadata = {
+ title: `useToggleState`,
+}
+
+# {metadata.title}
+
+This hook tracks a boolean value and toggles between its two states.
+
+This guide explains how to use the `useToggleState` hook.
+
+For example, you can use this hook to display a checkbox or a [Switch](../../components/switch/page.mdx) that toggles a [Focus Modal](../../components/focus-modal/page.mdx).
+
+
+
+## Usage
+
+```tsx
+import { useToggleState } from "@medusajs/ui"
+```
+
+```tsx
+const [state, open, close, toggle] = useToggleState()
+```
+
+---
+
+## API Reference
+
+### useToggleState Parameters
+
+
+
+### useToggleState Return Value
+
+
diff --git a/www/apps/ui/src/app/icon.ico b/www/apps/ui/app/icon.ico
similarity index 100%
rename from www/apps/ui/src/app/icon.ico
rename to www/apps/ui/app/icon.ico
diff --git a/www/apps/ui/app/icons/overview/page.mdx b/www/apps/ui/app/icons/overview/page.mdx
new file mode 100644
index 0000000000..04fa118667
--- /dev/null
+++ b/www/apps/ui/app/icons/overview/page.mdx
@@ -0,0 +1,80 @@
+import { IconSearch } from "@/components/IconSearch"
+import { ComponentExample } from "@/components/ComponentExample"
+import { Prerequisites } from "docs-ui"
+
+export const metadata = {
+ title: `Icons`,
+}
+
+# {metadata.title}
+
+In this guide, you'll learn how to install and use Medusa UI icons.
+
+The Medusa UI icons package is a collection of React icon components from Medusa's design system. You can use these icons either in your Medusa Admin customizations, or in your standalone React projects.
+
+## Installation
+
+The Medusa UI icons package is available by default in your Medusa application, so you can use them in your Medusa Admin customizations without any additional installation steps.
+
+### Installation in Standalone Projects
+
+
+
+To install the Medusa UI icons package in your React-based project, run the following command:
+
+```bash npm2yarn
+npm install @medusajs/icons
+```
+
+---
+
+## Usage
+
+You can import and use the icons in your React components:
+
+```tsx
+import { Sun } from "@medusajs/icons"
+
+export default function Component() {
+ return (
+
+ )
+}
+```
+
+---
+
+## Icons List
+
+Below is a list of all the icons available in the Medusa UI design system. Click on any icon to copy its component name.
+
+
+
+---
+
+## Icon Props
+
+Icons accept all props that an `svg` element accepts.
+
+### Icon Color
+
+By default, outline icons' stroke color and solid icon's fill color are set to `currentColor`.
+
+You can set a different color by passing the `color` prop.
+
+
+
+You can also use a CSS class by passing the `className` prop.
+
+
+
+### Icon Size
+
+All icon's width and height are `20px` and it's not possible to change them.
diff --git a/www/apps/ui/app/installation/medusa-admin-extension/page.mdx b/www/apps/ui/app/installation/medusa-admin-extension/page.mdx
new file mode 100644
index 0000000000..d2b79a8f7f
--- /dev/null
+++ b/www/apps/ui/app/installation/medusa-admin-extension/page.mdx
@@ -0,0 +1,50 @@
+export const metadata = {
+ title: `Install Medusa UI for Medusa Admin Customizations`,
+}
+
+# {metadata.title}
+
+In this guide, you'll learn how to use Medusa UI for building Medusa Admin customizations.
+
+## Use Medusa UI in Medusa Admin
+
+The `@medusajs/ui` and `@medusajs/icons` packages are already installed as dependencies of the `@medusajs/admin-sdk` package in your Medusa project. They're installed by default in your Medusa plugins as well.
+
+So, you can import the packages and use them in your Medusa Admin customizations without any additional installation steps.
+
+For example, to use the UI and icon packages in a UI route:
+
+```tsx title="src/admin/routes/custom/page.tsx"
+import { defineRouteConfig } from "@medusajs/admin-sdk"
+import { ChatBubbleLeftRight } from "@medusajs/icons"
+import { Container, Heading } from "@medusajs/ui"
+
+const CustomPage = () => {
+ return (
+
+
+ This is my custom route
+
+
+ )
+}
+
+export const config = defineRouteConfig({
+ label: "Custom Route",
+ icon: ChatBubbleLeftRight,
+})
+
+export default CustomPage
+```
+
+In this example, you use the [Container](../../components/container/page.mdx) and [Heading](../../components/heading/page.mdx) components in the UI route. You also use the `ChatBubbleLeftRight` icon from the [Icons package](../../icons/overview/page.mdx) for the UI route's sidebar item.
+
+---
+
+## Related Resources
+
+If you're building Medusa Admin customizations, check out the following documentation guides:
+
+- [Admin Widgets](!docs!/learn/fundamentals/admin/widgets): Insert custom components into existing Medusa Admin pages.
+- [Admin UI Routes](!docs!/learn/fundamentals/admin/ui-routes): Add new pages to the Medusa Admin.
+- [Admin Components & Layouts](!resources!/admin-components): Use Medusa UI to implement common Medusa Admin components and layouts for a consistent design in your customizations.
diff --git a/www/apps/ui/src/content/docs/installation/standalone-project.mdx b/www/apps/ui/app/installation/standalone-project/page.mdx
similarity index 67%
rename from www/apps/ui/src/content/docs/installation/standalone-project.mdx
rename to www/apps/ui/app/installation/standalone-project/page.mdx
index 8567caea10..02aac4fdfd 100644
--- a/www/apps/ui/src/content/docs/installation/standalone-project.mdx
+++ b/www/apps/ui/app/installation/standalone-project/page.mdx
@@ -1,23 +1,31 @@
----
-title: "Medusa UI Installation in Standalone Projects"
-description: "Learn how to install and use Medusa UI in a standalone project."
----
+import Feedback from "@/components/Feedback"
+import { Note } from "docs-ui"
-Medusa UI is a React UI library that, while intended for usage within Medusa projects, can also be used in any React project.
+export const metadata = {
+ title: `Install Medusa UI in Standalone Projects`,
+}
+
+# {metadata.title}
+
+In this guide, you'll learn how to install and use Medusa UI in a standalone project.
+
+Medusa UI is a React UI library that, while intended for use within Medusa projects, can also be used in any React project.
-The icons package is installed independently from Medusa UI. Learn how to install it in the [Icons](../icons/overview.mdx) guide.
+The icons package is installed independently from Medusa UI. Learn how to install it in the [Icons](../../icons/overview/page.mdx) guide.
+---
+
## Medusa UI Compatibility
To use Medusa UI in your standalone project, you must have:
- React 18+ installed. Most React-based frameworks and libraries, such as Next.js and Vite, are compatible with this requirement.
-- [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.
- - Medusa UI was built with Tailwind CSS v3, but it may generally support v4 as well.
+- [Tailwind CSS](https://v3.tailwindcss.com/) installed. The components in Medusa UI are styled using Tailwind CSS, so you'll need to install it in your project as well.
+ - Medusa UI was built with Tailwind CSS v3, but it may also support v4.
---
@@ -25,17 +33,21 @@ To use Medusa UI in your standalone project, you must have:
In your standalone project, install the Medusa UI package with the following command:
-
+```bash npm2yarn
+npm install @medusajs/ui
+```
---
## Step 2: Install UI Presets
-Medusa UI customizes Tailwind CSS classes to implement its design system. So, you must also install the Medusa UI preset package.
+Medusa UI customizes Tailwind CSS classes to implement its design system, so you must also install the Medusa UI preset package.
To install the Medusa UI preset, run the following command:
-
+```bash npm2yarn
+npm install @medusajs/ui-preset --save-dev
+```
---
@@ -50,7 +62,7 @@ In Tailwind CSS v3, which is the recommended version to use with Medusa UI, you
1. Add the Medusa UI preset to the `presets` array.
2. Ensure that the `content` field includes the path to the Medusa UI package.
-```js title="tailwind.config.js"
+```js title="tailwind.config.js" highlights={[["5"]]}
module.exports = {
presets: [require("@medusajs/ui-preset")],
content: [
@@ -63,7 +75,12 @@ module.exports = {
If your project is in a monorepo, you'll need to resolve the path to the `@medusajs/ui` package from the monorepo root:
-```tsx title="tailwind.config.js"
+export const monorepoHighlights = [
+ ["3", "uiPath", "Resolve the UI package path from `node_modules`."],
+ ["13"]
+]
+
+```tsx title="tailwind.config.js" highlights={monorepoHighlights}
const path = require("path")
const uiPath = path.resolve(
@@ -87,7 +104,7 @@ module.exports = {
Medusa UI isn't officially compatible with Tailwind CSS v4 yet, so use it with caution.
-In your CSS file that imports Tailwind CSS, add the following `@config` and `@source` directives:
+In your CSS file that imports Tailwind CSS, add the following `@import`, `@config`, and `@source` directives:
```css
@import "tailwindcss";
@@ -95,7 +112,7 @@ In your CSS file that imports Tailwind CSS, add the following `@config` and `@so
@config "@medusajs/ui-preset";
```
-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.
+This will explicitly include the Medusa UI preset and its components in your Tailwind CSS build and apply the preset styles to your project.
---
@@ -121,9 +138,9 @@ Refer to the documentation of each component to learn about its props and usage.
## Update UI Packages in Standalone Projects
-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.
+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.
-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).
+So, to find the 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).
To update these packages in your standalone project, update their version in your `package.json` file and re-install dependencies. For example:
diff --git a/www/apps/ui/src/app/layout.tsx b/www/apps/ui/app/layout.tsx
similarity index 63%
rename from www/apps/ui/src/app/layout.tsx
rename to www/apps/ui/app/layout.tsx
index 1573687925..a18fa25a58 100644
--- a/www/apps/ui/src/app/layout.tsx
+++ b/www/apps/ui/app/layout.tsx
@@ -1,19 +1,22 @@
import type { Metadata } from "next"
-
-import { Providers } from "@/providers"
-
-import { siteConfig } from "@/config/site"
-import "../styles/globals.css"
-import { BareboneLayout, InjectedMDXData, TightLayout } from "docs-ui"
import { Inter, Roboto_Mono } from "next/font/google"
+import Providers from "@/providers"
+import "./globals.css"
+import { BareboneLayout, TightLayout } from "docs-ui"
+import { config } from "@/config"
import clsx from "clsx"
+import Footer from "@/components/Footer"
const ogImage =
"https://res.cloudinary.com/dza7lstvk/image/upload/v1732200992/Medusa%20Resources/opengraph-image_daq6nx.jpg"
export const metadata: Metadata = {
- title: siteConfig.name,
- description: siteConfig.description,
+ title: {
+ template: `%s - ${config.titleSuffix}`,
+ default: config.titleSuffix || "",
+ },
+ description:
+ "Learn about Medusa UI, A React package with primitives for building Medusa applications.",
metadataBase: new URL(
process.env.NEXT_PUBLIC_BASE_URL || "http://localhost:3000"
),
@@ -39,13 +42,13 @@ export const metadata: Metadata = {
},
}
-const inter = Inter({
+export const inter = Inter({
subsets: ["latin"],
variable: "--font-inter",
weight: ["400", "500"],
})
-const robotoMono = Roboto_Mono({
+export const robotoMono = Roboto_Mono({
subsets: ["latin"],
variable: "--font-roboto-mono",
})
@@ -60,18 +63,8 @@ export default function RootLayout({
htmlClassName={clsx(inter.variable, robotoMono.variable)}
gaId={process.env.NEXT_PUBLIC_GA_ID}
>
-
+ }>
{children}
- {/*
- Since we use contentlayer in this project, we can't use a Recma plugin.
- This is a workaround until we move from contentlayer.
- */}
-
)
diff --git a/www/apps/ui/src/app/md-content/[[...slug]]/route.ts b/www/apps/ui/app/md-content/[[...slug]]/route.ts
similarity index 81%
rename from www/apps/ui/src/app/md-content/[[...slug]]/route.ts
rename to www/apps/ui/app/md-content/[[...slug]]/route.ts
index 8eda5acd23..2d6cef32ed 100644
--- a/www/apps/ui/src/app/md-content/[[...slug]]/route.ts
+++ b/www/apps/ui/app/md-content/[[...slug]]/route.ts
@@ -7,7 +7,7 @@ import path from "path"
import { addUrlToRelativeLink } from "remark-rehype-plugins"
import type { Plugin } from "unified"
import * as Icons from "@medusajs/icons"
-import * as HookValues from "@/registries/hook-values"
+import * as HookValues from "@/specs/hook-values"
import { colors as allColors } from "@/config/colors"
type Params = {
@@ -18,12 +18,10 @@ export async function GET(req: NextRequest, { params }: Params) {
const { slug = ["/"] } = await params
// keep this so that Vercel keeps the files in deployment
- const basePath = path.join(process.cwd(), "src", "content", "docs")
- const examplesPath = path.join(process.cwd(), "src", "examples")
- const specsPath = path.join(process.cwd(), "src", "specs")
- const fileName = slug.length === 1 ? "index" : slug.pop() || "index"
-
- const filePath = path.join(basePath, ...slug, `${fileName}.mdx`)
+ const basePath = path.join(process.cwd(), "app")
+ const componentSpecsPath = path.join(process.cwd(), "specs", "components")
+ const examplesPath = path.join(process.cwd(), "specs", "examples")
+ const filePath = path.join(basePath, ...slug, "page.mdx")
if (!existsSync(filePath)) {
return notFound()
@@ -31,7 +29,7 @@ export async function GET(req: NextRequest, { params }: Params) {
const cleanMdContent = await getCleanMd_(
filePath,
- { examplesPath, specsPath },
+ { examplesPath, specsPath: componentSpecsPath },
{
after: [
[addUrlToRelativeLink, { url: process.env.NEXT_PUBLIC_BASE_URL }],
diff --git a/www/apps/ui/src/app/not-found.mdx b/www/apps/ui/app/not-found.mdx
similarity index 96%
rename from www/apps/ui/src/app/not-found.mdx
rename to www/apps/ui/app/not-found.mdx
index c0b1caa0c4..277170c593 100644
--- a/www/apps/ui/src/app/not-found.mdx
+++ b/www/apps/ui/app/not-found.mdx
@@ -1,3 +1,7 @@
+---
+hide_content_menu: true
+---
+
import { CardList, H1 } from "docs-ui"
import {
BookOpen,
diff --git a/www/apps/ui/app/page.mdx b/www/apps/ui/app/page.mdx
new file mode 100644
index 0000000000..4a1e7b041a
--- /dev/null
+++ b/www/apps/ui/app/page.mdx
@@ -0,0 +1,44 @@
+import { FigmaCard } from "@/components/FigmaCard"
+
+export const metadata = {
+ title: `Medusa UI Documentation`,
+}
+
+# {metadata.title}
+
+Welcome to Medusa UI, a React implementation of the Medusa design system.
+
+Medusa UI is a collection of components, hooks, utility functions, icons, and [Tailwind CSS](https://tailwindcss.com/) classes that can be used to build
+a consistent user interface across the Medusa Admin and client applications.
+
+
+
+---
+
+## Packages
+
+Medusa UI is split into multiple packages. Each package is published to npm
+and can be installed separately.
+
+- `@medusajs/ui` - React components, hooks, and utility functions used
+ in Medusa UI.
+- `@medusajs/ui-preset` - Tailwind CSS preset containing all the classes
+ used in Medusa UI.
+- `@medusajs/icons` - Icons used in Medusa UI.
+
+Learn how to install and use these packages either for [Medusa Admin](./installation/medusa-admin-extension/page.mdx) customizations or a [standalone project](./installation/standalone-project/page.mdx).
+
+---
+
+## How Medusa UI is Built
+
+At its core, Medusa UI is a styled and slightly opinionated implementation of [Radix Primitives](https://www.radix-ui.com/primitives).
+Our team has also referenced the fantastic [shadcn/ui](https://ui.shadcn.com/) for inspiration in certain implementations.
+
+Our team strongly believes in keeping the components simple and
+composable, much like Medusa's foundation. This allows you to build whatever you need.
+
+Our team has tried to avoid overloading
+the component API and, instead, has leveraged the native HTML API, which gets implemented
+and respected accordingly, and passed to the underlying elements.
+
diff --git a/www/apps/ui/src/app/sitemap.ts b/www/apps/ui/app/sitemap.ts
similarity index 50%
rename from www/apps/ui/src/app/sitemap.ts
rename to www/apps/ui/app/sitemap.ts
index 94d4be150b..d3bc3e9a9b 100644
--- a/www/apps/ui/src/app/sitemap.ts
+++ b/www/apps/ui/app/sitemap.ts
@@ -1,14 +1,13 @@
import { retrieveMdxPages } from "build-scripts"
import type { MetadataRoute } from "next"
import path from "path"
-import { siteConfig } from "../config/site"
-import { basePathUrl } from "../lib/base-path-url"
+import { config } from "../config"
+import { basePathUrl } from "../utils/base-path-url"
export default function sitemap(): MetadataRoute.Sitemap {
return retrieveMdxPages({
- basePath: path.resolve("src", "content", "docs"),
- testFileName: false,
+ basePath: path.resolve("app"),
}).map((filePath) => ({
- url: `${siteConfig.baseUrl}${basePathUrl(filePath)}`,
+ url: `${config.baseUrl}${basePathUrl(filePath)}`,
}))
}
diff --git a/www/apps/ui/app/utils/clx/page.mdx b/www/apps/ui/app/utils/clx/page.mdx
new file mode 100644
index 0000000000..e6c5989cca
--- /dev/null
+++ b/www/apps/ui/app/utils/clx/page.mdx
@@ -0,0 +1,92 @@
+export const metadata = {
+ title: `clx`,
+}
+
+# {metadata.title}
+
+`clx` is a utility function that adds class names to your components, with support for conditional classes and merging Tailwind CSS classes.
+
+In this guide, you'll learn how to use the `clx` utility function.
+
+## Usage
+
+
+The `clx` function is built using [clsx](https://www.npmjs.com/package/clsx) and [tw-merge](https://www.npmjs.com/package/tw-merge). It is intended to be used with [Tailwind CSS](https://tailwindcss.com/) to efficiently add classes to your components.
+
+
+`clx` is useful for:
+
+- Conditionally apply classes based on props or state. For example, you can apply the `hidden` class if a component's `open` state variable is `false`.
+- Merge multiple strings into a single class name string. For example, you can apply class names to the component, and allow passing additional class names as props.
+- Override conflicting Tailwind CSS classes. For example, if you specify a `p-2` class name on your component, and you pass a `p-4` class name as a prop, the `p-4` class will take precedence.
+ - The last class name specified will take precedence over any previous class names.
+
+For example:
+
+```tsx
+import { clx } from "@medusajs/ui"
+
+type BoxProps = {
+ className?: string
+ children: React.ReactNode
+ mt: "sm" | "md" | "lg"
+}
+
+const Box = ({ className, children, mt }: BoxProps) => {
+ return (
+
+ {children}
+
+ )
+}
+```
+
+In the above example, you use `clx` to:
+
+- Apply a base style.
+- Apply a margin top that depends on the `mt` prop.
+- Add class names passed as a prop.
+
+`clx` ensures that Tailwind CSS classes are merged without style conflicts.
+
+---
+
+## API Reference
+
+### clx Parameters
+
+`clx` accepts any number of arguments, each of them can be of the following types:
+
+- `string`: A string of class names to apply.
+
+```tsx
+clx("flex items-center justify-between")
+```
+
+- `Record`: An object whose keys are the class names to apply, and the values are booleans indicating whether to apply the class names.
+
+```tsx
+clx({
+ "flex items-center justify-between": isFlex,
+})
+```
+
+- `Array`: An array of strings or objects to apply.
+
+```tsx
+clx([
+ "flex items-center justify-between",
+ {
+ "hidden": isHidden,
+ },
+])
\ No newline at end of file
diff --git a/www/apps/ui/src/components/colors.tsx b/www/apps/ui/components/Colors/index.tsx
similarity index 62%
rename from www/apps/ui/src/components/colors.tsx
rename to www/apps/ui/components/Colors/index.tsx
index 243fa95479..c1cbde3c26 100644
--- a/www/apps/ui/src/components/colors.tsx
+++ b/www/apps/ui/components/Colors/index.tsx
@@ -1,9 +1,10 @@
"use client"
import React from "react"
-import { CopyButton, useColorMode } from "docs-ui"
-import { colors as allColors } from "../config/colors"
+import { CopyButton, H2, Hr, MarkdownContent, useColorMode } from "docs-ui"
+import { colors as allColors } from "@/config/colors"
import { clx } from "@medusajs/ui"
+import slugify from "slugify"
type Color = {
name: string
@@ -11,21 +12,10 @@ type Color = {
}
type ColorsTable = {
- backgrounds: Color[]
- foregrounds: Color[]
- borders: Color[]
- buttons: Color[]
- code: Color[]
- tags: Color[]
-}
-
-const PREFIXES: { [k: string]: keyof ColorsTable } = {
- "--bg": "backgrounds",
- "--fg": "foregrounds",
- "--border": "borders",
- "--button": "buttons",
- "--code": "code",
- "--tag": "tags",
+ [k: string]: {
+ description?: string
+ colors: Color[]
+ }
}
interface ColorBlockProps extends React.HTMLAttributes {
@@ -99,7 +89,7 @@ const cssVarToTailwindClass = (name: string) => {
return name.replace("-", "border-ui")
}
- if (name.startsWith("--tag") || name.startsWith("--code")) {
+ if (name.startsWith("--tag")) {
if (name.includes("bg")) {
return name.replace("-", "bg-ui")
}
@@ -111,49 +101,78 @@ const cssVarToTailwindClass = (name: string) => {
}
}
+ if (name.startsWith("--contrast") || name.startsWith("--alpha")) {
+ return name.replace("-", "bg-ui")
+ }
+
return name
}
+const transformPrefixToTitle = (prefix: string) => {
+ switch (prefix) {
+ case "bg":
+ return "Background"
+ case "fg":
+ return "Foreground"
+ default:
+ return prefix.charAt(0).toUpperCase() + prefix.slice(1)
+ }
+}
+
+const getDescriptionOfSection = (title: string) => {
+ switch (title) {
+ case "Alpha":
+ case "Contrast":
+ return "These colors can be used for foreground (using `text-` prefix), background (using `bg-` prefix), and border (using `border-` prefix) elements."
+ default:
+ return ""
+ }
+}
+
const Colors = () => {
const { colorMode } = useColorMode()
- const colors: ColorsTable = {
- backgrounds: [],
- foregrounds: [],
- borders: [],
- buttons: [],
- code: [],
- tags: [],
- }
+ const colors: ColorsTable = {}
for (const [tag, value] of Object.entries(allColors[colorMode])) {
- const prefix = tag.match(/(--[a-zA-Z]+)/gi)
- if (prefix && Object.keys(PREFIXES).includes(prefix[0])) {
- if (!tag.includes("gradient")) {
- colors[PREFIXES[prefix[0]]].push({
- name: tag,
- code: value as string,
- })
+ const prefixMatch = tag.match(/(--[a-zA-Z]+)/gi)
+ if (!prefixMatch) {
+ return
+ }
+ const prefix = transformPrefixToTitle(prefixMatch[0].replace("--", ""))
+ if (!colors[prefix]) {
+ colors[prefix] = {
+ description: getDescriptionOfSection(prefix),
+ colors: [],
}
}
+
+ colors[prefix].colors.push({
+ name: tag,
+ code: value as string,
+ })
}
- for (const [, section] of Object.entries(colors)) {
- section.sort((a, b) => {
+ const sortedSections = Object.entries(colors).sort((a, b) => {
+ return a[0].localeCompare(b[0])
+ })
+
+ for (const [, sectionData] of sortedSections) {
+ sectionData.colors.sort((a, b) => {
return a.name < b.name ? -1 : 1
})
}
return (
+
+ This is the General step.
+
+
+ This is the Shipping step.
+
+
+ This is the Payment step.
+
+
+
+
+
+
+
+
+ )
+}
diff --git a/www/apps/ui/src/examples/progress-tabs-demo.tsx b/www/apps/ui/specs/examples/progress-tabs-demo.tsx
similarity index 100%
rename from www/apps/ui/src/examples/progress-tabs-demo.tsx
rename to www/apps/ui/specs/examples/progress-tabs-demo.tsx
diff --git a/www/apps/ui/specs/examples/progress-tabs-disabled.tsx b/www/apps/ui/specs/examples/progress-tabs-disabled.tsx
new file mode 100644
index 0000000000..059bad65df
--- /dev/null
+++ b/www/apps/ui/specs/examples/progress-tabs-disabled.tsx
@@ -0,0 +1,30 @@
+import { ProgressTabs, Text } from "@medusajs/ui"
+
+export default function ProgressTabsDisabled() {
+ return (
+
+
+
+
+ General
+
+ Shipping
+
+ Payment
+
+
+
+
+ This is the General step.
+
+
+ This is the Shipping step (disabled).
+
+
+ This is the Payment step.
+
+
+
+
+ )
+}
diff --git a/www/apps/ui/specs/examples/progress-tabs-status.tsx b/www/apps/ui/specs/examples/progress-tabs-status.tsx
new file mode 100644
index 0000000000..5c8f619de2
--- /dev/null
+++ b/www/apps/ui/specs/examples/progress-tabs-status.tsx
@@ -0,0 +1,34 @@
+import { ProgressTabs, Text } from "@medusajs/ui"
+
+export default function ProgressTabsStatus() {
+ return (
+
+
+
+
+
+ General
+
+
+ Shipping
+
+
+ Payment
+
+
+
+
+
+ General step is completed.
+
+
+ Shipping step is in progress.
+
+
+ Payment step has not started.
+
+
+
+
+ )
+}
diff --git a/www/apps/ui/specs/examples/prompt-confirmation.tsx b/www/apps/ui/specs/examples/prompt-confirmation.tsx
new file mode 100644
index 0000000000..2f7e1c48e2
--- /dev/null
+++ b/www/apps/ui/specs/examples/prompt-confirmation.tsx
@@ -0,0 +1,23 @@
+import { Button, Prompt } from "@medusajs/ui"
+
+export default function PromptConfirmation() {
+ return (
+
+
+
+
+
+
+ Confirm Action
+
+ Are you sure you want to proceed? This action can be undone.
+
+
+
+ Cancel
+ Confirm
+
+
+
+ )
+}
diff --git a/www/apps/ui/src/examples/prompt-demo.tsx b/www/apps/ui/specs/examples/prompt-demo.tsx
similarity index 100%
rename from www/apps/ui/src/examples/prompt-demo.tsx
rename to www/apps/ui/specs/examples/prompt-demo.tsx
diff --git a/www/apps/ui/specs/examples/radio-group-choicebox.tsx b/www/apps/ui/specs/examples/radio-group-choicebox.tsx
new file mode 100644
index 0000000000..c5ee990c57
--- /dev/null
+++ b/www/apps/ui/specs/examples/radio-group-choicebox.tsx
@@ -0,0 +1,23 @@
+import { RadioGroup } from "@medusajs/ui"
+
+export default function RadioGroupChoiceBox() {
+ return (
+
+
+
+
+
+ )
+}
diff --git a/www/apps/ui/specs/examples/radio-group-controlled.tsx b/www/apps/ui/specs/examples/radio-group-controlled.tsx
new file mode 100644
index 0000000000..2f1f50ad6a
--- /dev/null
+++ b/www/apps/ui/specs/examples/radio-group-controlled.tsx
@@ -0,0 +1,31 @@
+import { Label, RadioGroup } from "@medusajs/ui"
+import * as React from "react"
+
+export default function RadioGroupControlled() {
+ const [value, setValue] = React.useState("1")
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Selected value: {value}
+
+ )
+}
diff --git a/www/apps/ui/src/examples/radio-group-demo.tsx b/www/apps/ui/specs/examples/radio-group-demo.tsx
similarity index 100%
rename from www/apps/ui/src/examples/radio-group-demo.tsx
rename to www/apps/ui/specs/examples/radio-group-demo.tsx
diff --git a/www/apps/ui/src/examples/radio-group-descriptions.tsx b/www/apps/ui/specs/examples/radio-group-descriptions.tsx
similarity index 100%
rename from www/apps/ui/src/examples/radio-group-descriptions.tsx
rename to www/apps/ui/specs/examples/radio-group-descriptions.tsx
diff --git a/www/apps/ui/src/examples/radio-group-disabled.tsx b/www/apps/ui/specs/examples/radio-group-disabled.tsx
similarity index 100%
rename from www/apps/ui/src/examples/radio-group-disabled.tsx
rename to www/apps/ui/specs/examples/radio-group-disabled.tsx
diff --git a/www/apps/ui/src/examples/select-controlled.tsx b/www/apps/ui/specs/examples/select-controlled.tsx
similarity index 100%
rename from www/apps/ui/src/examples/select-controlled.tsx
rename to www/apps/ui/specs/examples/select-controlled.tsx
diff --git a/www/apps/ui/src/examples/select-demo.tsx b/www/apps/ui/specs/examples/select-demo.tsx
similarity index 100%
rename from www/apps/ui/src/examples/select-demo.tsx
rename to www/apps/ui/specs/examples/select-demo.tsx
diff --git a/www/apps/ui/src/examples/select-disabled.tsx b/www/apps/ui/specs/examples/select-disabled.tsx
similarity index 100%
rename from www/apps/ui/src/examples/select-disabled.tsx
rename to www/apps/ui/specs/examples/select-disabled.tsx
diff --git a/www/apps/ui/src/examples/select-grouped-items.tsx b/www/apps/ui/specs/examples/select-grouped-items.tsx
similarity index 100%
rename from www/apps/ui/src/examples/select-grouped-items.tsx
rename to www/apps/ui/specs/examples/select-grouped-items.tsx
diff --git a/www/apps/ui/src/examples/select-item-aligned.tsx b/www/apps/ui/specs/examples/select-item-aligned.tsx
similarity index 100%
rename from www/apps/ui/src/examples/select-item-aligned.tsx
rename to www/apps/ui/specs/examples/select-item-aligned.tsx
diff --git a/www/apps/ui/src/examples/select-small.tsx b/www/apps/ui/specs/examples/select-small.tsx
similarity index 100%
rename from www/apps/ui/src/examples/select-small.tsx
rename to www/apps/ui/specs/examples/select-small.tsx
diff --git a/www/apps/ui/specs/examples/status-badge-all-colors.tsx b/www/apps/ui/specs/examples/status-badge-all-colors.tsx
new file mode 100644
index 0000000000..804ecf9fcb
--- /dev/null
+++ b/www/apps/ui/specs/examples/status-badge-all-colors.tsx
@@ -0,0 +1,14 @@
+import { StatusBadge } from "@medusajs/ui"
+
+export default function StatusBadgeAllColors() {
+ return (
+
+ Active
+ Error
+ Pending
+ Info
+ Archived
+ Draft
+
+ )
+}
diff --git a/www/apps/ui/src/examples/status-badge-demo.tsx b/www/apps/ui/specs/examples/status-badge-demo.tsx
similarity index 67%
rename from www/apps/ui/src/examples/status-badge-demo.tsx
rename to www/apps/ui/specs/examples/status-badge-demo.tsx
index 2482d933c9..d2c974dc32 100644
--- a/www/apps/ui/src/examples/status-badge-demo.tsx
+++ b/www/apps/ui/specs/examples/status-badge-demo.tsx
@@ -1,5 +1,5 @@
import { StatusBadge } from "@medusajs/ui"
export default function StatusBadgeDemo() {
- return Status
+ return Draft
}
diff --git a/www/apps/ui/specs/examples/switch-all-sizes.tsx b/www/apps/ui/specs/examples/switch-all-sizes.tsx
new file mode 100644
index 0000000000..94e62950e5
--- /dev/null
+++ b/www/apps/ui/specs/examples/switch-all-sizes.tsx
@@ -0,0 +1,20 @@
+import { Label, Switch } from "@medusajs/ui"
+
+export default function SwitchAllSizes() {
+ return (
+