
如何使用Cursor AI生成风格统一且精致的UI
根据项目需求来划分UI模块
核心功能
向大模型尽可能详细地描述项目的功能时,建议采用GPT-4、Gemini 2.0 Flash,也可以尝试DeepSeek,Claude暂未尝试。
向大模型询问该如何划分项目的核心UI模块时,以我周末开发的送礼物小工具为例,大模型会告诉你项目的核心功能可以划分为商品添加模块、个性化礼物定制模块、礼物分享模块、礼物接收模块。当然,如果它遗漏了部分核心功能,你可以提醒它补充,但就目前来看,大模型对于项目的理解还是很到位的,甚至比我自己考虑得更加全面,令人赞叹。
辅助功能
列举完核心功能模块后,需要让大模型为项目添加辅助UI功能模块,以串联各个核心模块。这些辅助功能包括首页入口、用户鉴权、个人设置、历史记录查看和积分管理等。


细化各模块的UI功能
在确定各UI模块后,让大模型为每个功能模块提供具体细节。如果你暂时没有想法,可以先听听它的建议,然后在它的启发下展开细节讨论。

确定UI风格
在完成UI细节设计后,下一个关键环节是确定UI风格,这是保持整个项目UI风格统一的基础。
你可以向大模型询问适合的UI配色和元素风格。我认为可以借鉴Midjourney的提示词方式,告诉大模型你喜欢的UI设计师风格,不过这个方法我还没深入研究。
在开发送礼物工具时,大模型建议了清新治愈风、简约时尚风和浪漫梦幻风等风格选项。我选择了浪漫梦幻风,因为它能带来满满的少女感。
在后续开发中,大模型会在每次生成UI描述提示词时都加入统一的风格提示。这一点非常重要,因为它可以防止Cursor AI因上下文记忆丢失而导致UI风格不一致。
好的,很乐意为您推荐几种 UI 配色及元素风格,帮助您生成更符合您期望的 UI 代码。
在选择配色和元素风格时,我们主要考虑以下几个方面:
* **目标用户:** 谁会使用这个小程序?(年轻人、长辈、男性、女性等)
* **品牌调性:** 你希望小程序给用户传递什么样的感觉?(惊喜、浪漫、温馨、科技、简约等)
* **功能定位:** 这个小程序的主要功能是什么?(送礼、个性化定制等)
**以下是一些推荐的 UI 配色及元素风格,以及它们的特点和适用场景:**
**1. 清新治愈风**
省略...
**2. 简约时尚风**
省略...
**3. 浪漫梦幻风**
* **配色:**
* **主色调:** 粉色、紫色、淡蓝色等,给人浪漫、梦幻的感觉。
* **辅助色:** 金色、银色、白色等,用于点缀和提升质感。
* **元素风格:**
* **图标:** 带有装饰性的图标。
* **字体:** 带有浪漫气息的字体,例如手写体、衬线体。
* **形状:** 多使用心形、星形、花朵等浪漫的形状。
* **背景:** 搭配一些渐变色、模糊背景等。
* **特点:** 浪漫、梦幻、唯美、温馨。
* **适用场景:**
* 适合情人节、生日等浪漫场合的送礼场景。
* 适合女性用户,传递浪漫、梦幻的感觉。
* **关键词:** 浪漫、梦幻、唯美、温馨、精致
**4. 科技炫酷风**
省略...
**建议:**
1. **根据你的想法选择:** 选择你最喜欢,最符合你产品定位的配色和元素风格。
2. **参考优秀设计案例:** 参考一些优秀的设计案例,获取更多的灵感。
3. **尝试不同的组合:** 可以在 中尝试不同的配色和元素组合,看看效果如何。
4. **进行 A/B 测试:** 如果有条件,可以进行 A/B 测试,看看哪种风格更受用户欢迎。
**对于你的 "惊喜壳子" 小程序,我个人比较推荐 "清新治愈风" 或 "浪漫梦幻风",** 因为它们更符合送礼场景的氛围,更容易给用户带来愉悦和惊喜的感觉。
**下一步行动:**
1. **从上述推荐中选择你喜欢的风格:** 你可以根据你的偏好和产品定位,选择一种或几种风格进行尝试。
2. **在 中进行尝试:** 使用 的 AI 代码生成功能,根据你选择的风格,生成 UI 代码。
3. **对比不同风格的效果:** 对比不同风格的 UI 效果,选择你最喜欢的一种。
选择 UI 风格是一个非常主观的过程,希望我的建议能给你提供一些帮助。 期待看到你使用 生成的 “惊喜壳子” 的 UI!
基于UI风格,生成每个UI模块的提示词
生成提示词是个相对简单的步骤。基于之前与大模型的讨论成果,诚恳地请它帮你编写提示词即可。
当我首次看到大模型生成的UI描述提示词时,我才恍然大悟,明白了为什么直接让Cursor AI生成UI会产生混乱的结果。
好的,我们来针对 “惊喜壳子” 小程序的第一个页面——**商品添加页面**,生成详细的描述词,以便你快速生成符合柔和治愈浪漫风的 UI 代码。
**目标:**
* 创建一个简洁、直观、易于操作的商品添加页面。
* 符合柔和治愈浪漫风的整体风格。
* 使用户可以快速粘贴微信小店的商品链接或输入商品 ID。
**详细的描述词:**
Create a page with a soft pastel background, primarily using light pink and light blue. The page should have a centered layout with a title saying "添加惊喜商品" (Add Surprise Item) in a gentle, handwritten-style font, or a rounded sans-serif if handwritten font is not supported.
Below the title, create a rounded rectangle text input field with a light gray border. The input field should have a placeholder text saying “请粘贴微信小店商品链接或输入商品ID” (Please paste WeChat Shop product link or enter product ID). Use a readable, standard font for placeholder text.
Beneath the input field, create a large, rounded rectangular button with the text “添加” (Add). The button should be in a slightly deeper shade of pink and have white text. When the user taps/clicks on the button, the button should appear to animate by slightly deepening the color.
Add subtle, heart-shaped decorations around the button, ensuring that these decorations are small and do not distract from the main content. Use a light color for the heart decorations, such as pale pink.
Use a soft, rounded design for all elements, avoiding sharp corners. The page should feel spacious, with ample white space to give a calm and comforting aesthetic. Add subtle and gentle fade in animation when the page is loaded.
The overall feel of the page should be welcoming and encouraging.
**V0 描述词分解说明:**
1. **整体风格描述:**
* `Create a page with a soft pastel background, primarily using light pink and light blue.`
* 描述页面背景色,明确使用柔和的粉色和蓝色。
* `The page should feel spacious, with ample white space to give a calm and comforting aesthetic.`
* 强调页面留白,营造舒适感。
* `Add subtle and gentle fade in animation when the page is loaded.`
* 描述页面加载的动画效果,使页面呈现更流畅。
2. **标题描述:**
* `The page should have a centered layout with a title saying "添加惊喜商品" (Add Surprise Item) in a gentle, handwritten-style font, or a rounded sans-serif if handwritten font is not supported.`
* 描述页面标题,使用 “添加惊喜商品” 作为标题,并强调字体风格,优先选择手写体,如果不支持则使用圆角无衬线体。
3. **输入框描述:**
* `Below the title, create a rounded rectangle text input field with a light gray border.`
* 描述输入框形状,使用圆角矩形和浅灰色边框。
* `The input field should have a placeholder text saying “请粘贴微信小店商品链接或输入商品ID” (Please paste WeChat Shop product link or enter product ID). Use a readable, standard font for placeholder text.`
* 描述输入框占位符文字,使用 “请粘贴微信小店商品链接或输入商品ID” 作为提示文字,字体使用可读的标准字体。
4. **按钮描述:**
* `Beneath the input field, create a large, rounded rectangular button with the text “添加” (Add). The button should be in a slightly deeper shade of pink and have white text.`
* 描述按钮的形状、文本和颜色,明确按钮为圆角矩形,文本为 “添加”,颜色为稍深的粉色,文字为白色。
* `When the user taps/clicks on the button, the button should appear to animate by slightly deepening the color.`
* 描述按钮的动画效果,强调点击时颜色加深。
5. **装饰元素描述:**
* `Add subtle, heart-shaped decorations around the button, ensuring that these decorations are small and do not distract from the main content. Use a light color for the heart decorations, such as pale pink.`
* 描述按钮周围的装饰元素,使用小的、淡淡的粉色爱心装饰,不喧宾夺主。
6. **整体风格描述补充:**
* `Use a soft, rounded design for all elements, avoiding sharp corners.`
* 强调所有元素都使用柔和的圆角设计,避免出现尖锐边角。
* `The overall feel of the page should be welcoming and encouraging.`
* 描述页面的整体感觉,要具有欢迎和鼓励的氛围。
**注意事项:**
* **分步实现:** 一次性描述所有内容可能无法完全符合预期,建议逐步描述,并进行测试。
* **迭代优化:** 初次生成的代码可能不完美,需要进行迭代优化,根据实际效果进行调整。
* **尝试不同的描述方式:** 如果对生成结果不满意,可以尝试不同的描述方式,看看效果如何。
这个详细的描述词已经尽可能地涵盖了页面设计的各个方面。
将UI描述提示词丢入Cursor生成UI
这一步就没啥好讲的了,向Cursor AI复制粘贴后,等待它生成代码即可。

