Generated banner for Clerk Custom UI
Generated logo for Clerk Custom UI

Clerk Custom UI

ClerkOfficialCreated by clerk

  • Skill
  • Tool integration
  • Software development
  • MIT
  • No issues found

From the author

Custom authentication flows and component appearance - hooks (useSignIn, useSignUp), themes, colors, fonts, CSS. Use for custom sign-in/sign-up flows, appearance styling, visual customization, branding.
— the description by clerk

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides guidance on customizing the authentication experience provided by Clerk. It covers two primary areas: building custom sign-in and sign-up flows using React hooks, and styling pre-built Clerk components to match brand requirements. The skill distinguishes between Core 2 and current SDK versions, ensuring developers apply the correct properties, hooks, and theme imports for their specific environment.

What it does

  • Provides instructions for building custom authentication flows with useSignIn and useSignUp hooks.
  • Explains how to use the appearance prop to style Clerk components.
  • Details how to apply pre-built themes like dark, neobrutalism, and shadcn.
  • Guides developers on configuring variables such as colors, typography, and border radius.
  • Outlines how to manage component layout options like logos and social button variants.
  • Offers specific integration steps for projects using the shadcn/ui design system.

When to use it

  • When you need to build a bespoke sign-in or sign-up UI instead of using pre-built components.
  • When you need to align Clerk components with your application's branding and design system.
  • When you need to implement dark mode or specific visual themes for authentication pages.
  • When you are migrating or upgrading between Clerk Core 2 and current SDK versions.

Advantages

  • Ensures visual consistency across your application by supporting custom themes and CSS.
  • Provides clear version-specific guidance to avoid common API pitfalls.
  • Simplifies integration with popular design systems like shadcn/ui.
  • Offers granular control over authentication UI components and flow logic.

Usage examples

“How do I change the primary color of my Clerk sign-in component?”
The agent will explain how to use the appearance prop with the variables object to set the colorPrimary property.
“How can I apply the shadcn theme to my Clerk components?”
The agent will provide the necessary import statements for the shadcn theme and the required CSS import for your global stylesheet.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/clerk/clerk-custom-ui/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip clerk-custom-ui.zip -d .agents/skills

Documentation by clerk

Custom UI

Prerequisite: Ensure ClerkProvider wraps your app. See clerk-setup skill.

Version: Check package.json for the SDK version — see clerk skill for the version table. This determines which custom flow references to use below.

This skill covers two areas:

  1. Custom authentication flows — build your own sign-in/sign-up UI with hooks

  2. Appearance customization — theme, style, and brand Clerk's pre-built components

What Do You Need?

TaskReference
Custom sign-in (Core 2 / LTS)core-2/custom-sign-in.md
Custom sign-up (Core 2 / LTS)core-2/custom-sign-up.md
Custom sign-in (Current SDK v7+)core-3/custom-sign-in.md
Custom sign-up (Current SDK v7+)core-3/custom-sign-up.md
Show component pattern (Current SDK)core-3/show-component.md

Custom Flow References

TaskCore 2Current
Custom sign-in (useSignIn)core-2/custom-sign-in.mdcore-3/custom-sign-in.md
Custom sign-up (useSignUp)core-2/custom-sign-up.mdcore-3/custom-sign-up.md
<Show> component(use <SignedIn>, <SignedOut>, <Protect>)core-3/show-component.md

Appearance Customization

Appearance customization applies to both Core 2 and the current SDK.

Component Customization Options
Appearance Pattern
<SignIn
  appearance={{
    variables: {
      colorPrimary: '#0000ff',
      borderRadius: '0.5rem',
    },
    options: {
      logoImageUrl: '/logo.png',
      socialButtonsVariant: 'iconButton',
    },
  }}
/>

Core 2 ONLY (skip if current SDK): The options property was named layout. Use layout: { logoImageUrl: '...', socialButtonsVariant: '...' } instead of options.

