clerk-custom-ui
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseComponent Customization
组件定制
Prerequisite: Ensurewraps your app. SeeClerkProvider.setup/
前提条件:确保包裹你的应用。请查看ClerkProvider目录。setup/
Component Customization Options
组件定制选项
| Task | Documentation |
|---|---|
| Appearance prop overview | https://clerk.com/docs/nextjs/guides/customizing-clerk/appearance-prop/overview |
| Layout (structure, logo, buttons) | https://clerk.com/docs/nextjs/guides/customizing-clerk/appearance-prop/layout |
| Themes (pre-built dark/light) | https://clerk.com/docs/nextjs/guides/customizing-clerk/appearance-prop/themes |
| Variables (colors, fonts, spacing) | https://clerk.com/docs/nextjs/guides/customizing-clerk/appearance-prop/variables |
| CAPTCHA configuration | https://clerk.com/docs/nextjs/guides/customizing-clerk/appearance-prop/captcha |
| Bring your own CSS | https://clerk.com/docs/nextjs/guides/customizing-clerk/appearance-prop/bring-your-own-css |
Appearance Pattern
Appearance模式
typescript
<SignIn
appearance={{
variables: {
colorPrimary: '#0000ff',
borderRadius: '0.5rem',
},
layout: {
logoImageUrl: '/logo.png',
socialButtonsVariant: 'iconButton',
},
}}
/>typescript
<SignIn
appearance={{
variables: {
colorPrimary: '#0000ff',
borderRadius: '0.5rem',
},
layout: {
logoImageUrl: '/logo.png',
socialButtonsVariant: 'iconButton',
},
}}
/>variables (colors, typography, borders)
variables(颜色、排版、边框)
| Property | Description |
|---|---|
| Primary color throughout |
| Background color |
| Border radius (default: |
| 属性 | 描述 |
|---|---|
| 全局主色调 |
| 背景色 |
| 边框圆角(默认值: |
layout (structure, logo, social buttons)
layout(结构、Logo、社交按钮)
| Property | Description |
|---|---|
| URL to custom logo |
| |
| |
| 属性 | 描述 |
|---|---|
| 自定义Logo的URL |
| |
| |
shadcn Theme
shadcn主题
If the project has (shadcn/ui installed), use the shadcn theme:
components.jsontypescript
import { shadcn } from '@clerk/themes'
<ClerkProvider
appearance={{
theme: shadcn,
}}
/>Also import shadcn CSS in your global.css:
css
@import 'tailwindcss';
@import '@clerk/themes/shadcn.css';如果项目中有(已安装shadcn/ui),请使用shadcn主题:
components.jsontypescript
import { shadcn } from '@clerk/themes'
<ClerkProvider
appearance={{
theme: shadcn,
}}
/>同时在你的global.css中导入shadcn CSS:
css
@import 'tailwindcss';
@import '@clerk/themes/shadcn.css';Workflow
工作流程
- Identify customization needs (colors, layout, theme, CSS)
- WebFetch the appropriate documentation from table above
- Follow official code examples from the docs
- Apply appearance prop to your Clerk components
- 确定定制需求(颜色、布局、主题、CSS)
- 从上方表格中获取对应的官方文档
- 遵循文档中的官方代码示例
- 为你的Clerk组件添加appearance属性
Common Pitfalls
常见问题
| Issue | Solution |
|---|---|
| Colors not applying | Use |
| Logo not showing | Put |
| Social buttons wrong | Add |
| Styling not working | Use appearance prop, not direct CSS (unless with bring-your-own-css) |
| 问题 | 解决方案 |
|---|---|
| 颜色未生效 | 使用 |
| Logo不显示 | 将 |
| 社交按钮样式错误 | 在 |
| 样式不生效 | 使用appearance属性,而非直接编写CSS(除非使用自定义CSS方案) |