UI细节调整
如果你对生成的UI整体满意,但对某些局部细节不满意,可以向大模型详细描述需要修改的部分。大模型会重新生成完整的UI描述,并单独列出变动部分的描述。你可以将这些变动部分的描述提供给Cursor AI,让它针对性地调整UI。
**问:**我要对音乐播放的UI做一些小修改,播放过程中出现跳跃的优雅的频谱柱,让画面有动画感
**答:**
好的,在音乐播放 UI 中添加跳跃的优雅频谱柱,是一个非常棒的主意,这可以使页面更具活力和动感,与音乐氛围相得益彰。
我们来详细描述如何将频谱柱效果融入音乐播放 UI 中,并更新描述词:
**核心思路:**
* **频谱柱样式:** 使用简洁、优雅的线条或柱状图,颜色与整体主题色一致(淡粉色、淡蓝色)。
* **跳跃效果:** 频谱柱应随着音乐节奏跳跃,高度和频率应与音乐的音量和频率相关。
* **动画过渡:** 频谱柱的跳跃应平滑自然,避免出现卡顿感。
* **整体融合:** 频谱柱应与整体 UI 风格和谐统一,避免过于突兀。
**更新后的描述词 (包含频谱柱动画):**
Create a full-screen page with a soft pastel background, primarily using light pink and light blue. This page should be designed to maximize the feeling of surprise and delight.
Initially, the screen should display a beautifully designed gift box at the center, using rounded corners and soft, pastel colors (such as light pink and a hint of light blue). The box should appear closed.
The opening animation should be as follows:
- The lid of the gift box should smoothly move upwards, rotating slightly, revealing the personalized content inside.
- As the lid opens, the background should subtly fade in, and the cover image (or a default image if no cover is uploaded), the greeting message, and a subtle music icon should gently fade into view, becoming fully visible when the lid animation completes.
- This animation should be smooth and gentle, emphasizing the magical aspect of unveiling the contents.
Once the animation completes, the cover image should be displayed in a large area, centered on the screen, and with a slightly rounded border.
Below the cover, provide space for the greeting message, using a legible and gently styled font. The text should be displayed with an emphasis on readability and warmth.
If the user provided custom music, a subtle music icon indicating that background music is available should be present. Below the music icon (or in place of it if no custom music is available), add an animated audio visualizer. The visualizer should consist of elegant vertical bars that subtly pulse and jump according to the rhythm and intensity of the music. The bars should use soft, pastel colors that complement the overall page aesthetic (light pink and a hint of light blue). The animation of the visualizer should be smooth and continuous, creating a gentle and elegant effect.
Below the greeting message (or the music visualizer, if present), add a rounded rectangular button with the text "查看礼品" (View Gift). The button should have a pale pink background with dark gray text. When the button is tapped/clicked, it should animate by scaling slightly and changing the background to a slightly darker shade of pink.
The background music (if any) should start playing automatically when the page loads (after the box animation) and should be low in volume. Ensure there is a small, discreet icon (such as a music note) in the corner of the page, which when clicked would allow the user to pause/play the music. The pause/play music icon should appear even if no custom music is available to give the user control over background music.
Use a soft, rounded design for all elements, avoiding sharp corners. The overall feel should be warm, inviting, and delightful. Add a gentle, smooth fade-in animation for all elements when the page is loaded (after the box animation is complete).
**描述词分解说明 (包含频谱柱动画):**
1. **整体风格描述:**
* `Create a full-screen page with a soft pastel background, primarily using light pink and light blue.`
* 描述页面背景色,使用柔和的粉色和蓝色为主。
* `Use a soft, rounded design for all elements, avoiding sharp corners.`
* 强调所有元素都使用柔和的圆角设计,避免出现尖锐边角。
* `The overall feel should be warm, inviting, and delightful.`
* 描述页面整体感觉,需要温暖、邀请和愉悦。
* `Add a gentle, smooth fade-in animation for all elements when the page is loaded (after the box animation is complete).`
* 描述页面加载动画,所有元素淡入。
2. **初始盒子状态描述:**
* `Initially, the screen should display a beautifully designed gift box at the center, using rounded corners and soft, pastel colors (such as light pink and a hint of light blue). The box should appear closed.`
* 描述初始状态,屏幕中央显示一个精美设计的礼品盒,使用柔和的粉色和蓝色,盒子处于闭合状态。
3. **动画描述:**
* `The opening animation should be as follows:`
* 描述接下来是一段打开的动画。
* `- The lid of the gift box should smoothly move upwards, rotating slightly, revealing the personalized content inside.`
* 描述礼品盒盖子的动画效果,平滑向上移动并轻微旋转,露出内部内容。
* `- As the lid opens, the background should subtly fade in, and the cover image (or a default image if no cover is uploaded), the greeting message, and a subtle music icon should gently fade into view, becoming fully visible when the lid animation completes.`
* 描述打开盖子的同时,背景淡入,封面、祝福语和音乐图标等元素淡入并完全显示。
* `- This animation should be smooth and gentle, emphasizing the magical aspect of unveiling the contents.`
* 强调动画效果应该平滑柔和,体现揭开礼物的魔幻感。
4. **动画完成后页面元素描述:**
* `Once the animation completes, the cover image should be displayed in a large area, centered on the screen, and with a slightly rounded border.`
* 描述动画完成后,封面图在屏幕中央大面积显示。
* `Below the cover, provide space for the greeting message, using a legible and gently styled font. The text should be displayed with an emphasis on readability and warmth.`
* 描述祝福语展示区域,封面下方显示,字体可读且柔和,强调温暖感。
* `If the user provided custom music, a subtle music icon indicating that background music is available should be present. Below the music icon (or in place of it if no custom music is available), add an animated audio visualizer. The visualizer should consist of elegant vertical bars that subtly pulse and jump according to the rhythm and intensity of the music. The bars should use soft, pastel colors that complement the overall page aesthetic (light pink and a hint of light blue). The animation of the visualizer should be smooth and continuous, creating a gentle and elegant effect.`
* 描述如果有自定义音乐,显示一个音乐图标,如果没有,则显示一个音乐频谱柱,根据音乐节奏跳跃,线条简洁优雅,颜色与整体风格一致。
5. **按钮描述:**
* `Below the greeting message (or the music visualizer, if present), add a rounded rectangular button with the text "查看礼品" (View Gift). The button should have a pale pink background with dark gray text. When the button is tapped/clicked, it should animate by scaling slightly and changing the background to a slightly darker shade of pink.`
* 描述 “查看礼品” 按钮,圆角矩形,文字为“查看礼品”,背景色为浅粉色,文字颜色为深灰色,点击时,按钮放大并背景色加深。
6. **音乐描述:**
* `The background music (if any) should start playing automatically when the page loads (after the box animation) and should be low in volume. Ensure there is a small, discreet icon (such as a music note) in the corner of the page, which when clicked would allow the user to pause/play the music. The pause/play music icon should appear even if no custom music is available to give the user control over background music.`
* 描述背景音乐,动画完成后自动播放,音量较低,页面角落显示播放/暂停按钮。即使没有自定义音乐,也要显示播放/暂停按钮。
**注意事项:**
* **频谱柱实现:** 可能无法直接生成复杂的音乐频谱柱动画,你可能需要在生成的代码基础上进行手动调整和优化。
* **音乐播放:** 你可能需要自己实现音乐播放和音量控制功能。
* **分步实现:** 一次性描述所有内容可能无法完全符合预期,建议分步骤描述,并进行测试。
* **迭代优化:** 初次生成的代码可能不完美,需要进行迭代优化,根据实际效果进行调整。
* **尝试不同的描述方式:** 如果对生成结果不满意,可以尝试不同的描述方式,看看效果如何。
这个详细的描述词加入了 “打开盒子” 动画和频谱柱效果,相信可以给你的用户带来更棒的惊喜体验。 现在,你可以尝试生成带有动画效果和音乐频谱柱的接收页面了。 期待你的作品! 如果你在生成过程中遇到任何问题,随时可以向我提问。
结束语
使用这套方法后,仿佛打开了Cursor 生成UI的新世界大门,我猜Vercel V0工具可能也是组合使用了一套工作流来实现UI的生成,核心估计还是大语言模型。如果有什么好的建议,也欢迎大家讨论,共同进步。
转载请备注我的即刻地址@JackTu: https://okjk.co/zcUC65 以及CursorHow入门网站:https://cursorhow.com