variables (colors, typography, borders)
PropertyDescription
colorPrimaryPrimary color throughout
colorBackgroundBackground color
borderRadiusBorder radius (default: 0.375rem)

Opacity change: colorRing and colorModalBackdrop now render at full opacity. Use explicit rgba() values if you need transparency.

Core 2 ONLY (skip if current SDK): colorRing and colorModalBackdrop rendered at 15% opacity by default.

options (structure, logo, social buttons)
PropertyDescription
logoImageUrlURL to custom logo
socialButtonsVariant'blockButton' | 'iconButton' | 'auto'
socialButtonsPlacement'top' | 'bottom'
showOptionalFieldsShow optional fields (default: false)

Core 2 ONLY (skip if current SDK): This property is called layout, not options. Also, showOptionalFields defaulted to true.

Themes

Install themes from @clerk/ui:

npm install @clerk/ui
import { dark } from '@clerk/ui/themes'

<ClerkProvider appearance={{ theme: dark }} />

Core 2 ONLY (skip if current SDK): Themes are imported from @clerk/themes (install @clerk/themes instead of @clerk/ui). Example: import { dark } from '@clerk/themes'.

Theme stacking — pass an array where the last theme takes precedence:

import { dark, neobrutalism } from '@clerk/ui/themes'

<ClerkProvider appearance={{ theme: [dark, neobrutalism] }} />

CSS color-scheme support — the default theme respects the CSS color-scheme property for automatic light/dark mode toggling.

Available themes: dark, neobrutalism, shadcn, simple

shadcn Theme

IMPORTANT: If the project has components.json (shadcn/ui installed), ALWAYS apply the shadcn theme as the FIRST customization step. This ensures Clerk components visually match the existing shadcn design system. Skip this only if the user explicitly requests a different theme.

If the project uses shadcn/ui (check for components.json in the project root), always use the shadcn theme:

import { shadcn } from '@clerk/ui/themes'

<ClerkProvider appearance={{ theme: shadcn }} />

Also import shadcn CSS in your global styles:

@import 'tailwindcss';
@import '@clerk/ui/themes/shadcn.css';

Core 2 ONLY (skip if current SDK): Import from @clerk/themes and @clerk/themes/shadcn.css:

import { shadcn } from '@clerk/themes'
@import '@clerk/themes/shadcn.css';

Workflow

  1. Identify customization needs (custom flow or appearance)

  2. For custom flows: check SDK version → read appropriate core-2/ or core-3/ reference

  3. For appearance: WebFetch the appropriate documentation above

  4. Apply appearance prop to your Clerk components or build custom flow with hooks

Common Pitfalls

IssueSolution
Colors not applyingUse colorPrimary not primaryColor
Logo not showingPut logoImageUrl inside options: {} (or layout: {} in Core 2)
Social buttons wrongAdd socialButtonsVariant: 'iconButton' in options (or layout in Core 2)
Styling not workingUse appearance prop, not direct CSS (unless with bring-your-own-css)
Hook returns different shapeCheck SDK version — Core 2 and current have completely different useSignIn/useSignUp APIs

See Also

  • clerk-setup - Initial Clerk install

  • clerk-nextjs-patterns - Next.js patterns

  • clerk-orgs - B2B organizations

Files

core-3/custom-sign-in.md

Custom Sign-In Flow

Build a custom sign-in experience using the useSignIn() hook.

Hook API

import { useSignIn } from '@clerk/nextjs' // or @clerk/react, @clerk/expo

const { signIn, errors, fetchStatus } = useSignIn()
PropertyTypeDescription
signInSignInFutureSign-in object with namespaced methods
errorsErrors<SignInFields>Structured error object
fetchStatus'idle' | 'fetching'Network request status

Sign-In Methods

