UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.
docs: add installation documentation #201 (#208)
Abderrahman ES-SEBYITY41f50030bf21
diff --git a/components/component-installation.tsx b/components/component-installation.tsxindex fe39cea7..3b9ea7d8 100644--- a/components/component-installation.tsx+++ b/components/component-installation.tsx@@ -19,6 +19,57 @@ const frameworks = [</svg>),},+ {+ name: "Astro",+ href: "/docs/installation/astro",+ icon: (+ <svg+ role="img"+ viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg"+ className="size-10"+ fill="currentColor"+ >+ <title>Astro</title>+ <path+ d="M16.074 16.86C15.354 17.476 13.917 17.895 12.262 17.895C10.23 17.895 8.527 17.263 8.075 16.412C7.914 16.9 7.877 17.458 7.877 17.814C7.877 17.814 7.771 19.564 8.988 20.782C8.988 20.15 9.501 19.637 10.133 19.637C11.216 19.637 11.215 20.582 11.214 21.349V21.418C11.214 22.582 11.925 23.579 12.937 24C12.7812 23.6794 12.7005 23.3275 12.701 22.971C12.701 21.861 13.353 21.448 14.111 20.968C14.713 20.585 15.383 20.161 15.844 19.308C16.0926 18.8493 16.2225 18.3357 16.222 17.814C16.2221 17.4903 16.1722 17.1685 16.074 16.86ZM15.551 0.6C15.747 0.844 15.847 1.172 16.047 1.829L20.415 16.176C18.7743 15.3246 17.0134 14.7284 15.193 14.408L12.35 4.8C12.3273 4.72337 12.2803 4.65616 12.2162 4.60844C12.152 4.56072 12.0742 4.53505 11.9943 4.53528C11.9143 4.5355 11.8366 4.56161 11.7727 4.60969C11.7089 4.65777 11.6623 4.72524 11.64 4.802L8.83 14.405C7.00149 14.724 5.23264 15.3213 3.585 16.176L7.974 1.827C8.174 1.171 8.274 0.843 8.471 0.6C8.64406 0.385433 8.86922 0.218799 9.125 0.116C9.415 0 9.757 0 10.443 0H13.578C14.264 0 14.608 0 14.898 0.117C15.1529 0.219851 15.3783 0.386105 15.551 0.6Z"+ fill="currentColor"+ ></path>+ </svg>+ ),+ },+ {+ name: "Vite",+ href: "/docs/installation/vite",+ icon: (+ <svg+ role="img"+ viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg"+ className="size-10"+ fill="currentColor"+ >+ <title>Vite</title>+ <path d="m8.286 10.578.512-8.657a.306.306 0 0 1 .247-.282L17.377.006a.306.306 0 0 1 .353.385l-1.558 5.403a.306.306 0 0 0 .352.385l2.388-.46a.306.306 0 0 1 .332.438l-6.79 13.55-.123.19a.294.294 0 0 1-.252.14c-.177 0-.35-.152-.305-.369l1.095-5.301a.306.306 0 0 0-.388-.355l-1.433.435a.306.306 0 0 1-.389-.354l.69-3.375a.306.306 0 0 0-.37-.36l-2.32.536a.306.306 0 0 1-.374-.316zm14.976-7.926L17.284 3.74l-.544 1.887 2.077-.4a.8.8 0 0 1 .84.369.8.8 0 0 1 .034.783L12.9 19.93l-.013.025-.015.023-.122.19a.801.801 0 0 1-.672.37.826.826 0 0 1-.634-.302.8.8 0 0 1-.16-.67l1.029-4.981-1.12.34a.81.81 0 0 1-.86-.262.802.802 0 0 1-.165-.67l.63-3.08-2.027.468a.808.808 0 0 1-.768-.233.81.81 0 0 1-.217-.6l.389-6.57-7.44-1.33a.612.612 0 0 0-.64.906L11.58 23.691a.612.612 0 0 0 1.066-.004l11.26-20.135a.612.612 0 0 0-.644-.9z"></path>+ </svg>+ ),+ },+ {+ name: "Remix",+ href: "/docs/installation/remix",+ icon: (+ <svg+ role="img"+ viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg"+ className="size-10"+ fill="currentColor"+ >+ <title>Remix</title>+ <path d="M21.511 18.508c.216 2.773.216 4.073.216 5.492H15.31c0-.309.006-.592.011-.878.018-.892.036-1.821-.109-3.698-.19-2.747-1.374-3.358-3.55-3.358H1.574v-5h10.396c2.748 0 4.122-.835 4.122-3.049 0-1.946-1.374-3.125-4.122-3.125H1.573V0h11.541c6.221 0 9.313 2.938 9.313 7.632 0 3.511-2.176 5.8-5.114 6.182 2.48.497 3.93 1.909 4.198 4.694ZM1.573 24v-3.727h6.784c1.133 0 1.379.84 1.379 1.342V24Z"></path>+ </svg>+ ),+ },];interface ComponentInstallationPropsdiff --git a/content/docs/installation/astro.mdx b/content/docs/installation/astro.mdxnew file mode 100644index 00000000..09538bf9--- /dev/null+++ b/content/docs/installation/astro.mdx@@ -0,0 +1,154 @@+---+title: Astro+description: Install and configure Astro.+---++<Steps>++### Create project++Start by creating a new Astro project:++```bash+npm create astro@latest+```++### Configure your Astro project++You will be asked a few questions to configure your project:++```txt showLineNumbers+- Where should we create our new project?+./your-app-name+- How would you like to start your new project?+Choose a starter template (or Empty)+- Do you plan to write TypeScript? Yes+- How strict should TypeScript be? Strict+- Install dependencies? Yes+- Initialize a new git repository? (optional) Yes/No+```++### Add React to your project++Install React using the Astro CLI:++```bash+npx astro add react+```++Answer `Yes` to all the question prompted by the CLI when installing React.++### Add Tailwind CSS to your project++Install Tailwind CSS using the Astro CLI:++```bash+npx astro add tailwind+```++Answer `Yes` to all the question prompted by the CLI when installing Tailwind CSS.++### Edit tsconfig.json file++Add the following code to the `tsconfig.json` file to resolve paths:++```ts {4-9} showLineNumbers+{+ "compilerOptions": {+ // ...+ "baseUrl": ".",+ "paths": {+ "@/*": [+ "./src/*"+ ]+ }+ // ...+ }+}+```++### Run the CLI++Run the `magicui-cli` init command to setup your project:++```bash+npx magicui-cli init+```++### Configure components.json++You will be asked a few questions to configure `components.json`:++```txt showLineNumbers+Would you like to use TypeScript (recommended)? no / yes+Which style would you like to use? › Default+Which color would you like to use as base color? › Slate+Where is your global CSS file? › ./src/styles/globals.css+Do you want to use CSS variables for colors? › no / yes+Where is your tailwind.config.js located? › tailwind.config.mjs+Configure the import alias for components: › @/components+Configure the import alias for utils: › @/lib/utils+Are you using React Server Components? › no+Write configuration to components.json Proceed? › yes+```++### Import the globals.css file++Import the `globals.css` file in the `src/pages/index.astro` file:++```ts {2} showLineNumbers+---+import '@/styles/globals.css'+---+```++### Update astro tailwind config++To prevent serving the Tailwind base styles twice, we need to tell Astro not to apply the base styles, since we already include them in our own `globals.css` file. To do this, set the `applyBaseStyles` config option for the tailwind plugin in `astro.config.mjs` to `false`.++```ts {3-5} showLineNumbers+export default defineConfig({+ integrations: [+ tailwind({+ applyBaseStyles: false,+ }),+ ],+});+```++### Update tailwind.config.mjs++When running `npx magicui-cli init`, your tailwind config for content will be overwritten. To fix this, change the `module.exports` to `export default` and the `content` section with the code below to your `tailwind.config.mjs` file:++```js {1-4} showLineNumbers+export default {+ content: ["./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}"],+};+```++### That's it++You can now start adding components to your project.++```bash+npx magicui-cli add blur-in+```++The command above will add the `BlurIn` component to your project. You can then import it like this:++```astro {2,10} showLineNumbers+---+import BlurIn from "@/components/magicui/blur-in";+---++<html lang="en">+ <head>+ <title>Astro</title>+ </head>+ <body>+ <BlurIn word={"Hello World"} client:load></BlurIn>+ </body>+</html>+```++</Steps>diff --git a/content/docs/installation/remix.mdx b/content/docs/installation/remix.mdxnew file mode 100644index 00000000..9a3b3fb1--- /dev/null+++ b/content/docs/installation/remix.mdx@@ -0,0 +1,124 @@+---+title: Remix+description: Install and configure Remix.+author: abdrahmanES1+---++<Steps>++### Create project++Start by creating a new Remix project using `create-remix`:++```bash+npx create-remix@latest my-app+```++### Run the CLI++Run the `magicui-cli` init command to setup your project:++```bash+npx magicui-cli init+```++### Configure components.json++You will be asked a few questions to configure `components.json`:++```txt showLineNumbers+✔ Would you like to use TypeScript (recommended)? … no / yes+✔ Which style would you like to use? › Default+✔ Which color would you like to use as base color? › Slate+✔ Where is your global CSS file? … app/tailwind.css+✔ Would you like to use CSS variables for colors? … no / yes+✔ Are you using a custom tailwind prefix eg. tw-? (Leave blank if not) …+✔ Where is your tailwind.config.js located? … tailwind.config.ts+✔ Configure the import alias for components: … ~/components+✔ Configure the import alias for utils: … ~/lib/utils+✔ Are you using React Server Components? … no / yes+✔ Write configuration to components.json. Proceed? … yes+```++### App structure++**Note**: This app structure is only a suggestion. You can place the files wherever you want.++- Place the UI components in the `app/components/magic-ui` folder.+- Your own components can be placed in the `app/components` folder.+- The `app/lib` folder contains all the utility functions. We have a `utils.ts` where we define the `cn` helper.+- The `app/tailwind.css` file contains the global CSS.++### Install Tailwind CSS++```bash+npm add -D tailwindcss@latest autoprefixer@latest+```++Then we create a `postcss.config.js` file:++```js+export default {+ plugins: {+ tailwindcss: {},+ autoprefixer: {},+ },+};+```++And finally we add the following to our `remix.config.js` file:++```js {4-5}+/** @type {import('@remix-run/dev').AppConfig} */+export default {+ ...+ tailwind: true,+ postcss: true,+ ...+};+```++### Add `tailwind.css` to your app++```bash+npm install @remix-run/css-bundle+```++In your `app/root.tsx` file, import the `tailwind.css` file:++```js {1, 4}+import { cssBundleHref } from "@remix-run/css-bundle";+import type { LinksFunction } from "@remix-run/node"; // or cloudflare/deno+import styles from "./tailwind.css"++export const links: LinksFunction = () => [+ ...(cssBundleHref+ ? [{ rel: "stylesheet", href: cssBundleHref }]+ : []),+ // ...+];+```++### That's it++You can now start adding components to your project.++```bash+npx magicui-cli add blur-in+```++The command above will add the `Button` component to your project. You can then import it like this:++```tsx {1,6} showLineNumbers+import BlurIn from "~/components/magicui/blur-in";++export default function Home() {+ return (+ <div>+ <BlurIn word={"Hello World"}></BlurIn>+ </div>+ );+}+```++</Steps>diff --git a/content/docs/installation/vite.mdx b/content/docs/installation/vite.mdxnew file mode 100644index 00000000..e3d38fc6--- /dev/null+++ b/content/docs/installation/vite.mdx@@ -0,0 +1,116 @@+---+title: Vite+description: Install and configure Vite.+author: abdrahmanES1+---++<Steps>++### Create project++Start by creating a new React project using `vite`:++```bash+npm create vite@latest+```++### Add Tailwind and its configuration++Install `tailwindcss` and its peer dependencies, then generate your `tailwind.config.js` and `postcss.config.js` files:++```bash+npm install -D tailwindcss postcss autoprefixer++npx tailwindcss init -p+```++### Edit tsconfig.json file++Add the following code to the `tsconfig.json` or `tsconfig.app.json` file to resolve paths:++```ts {4-9} showLineNumbers+{+ "compilerOptions": {+ // ...+ "baseUrl": ".",+ "paths": {+ "@/*": [+ "./src/*"+ ]+ }+ // ...+ }+}+```++### Update vite.config.ts++Add the following code to the vite.config.ts so your app can resolve paths without error++```bash+# (so you can import "path" without error)+npm i -D @types/node+```++```typescript+import path from "path";+import react from "@vitejs/plugin-react";+import { defineConfig } from "vite";++export default defineConfig({+ plugins: [react()],+ resolve: {+ alias: {+ "@": path.resolve(__dirname, "./src"),+ },+ },+});+```++### Run the CLI++Run the `magicui-cli` init command to setup your project:++```bash+npx magicui-cli init+```++### Configure components.json++You will be asked a few questions to configure `components.json`:++```txt showLineNumbers+Would you like to use TypeScript (recommended)? no / yes+Which style would you like to use? › Default+Which color would you like to use as base color? › Slate+Where is your global CSS file? › › src/index.css+Do you want to use CSS variables for colors? › no / yes+Where is your tailwind.config.js located? › tailwind.config.js+Configure the import alias for components: › @/components+Configure the import alias for utils: › @/lib/utils+Are you using React Server Components? › no / yes (no)+```++### That's it++You can now start adding components to your project.++```bash+npx magicui-cli add blur-in+```++The command above will add the `Button` component to your project. You can then import it like this:++```tsx {1,6} showLineNumbers+import BlurIn from "@/components/magicui/blur-in";++export default function Home() {+ return (+ <div>+ <BlurIn word={"Hello World"}></BlurIn>+ </div>+ );+}+```++</Steps>