šŸ“ Sign Up | šŸ” Log In

← Root | ↑ Up

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā” │ šŸ“„ shadcn/directory/clerk/clerk-docs/reference/ios/clerk-theme │ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

╔══════════════════════════════════════════════════════════════════════════════════════════════╗
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘

title: 'ClerkTheme' description: Utilize Clerk's ClerkTheme to adjust the general styles of the iOS components, like colors, fonts, and design properties. sdk: ios

The ClerkTheme is used to customize the appearance of Clerk iOS components by adjusting colors, fonts, and design properties. It provides a comprehensive theming system that allows you to create a consistent visual experience across all Clerk components.

Structure

ClerkTheme consists of three main properties:

  • colors - Color properties for various UI elements.
  • fonts - Font properties for different text styles.
  • design - Design properties like border radius.

Colors

The colors property contains the following color options:

<Properties> - `primary` - `Color`

The primary color used throughout the components.


  • background
  • Color

The background color for containers.


  • input
  • Color

The background color used for input fields.


  • danger
  • Color

The color used for error states.


  • success
  • Color

The color used for success states.


  • warning
  • Color

The color used for warning states.


  • foreground
  • Color

The color used for text.


  • mutedForeground
  • Color

The color used for secondary text.


  • primaryForeground
  • Color

The color used for text on the primary background.


  • inputForeground
  • Color

The color used for text in input fields.


  • neutral
  • Color

The color that will be used to generate the neutral shades the components use.


  • ring
  • Color

The color of the ring when an interactive element is focused.


  • muted
  • Color

The color used for muted backgrounds.


  • shadow
  • Color

The base shadow color used in the components.


  • border
  • Color

The base border color used in the components. </Properties>

Fonts

The fonts property contains the following font options based on iOS Dynamic Type:

<Properties> - `largeTitle` - `Font`
  • title
  • Font

  • title2
  • Font

  • title3
  • Font

  • headline
  • Font

  • subheadline
  • Font

  • body
  • Font

  • callout
  • Font

  • footnote
  • Font

  • caption
  • Font

  • caption2
  • Font </Properties>

Design

The design property contains the following design options:

<Properties> - `borderRadius` - `CGFloat`

The border radius used throughout the components. By default, this is set to 6.0. </Properties>

Usage

You can customize Clerk iOS components by creating a ClerkTheme and applying it to the SwiftUI environment.

Apply a custom theme to all Clerk components

To customize all Clerk components in your app, create a ClerkTheme and apply it to your root view using the environment.

import SwiftUI
import Clerk

struct MyApp: App {
  var body: some Scene {
    WindowGroup {
      ContentView()
        .environment(\.clerkTheme, customTheme)
    }
  }

  let customTheme = ClerkTheme(
    colors: .init(
      primary: .blue,
    ),
    design: .init(
      borderRadius: 12.0
    )
  ) 
}

Apply a theme to specific components

You can apply a theme to specific Clerk components by using the environment modifier on individual views. The theme used here will apply to all children of this view.

struct SignInView: View {
  var body: some View {
    AuthView()
      .environment(\.clerkTheme, customTheme)
  }

  let customTheme = ClerkTheme(
    colors: .init(
      primary: .purple,
    )
  )
}

Adjust a specific property of the theme

You can adjust a specific property of the theme by modifying a single property.

struct SignInView: View {
  var body: some View {
    AuthView()
      .environment(\.clerkTheme.colors.primary, .green)
  }
}

Custom fonts

You can customize fonts by providing a font family name or individual font specifications.

Using a font family name

struct CustomFontView: View {
  var body: some View {
    AuthView()
      .environment(\.clerkTheme, customTheme)
  }

  let customTheme = ClerkTheme(
    fonts: .init(fontFamily: "Helvetica Neue")
  )
}

Using individual font specifications

struct CustomFontView: View {
  var body: some View {
    AuthView()
      .environment(\.clerkTheme, customTheme)
  }

  let customTheme = ClerkTheme(
    fonts: .init(
      largeTitle: .init(name: "Helvetica Neue", size: 34.0),
      title: .init(name: "Helvetica Neue", size: 28.0),
      title2: .init(name: "Helvetica Neue", size: 22.0),
      title3: .init(name: "Helvetica Neue", size: 20.0),
      headline: .init(name: "Helvetica Neue", size: 18.0),
    )
  )
}

Light and Dark Mode Support

Clerk iOS components automatically support both light and dark mode appearance, adapting seamlessly to the user's system preferences.

<div style={{ display: 'flex', gap: '20px', alignItems: 'flex-start' }}> ![Light Mode](/docs/images/ui-components/ios-user-profile-view.png){{ style: { maxWidth: '230px' } }} ![Dark Mode](/docs/images/ui-components/ios-user-profile-view-dark.png){{ style: { maxWidth: '230px' } }} </div>

Using Asset Catalog Colors

For more sophisticated appearance support, create colors in your Asset Catalog with separate light and dark variants:

extension ClerkTheme {
  static let brandTheme = ClerkTheme(
    colors: .init(
      primary: Color(.brandPrimary), // Asset with light/dark variants
      background: Color(.brandBackground),
      foreground: Color(.brandText),
      danger: Color(.brandDanger)
    )
  )
}

If Clerk's prebuilt theming doesn't meet your specific needs, you can create completely custom authentication flows using the Clerk API. For more information, see the custom flow guides.

ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•

← Root | ↑ Up