Intermediate

Customization

Brand your Chainlit chatbot with custom themes, logos, colors, authentication, and UI configuration for enterprise-ready deployment.

Configuration File

TOML - .chainlit/config.toml
[project]
name = "My AI Assistant"
enable_telemetry = false

[UI]
name = "My Assistant"
description = "Your intelligent coding companion"
default_theme = "dark"

[UI.theme.dark]
primary = "#6366f1"
background = "#0f172a"
paper = "#1e293b"

[UI.theme.light]
primary = "#4f46e5"
background = "#f8fafc"
paper = "#ffffff"

Custom Branding

File Structure
public/
  logo_dark.png       # Logo for dark theme (200x80px recommended)
  logo_light.png      # Logo for light theme
  favicon.png         # Browser tab icon
  watermark.png       # Chat watermark (optional)

Authentication

Python - Password Auth
import chainlit as cl

@cl.password_auth_callback
def auth_callback(username: str, password: str):
    if username == "admin" and password == "secret":
        return cl.User(
            identifier=username,
            metadata={"role": "admin"}
        )
    return None
Python - OAuth
@cl.oauth_callback
def oauth_callback(
    provider_id: str,
    token: str,
    raw_user_data: dict,
    default_user: cl.User,
):
    return default_user
TOML - Enable OAuth
[project]
enable_auth = true

# .env file:
# OAUTH_GOOGLE_CLIENT_ID=...
# OAUTH_GOOGLE_CLIENT_SECRET=...

Custom CSS

CSS - public/styles.css
/* Custom font */
.message-content {
  font-family: 'Inter', sans-serif;
}

/* Custom message bubble */
.message-avatar {
  border-radius: 8px;
}

/* Hide elements */
.watermark {
  display: none;
}

Chat Profiles

Python
@cl.set_chat_profiles
async def chat_profiles():
    return [
        cl.ChatProfile(
            name="GPT-4o",
            markdown_description="Most capable model",
        ),
        cl.ChatProfile(
            name="GPT-4o-mini",
            markdown_description="Faster, cheaper model",
        ),
    ]

@cl.on_chat_start
async def start():
    profile = cl.user_session.get("chat_profile")
    model = "gpt-4o" if profile == "GPT-4o" else "gpt-4o-mini"
    cl.user_session.set("model", model)
Starters: Use @cl.set_starters to show suggested prompts when the chat starts, helping users understand what your chatbot can do.

What's Next?

In our final lesson, we cover production deployment, Docker, error handling, and scaling best practices.