Thank you for your interest in contributing to MagicUI! We appreciate your support and look forward to your contributions. This guide will help you understand the directory structure and provide detailed instructions on how to add a new component to MagicUI.
Read the example PR to learn which files you need to add. You only need to change 5 files to add a new component or effect and it only takes around 10 minutes of work!
Once done, open a pull request from your forked repo to the main repo here.
-
Fork this repository
Click here to fork the repository. -
Clone your forked repository to your local machine
git clone https://github.com/<YOUR_USERNAME>/magicui.git
-
Navigate to the project directory
cd magicui
-
Create a new branch for your changes
git checkout -b my-new-branch
-
Install dependencies
pnpm i
-
Create a
.env.local
filetouch .env.local && echo "NEXT_PUBLIC_APP_URL=http://localhost:3000" > .env.local
-
Run the project
pnpm dev
To add a new component to MagicUI, you will need to modify several files. Follow these steps:
File: config/docs.ts
Add metadata for your component in the sidebar navigation.
// Add sidebar button meta for your component
{
title: "Example Component",
href: `/docs/components/example-component`,
items: [],
label: "New",
}
File: registry/components/magicui/example-component.tsx
Create the main component file.
// Create your component here
import React from 'react'
const ExampleComponent = () => {
return (
<div>
This is your component.
</div>
)
}
export default ExampleComponent;
File: registry/components/example/example-component-demo.tsx
Provide a basic example to showcase your component.
// Create a very basic example showcasing your component
import ExampleComponent from '@/registry/components/magicui/example-component'
const ExampleComponentDemo = () => (
<div className="relative justify-center">
<ExampleComponent />
</div>
)
export default ExampleComponentDemo;
File: content/docs/components/example-component.mdx
Create an MDX file for documenting your component.
---
title: Example Component
date: 2024-06-01
description: Example component for demonstrating MagicUI integration
author: Bankkroll
published: true
---
<ComponentPreview name="example-component-demo" />
<Steps>
### Installation
Copy and paste the following code into your project.
```text
components/magicui/example-component.tsx
```
<ComponentSource name="example-component" />
</Steps>
## Props
| Prop | Type | Description | Default |
| ------------------------- | ------------------------- | ------------------------------------------------------------ | -------- |
| color | String | The color of the component | "blue" |
## Credits
- Credit to [Bankk](https://www.x.com/bankkroll_eth)
File: registry/index.tsx
Export your component and example in the registry.
const ui: Registry = {
// other components
"example-component": {
name: "example-component",
type: "components:ui",
files: ["registry/components/magicui/example-component.tsx"],
},
}
const example: Registry = {
// other examples
"example-component-demo": {
name: "example-component",
type: "components:example",
files: ["registry/components/example/example-component-demo.tsx"],
component: React.lazy(
() => import("@/registry/components/example/example-component-demo"),
),
},
}
For any help or questions, please open a new GitHub issue and we will get back to you :)