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 Sizes + +```tsx +import { Avatar } from "@medusajs/ui" + +export default function AvatarSizes() { + 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 ( +
+ + + + +
+ ) } ``` -### Secondary +### Button Sizes ```tsx import { Button } from "@medusajs/ui" -export default function ButtonSecondary() { - return +export default function ButtonAllSizes() { + 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 ( +
+ + + Selected: {date?.toDateString() ?? "None"} + +
+ ) +} + +``` + +### Min/Max Dates + +```tsx +import { Calendar } from "@medusajs/ui" + +export default function CalendarMinMax() { + const min = new Date() + const max = new Date() + max.setDate(max.getDate() + 10) + return ( +
+ + Selectable dates: {min.toDateString()} to {max.toDateString()} + + +
+ ) +} + +``` + +### Unavailable Dates + +```tsx +import { Calendar } from "@medusajs/ui" + +function isUnavailable(date: Date) { + // Disable all Sundays + return date.getDay() === 0 +} + +export default function CalendarUnavailable() { + 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 ( -
- - +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
) } ``` -### Checked +### Controlled Checkbox ```tsx -import { Checkbox, Label } from "@medusajs/ui" +import { Checkbox, CheckboxCheckedState, Label } from "@medusajs/ui" +import { useState } from "react" + +export default function CheckboxControlled() { + const [checked, setChecked] = useState(false) + + const handleToggle = () => { + switch (checked) { + case "indeterminate": + setChecked(true) + return + case true: + setChecked(false) + return + default: + setChecked("indeterminate") + } + } -export default function CheckboxChecked() { return ( -
- - -
- ) -} - -``` - -### Disabled - -```tsx -import { Checkbox, Label } from "@medusajs/ui" - -export default function CheckboxDisabled() { - return ( -
- - -
- ) -} - -``` - -### Indeterminate - -```tsx -import { Checkbox, Label } from "@medusajs/ui" - -export default function CheckboxIndeterminate() { - 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 ( +
+ +
+ Value: {formatValue(value)} +
+
+ ) +} + +``` + +### Disabled + +```tsx +import { CurrencyInput } from "@medusajs/ui" + +export default function CurrencyInputDisabled() { + return ( +
+ +
+ ) +} + +``` + +### Error State + +```tsx +import { useState } from "react" +import { CurrencyInput } from "@medusajs/ui" + +export default function CurrencyInputError() { + const [value, setValue] = useState("0") + const [touched, setTouched] = useState(false) + const isError = touched && (!value || parseFloat(value) <= 0) + return ( +
+ setValue(val)} + aria-label="Amount" + aria-invalid={isError} + onBlur={() => setTouched(true)} + min={0.01} + /> + {isError && ( +
+ Amount must be greater than 0 +
+ )} +
+ ) +} + +``` + +### 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 ( +
+ + + + + + + Simple Form + +
+ + + setName(e.target.value)} + placeholder="Enter your name" + /> + + + + + + + +
+
+
+ {submitted && ( +
Form submitted with name {name}
+ )} +
+ ) +} + +``` + + # 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 + +
+ +
+ + setValue(e.target.value)} + placeholder="Enter your name" + /> +
+
+ + + +
+
+
+ {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 ( +
+ + + + + + +
+ ) +} + +``` + +### Icon Button Sizes + +```tsx +import { IconButton } from "@medusajs/ui" +import { PlusMini } from "@medusajs/icons" + +export default function IconButtonAllSizes() { + return ( +
+ + + + + + + + + + + + + + + + + + +
+ ) +} + +``` + +### Icon Button Loading State ```tsx import { PlusMini } from "@medusajs/icons" import { IconButton } from "@medusajs/ui" -export default function IconButtonPrimary() { +export default function IconButtonLoading() { return ( - + ) @@ -92922,71 +93502,7 @@ export default function IconButtonPrimary() { ``` -### Transparent - -```tsx -import { PlusMini } from "@medusajs/icons" -import { IconButton } from "@medusajs/ui" - -export default function IconButtonTransparent() { - return ( - - - - ) -} - -``` - -### Base - -```tsx -import { PlusMini } from "@medusajs/icons" -import { IconButton } from "@medusajs/ui" - -export default function IconButtonBase() { - return ( - - - - ) -} - -``` - -### Large - -```tsx -import { PlusMini } from "@medusajs/icons" -import { IconButton } from "@medusajs/ui" - -export default function IconButtonLarge() { - return ( - - - - ) -} - -``` - -### X-Large - -```tsx -import { PlusMini } from "@medusajs/icons" -import { IconButton } from "@medusajs/ui" - -export default function IconButtonXLarge() { - return ( - - - - ) -} - -``` - -### Disabled +### Disabled Icon Button ```tsx import { PlusMini } from "@medusajs/icons" @@ -93002,27 +93518,13 @@ export default function IconButtonDisabled() { ``` -### Loading - -```tsx -import { PlusMini } from "@medusajs/icons" -import { IconButton } from "@medusajs/ui" - -export default function IconButtonLoading() { - return ( - - - - ) -} - -``` - # Inline Tip A component for displaying a note or tip inline. +In this guide, you'll learn how to use the Inline Tip component. + ```tsx import { InlineTip } from "@medusajs/ui" @@ -93039,8 +93541,6 @@ export default function InlineTipDemo() { ## Usage -*** - ```tsx import { InlineTip } from "@medusajs/ui" ``` @@ -93053,10 +93553,10 @@ import { InlineTip } from "@medusajs/ui" ``` -## API Reference - *** +## API Reference + ### InlineTip Props This component is based on the \`div\` element and supports all of its props. @@ -93064,10 +93564,10 @@ This component is based on the \`div\` element and supports all of its props. - label: (string) The label to display in the tip. - variant: (union) The variant of the tip. Default: "info" -## Examples - *** +## Examples + ### Success Inline Tip ```tsx @@ -93122,7 +93622,9 @@ export default function InlineTipError() { # Input -Renders a form input field +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. ```tsx import { Input } from "@medusajs/ui" @@ -93139,8 +93641,6 @@ export default function InputDemo() { ## Usage -*** - ```tsx import { Input } from "@medusajs/ui" ``` @@ -93149,20 +93649,20 @@ import { Input } from "@medusajs/ui" ``` -## API Reference - *** +## API Reference + ### Input Props This component is based on the \`input\` element and supports all of its props - size: (union) The input's size. Default: "base" -## Examples - *** +## Examples + ### Password ```tsx @@ -93208,7 +93708,7 @@ export default function InputDisabled() { ``` -### Small +### Small Size ```tsx import { Input } from "@medusajs/ui" @@ -93223,7 +93723,31 @@ export default function InputSmall() { ``` -### Error state +### Controlled + +```tsx +import { Input } from "@medusajs/ui" +import { useState } from "react" + +export default function InputControlled() { + const [value, setValue] = useState("") + + return ( +
+ setValue(e.target.value)} + placeholder="Enter name" + id="controlled-input" + /> + {value && Hello, {value}!} +
+ ) +} + +``` + +### 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 ( - +
+
+ + +
+
+ + +
+
+ +