Apply Custom Themes to OnchainKit Bridge Component using AI
Base Appchains offer builders dedicated blockspace with powerful customization options including: custom gas tokens, sequencer-fee logic, and contract allowlisting. OnchainKit’s Bridge component is equally flexible allowing you to craft a branded bridge experience. In this guide, you’ll use AI to generate a color palette based on your brand and apply it as a custom theme across all OnchainKit components.
This tutorial assumes you have already deployed a Base Appchain and installed OnchainKit (version ≥ 0.38.7).
Objectives
By the end of this guide, you will be able to:
- Use an LLM to generate a brand-aligned color palette in the OnchainKit CSS format.
- Replace your project’s
globals.css
with the AI-generated theme. - Configure your Next.js layout to import the custom CSS and enable light/dark modes.
- Update the OnchainKit provider to use your custom theme.
Prerequisites
- A deployed Base Appchain
- OnchainKit (version ≥ 0.38.7) installed
- Access to an AI LLM that can process prompts
- Familiarity with Next.js, TypeScript, and CSS
Generate a Color Palette Using AI (optional)
Use the OnchainKit Boilerplate
Attach your globals.css example from the OnchainKit docs. You can find the boilerplate here.
Paste this prompt into your AI LLM of choice, along with your existing globals.css file, the OnchainKit CSS boilerplate, and a screenshot of your brand’s design:
The AI should return something similar to:
Replace Your Global CSS
This guide assumes you have already bootstrapped your project with the OnchainKit Boilerplate. If not, you can do so by running:
In your terminal, navigate to your project root:
Replace the contents of app/globals.css
with the AI-generated CSS.
Confirm you’re importing globals.css in your root layout (layout.tsx
):
Configure the Root Layout to Apply the Theme
In layout.tsx
, wrap your <html>
tag with the light-mode class and apply your background variable:
Enable Your Custom Theme in OnchainKit Provider
Open app/providers.tsx
and update the provider’s appearance settings:
This ensures OnchainKit uses your AI-generated theme and respects the user’s system light/dark preference.
Run and Verify
Visit your local server (http://localhost:3000) and confirm:
- The CSS variables match your brand’s palette
- OnchainKit components including the Bridge widget reflect your custom theme
- Light and dark mode toggle correctly based on user settings
Conclusion
In this tutorial, you learned how to:
Use AI to generate a brand-aligned color palette for OnchainKit.
- Replace your globals.css with the AI-generated theme.
- Configure your Next.js layout and OnchainKit provider for theming.
- For more details, see the OnchainKit Custom Theme guide.
Happy building!