Password
const { error } = await signIn.password({
  identifier: '[email protected]',
  password: 'securePassword123',
})
SSO (OAuth / Enterprise)
const { error } = await signIn.sso({
  strategy: 'oauth_google', // or 'oauth_github', 'enterprise_sso', etc.
  redirectUrl: '/dashboard', // where to go after SSO completes
  redirectCallbackUrl: '/sso-callback', // intermediate callback route
})
Passkey
const { error } = await signIn.passkey({ flow: 'discoverable' })
Web3
const { error } = await signIn.web3({ strategy: 'web3_solana_signature' })
// or
const { error } = await signIn.web3({ strategy: 'web3_base_signature' })
const { error } = await signIn.ticket({ ticket: 'ticket_abc123' })
Email Code
// Send code (emailAddress is optional if a signIn already exists from a prior method call)
const { error } = await signIn.emailCode.sendCode({ emailAddress: '[email protected]' })

// Verify code
const { error } = await signIn.emailCode.verifyCode({ code: '123456' })
Phone Code
// Send code (phoneNumber is optional if a signIn already exists from a prior method call)
const { error } = await signIn.phoneCode.sendCode({ phoneNumber: '+12015551234' })

// Verify code
const { error } = await signIn.phoneCode.verifyCode({ code: '123456' })

MFA (Second Factor)

A second factor is required when signIn.status is one of:

  • 'needs_second_factor' — user has MFA enabled (TOTP, backup codes, etc.)

  • 'needs_client_trust' — new device sign-in without MFA; requires email or phone code verification

// TOTP (Authenticator app)
const { error } = await signIn.mfa.verifyTOTP({ code: '123456' })

// Backup code
const { error } = await signIn.mfa.verifyBackupCode({ code: 'backup-code-here' })

// Email code
const { error: sendErr } = await signIn.mfa.sendEmailCode()
const { error: verifyErr } = await signIn.mfa.verifyEmailCode({ code: '123456' })

// Phone code
const { error: sendErr } = await signIn.mfa.sendPhoneCode()
const { error: verifyErr } = await signIn.mfa.verifyPhoneCode({ code: '123456' })

Password Reset

// 1. Send reset code
const { error } = await signIn.resetPasswordEmailCode.sendCode()

// 2. Verify the code
const { error } = await signIn.resetPasswordEmailCode.verifyCode({ code: '123456' })

// 3. Submit new password
const { error } = await signIn.resetPasswordEmailCode.submitPassword({
  password: 'newSecurePassword123',
})

Device Trust

When a user signs in with a valid password from a new device without MFA enabled, the sign-in status becomes needs_client_trust. This requires an additional verification step:

if (signIn.status === 'needs_client_trust') {
  // Check supportedSecondFactors for available methods (email_code or phone_code)
  const factors = signIn.supportedSecondFactors
  // Use the appropriate mfa method to verify
}

Finalizing Sign-In

After successful authentication, call finalize() to activate the session:

