Creates a UI component based on a natural language description
Provides a real-time preview of the generated component
Adds the generated component to your project
Magic UI Generator is a powerful AI-driven tool that helps developers create beautiful, modern UI components instantly through natural language descriptions. It transforms simple text prompts into fully functional, customizable UI components inspired by 21st.dev's component library. The tool integrates seamlessly with popular IDEs like Cursor, Windsurf, and VS Code, providing a streamlined workflow for UI development. With features like real-time preview, TypeScript support, and SVGL integration for brand assets, Magic UI Generator significantly accelerates frontend development while maintaining high-quality standards.
Magic UI Generator transforms the way developers create UI components by leveraging AI to generate high-quality, customizable components from natural language descriptions. This tool is designed to integrate with your development workflow, making UI creation faster and more intuitive.
There are several ways to install and configure Magic UI Generator:
Before installation, you'll need to generate an API key:
The simplest way to install is using the CLI:
npx @21st-dev/cli@latest install <client> --api-key <your-api-key>
Replace <client>
with your IDE of choice: cursor
, windsurf
, cline
, or claude
.
Add the following configuration to your IDE's MCP config file:
{
"mcpServers": {
"@21st-dev/magic": {
"command": "npx",
"args": ["-y", "@21st-dev/magic@latest", "API_KEY=\"your-api-key\""]
}
}
}
Config file locations:
~/.cursor/mcp.json
~/.codeium/windsurf/mcp_config.json
~/.cline/mcp_config.json
~/.claude/mcp_config.json
For VS Code users, you can add the following to your User Settings (JSON):
{
"mcp": {
"inputs": [
{
"type": "promptString",
"id": "apiKey",
"description": "21st.dev Magic API Key",
"password": true
}
],
"servers": {
"@21st-dev/magic": {
"command": "npx",
"args": ["-y", "@21st-dev/magic@latest"],
"env": {
"API_KEY": "${input:apiKey}"
}
}
}
}
}
Alternatively, you can create a .vscode/mcp.json
file in your workspace with similar configuration.
Using Magic UI Generator is straightforward:
Initiate Component Creation
/ui
followed by a description of the component you need/ui create a modern navigation bar with responsive design
Review and Accept
Integration
All generated components are fully customizable:
If you encounter issues:
npx @21st-dev/magic@latest
to ensure you have the latest versionFor additional support, visit 21st.dev/magic/support.