await signIn.finalize({
  navigate: async ({ session, decorateUrl }) => {
    const destination = session.currentTask
      ? `/sign-in/tasks/${session.currentTask.key}`
      : '/'
    const url = decorateUrl(destination)
    // decorateUrl may return an absolute URL for Safari ITP
    if (url.startsWith('http')) {
      window.location.href = url
    } else {
      router.push(url)
    }
  },
})
  • decorateUrl(path) — decorates the URL with session info (required to support Safari's Intelligent Tracking Prevention). May return an absolute URL.

  • session.currentTask — check for pending session tasks before redirecting

Reset State

Clear local sign-in state and start over:

signIn.reset()

Error Handling

All methods return Promise<{ error: ClerkError | null }>. Errors are also available reactively on the hook:

const { signIn, errors } = useSignIn()

// Field-level errors
errors?.fields?.identifier // { code, message, longMessage? }
errors?.fields?.password   // { code, message, longMessage? }
errors?.fields?.code       // { code, message, longMessage? }

// Global errors (not tied to a field)
errors?.global // ClerkGlobalHookError[] | null

// Raw error array
errors?.raw // ClerkError[] | null

Complete Example: Email/Password with MFA

From the docs. Supports SMS verification codes, authenticator app (TOTP), and backup codes.

'use client'

import { useSignIn } from '@clerk/nextjs'
import { useRouter } from 'next/navigation'

export default function Page() {
  const { signIn, errors, fetchStatus } = useSignIn()
  const router = useRouter()

  const handleSubmit = async (formData: FormData) => {
    const emailAddress = formData.get('email') as string
    const password = formData.get('password') as string

    await signIn.password({
      emailAddress,
      password,
    })

    // If you're using the authenticator app strategy, remove this check.
    if (signIn.status === 'needs_second_factor') {
      await signIn.mfa.sendPhoneCode()
    }

    if (signIn.status === 'complete') {
      await signIn.finalize({
        navigate: ({ session, decorateUrl }) => {
          if (session?.currentTask) {
            // Handle pending session tasks
            // See https://clerk.com/docs/guides/development/custom-flows/authentication/session-tasks
            console.log(session?.currentTask)
            return
          }

          const url = decorateUrl('/')
          if (url.startsWith('http')) {
            window.location.href = url
          } else {
            router.push(url)
          }
        },
      })
    }
  }

  const handleMFAVerification = async (formData: FormData) => {
    const code = formData.get('code') as string
    const useBackupCode = formData.get('useBackupCode') === 'on'

    if (useBackupCode) {
      await signIn.mfa.verifyBackupCode({ code })
    } else {
      await signIn.mfa.verifyPhoneCode({ code })
      // If you're using the authenticator app strategy, use the following method instead:
      // await signIn.mfa.verifyTOTP({ code })
    }

    if (signIn.status === 'complete') {
      await signIn.finalize({
        navigate: ({ session, decorateUrl }) => {
          if (session?.currentTask) {
            // Handle pending session tasks
            // See https://clerk.com/docs/guides/development/custom-flows/authentication/session-tasks
            console.log(session?.currentTask)
            return
          }

          const url = decorateUrl('/')
          if (url.startsWith('http')) {
            window.location.href = url
          } else {
            router.push(url)
          }
        },
      })
    }
  }

  if (signIn.status === 'needs_second_factor') {
    return (
      <div>
        <h1>Verify your account</h1>
        <form action={handleMFAVerification}>
          <div>
            <label htmlFor="code">Code</label>
            <input id="code" name="code" type="text" />
            {errors.fields.code && <p>{errors.fields.code.message}</p>}
          </div>
          <div>
            <label>
              Use backup code
              <input type="checkbox" name="useBackupCode" />
            </label>
          </div>
          <button type="submit" disabled={fetchStatus === 'fetching'}>
            Verify
          </button>
        </form>
      </div>
    )
  }

  return (
    <>
      <h1>Sign in</h1>
      <form action={handleSubmit}>
        <div>
          <label htmlFor="email">Enter email address</label>
          <input id="email" name="email" type="email" />
          {errors.fields.identifier && <p>{errors.fields.identifier.message}</p>}
        </div>
        <div>
          <label htmlFor="password">Enter password</label>
          <input id="password" name="password" type="password" />
          {errors.fields.password && <p>{errors.fields.password.message}</p>}
        </div>
        <button type="submit" disabled={fetchStatus === 'fetching'}>
          Continue
        </button>
      </form>
      {errors && <p>{JSON.stringify(errors, null, 2)}</p>}
    </>
  )
}

Docs

Requirements and compatibility

Written for: Claude Code

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Declares allowed tools, Names Claude Code tools, Needs Node.js

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
clerk
Publisher
Clerk (Official)
Source
clerk/skills · skills/clerk-custom-ui · commit c5d2c0d
Licence
MIT License (redistribution allowed)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by clerk or Clerk.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download clerk-custom-ui.zip