-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: Theming guide #1413
Merged
Merged
docs: Theming guide #1413
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
65b7578
docs wip
cpcramer bb58909
tina edits
fakepixels 4323926
docs wip
cpcramer 32071a3
format fix
fakepixels 213393b
Merge branch 'paul/theming-guide-docs' of https://github.com/coinbase…
fakepixels 6ed1628
tina edits
fakepixels be3ff8b
asdf
cpcramer fac8902
asdf
cpcramer 1485493
asdf
cpcramer b9088ee
asdf
cpcramer 6cf03ed
asfd
cpcramer ba8a11f
Theme docs
cpcramer 959e426
asdf
cpcramer 9dad439
asf
cpcramer 06d4fef
asdf
cpcramer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
--- | ||
title: OnchainKit Themes · OnchainKit | ||
description: Customize the appearance of OnchainKit's components | ||
--- | ||
|
||
# OnchainKit Themes | ||
{/* <img alt="Themes" | ||
src="" | ||
height="364"/> */} | ||
|
||
## Overview | ||
|
||
OnchainKit provides flexible appearance control through two main features: `mode` and `theme`. | ||
|
||
- **Mode**: Controls the light/dark appearance and includes an auto option that inherits the system preference. | ||
- **Theme**: Governs the overall styling across components. | ||
|
||
You can choose from built-in themes or dynamically switch modes based on user preference or system settings, allowing for a customized and responsive user interface. | ||
|
||
## Built-in Themes | ||
|
||
OnchainKit offers multiple themes to quickly style your components. Set the theme via the `OnchainKitProvider` using `config.appearance.theme`: | ||
|
||
- `default`: Includes both light and dark modes. | ||
- `base`: Single mode only. | ||
- `cyberpunk`: Single mode only. | ||
- `hacker`: Single mode only. | ||
|
||
If no theme is selected, the **`default`** theme is applied automatically. | ||
|
||
```tsx twoslash | ||
// @noErrors: 2304 17008 1005 | ||
<OnchainKitProvider | ||
apiKey={process.env.NEXT_PUBLIC_ONCHAINKIT_API_KEY} | ||
chain={base} | ||
config={{ // [!code focus] | ||
appearance: { // [!code focus] | ||
mode: 'auto', // 'auto' | 'light' | 'dark' | ||
theme: 'default', // 'default' | 'base' | 'cyberpunk' | 'hacker' // [!code focus] | ||
}, // [!code focus] | ||
}} // [!code focus] | ||
> | ||
``` | ||
|
||
## Mode | ||
|
||
Control the color scheme by setting the `config.appearance.mode` property of the `OnchainKitProvider`: | ||
|
||
- `auto`: Automatically switches between light and dark mode based on the user’s OS preference. | ||
- `light`: Forces all components to use the light version of the theme. | ||
- `dark`: Forces all components to use the dark version of the theme. | ||
|
||
If no mode is specified, `auto` mode will be applied by default. | ||
|
||
```tsx twoslash | ||
// @noErrors: 2304 17008 1005 | ||
<OnchainKitProvider | ||
apiKey={process.env.NEXT_PUBLIC_ONCHAINKIT_API_KEY} | ||
chain={base} | ||
config={{ | ||
appearance: { | ||
mode: 'auto', // 'auto' | 'light' | 'dark' // [!code focus] | ||
theme: 'default', // 'default' | 'base' | 'cyberpunk' | 'hacker' | ||
}, | ||
}} | ||
> | ||
``` | ||
|
||
## CSS Overrides | ||
|
||
You can further customize the appearance by overriding CSS styles. This allows for fine-tuning the look of individual components beyond the provided themes. | ||
|
||
```css | ||
@layer base { | ||
:root | ||
.default-light, | ||
.default-dark, | ||
.base, | ||
.cyberpunk, | ||
.hacker { | ||
--ock-font-family: 'your-custom-value'; | ||
--ock-border-radius: 'your-custom-value'; | ||
--ock-border-radius-inner: 'your-custom-value'; | ||
--ock-text-inverse: 'your-custom-value'; | ||
--ock-text-foreground: 'your-custom-value'; | ||
--ock-text-foreground-muted: 'your-custom-value'; | ||
--ock-text-error: 'your-custom-value'; | ||
--ock-text-primary: 'your-custom-value'; | ||
--ock-text-success: 'your-custom-value'; | ||
--ock-text-warning: 'your-custom-value'; | ||
--ock-text-disabled: 'your-custom-value'; | ||
|
||
--ock-bg-default: 'your-custom-value'; | ||
--ock-bg-default-hover: 'your-custom-value'; | ||
--ock-bg-default-active: 'your-custom-value'; | ||
--ock-bg-alternate: 'your-custom-value'; | ||
--ock-bg-alternate-hover: 'your-custom-value'; | ||
--ock-bg-alternate-active: 'your-custom-value'; | ||
--ock-bg-inverse: 'your-custom-value'; | ||
--ock-bg-inverse-hover: 'your-custom-value'; | ||
--ock-bg-inverse-active: 'your-custom-value'; | ||
--ock-bg-primary: 'your-custom-value'; | ||
--ock-bg-primary-hover: 'your-custom-value'; | ||
--ock-bg-primary-active: 'your-custom-value'; | ||
--ock-bg-primary-washed: 'your-custom-value'; | ||
--ock-bg-primary-disabled: 'your-custom-value'; | ||
--ock-bg-secondary: 'your-custom-value'; | ||
--ock-bg-secondary-hover: 'your-custom-value'; | ||
--ock-bg-secondary-active: 'your-custom-value'; | ||
--ock-bg-error: 'your-custom-value'; | ||
--ock-bg-warning: 'your-custom-value'; | ||
--ock-bg-success: 'your-custom-value'; | ||
--ock-bg-default-reverse: 'your-custom-value'; | ||
|
||
--ock-icon-color-primary: 'your-custom-value'; | ||
--ock-icon-color-foreground: 'your-custom-value'; | ||
--ock-icon-color-foreground-muted: 'your-custom-value'; | ||
--ock-icon-color-inverse: 'your-custom-value'; | ||
--ock-icon-color-error: 'your-custom-value'; | ||
--ock-icon-color-success: 'your-custom-value'; | ||
--ock-icon-color-warning: 'your-custom-value'; | ||
|
||
--ock-line-primary: 'your-custom-value'; | ||
--ock-line-default: 'your-custom-value'; | ||
--ock-line-heavy: 'your-custom-value'; | ||
--ock-line-inverse: 'your-custom-value'; | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,32 +9,36 @@ export const sidebar = [ | |
text: 'Guides', | ||
items: [ | ||
{ | ||
text: 'Lifecycle Status', | ||
link: '/guides/lifecycle-status', | ||
text: 'Build Onchain Apps', | ||
link: '/guides/build-onchain-apps', | ||
Comment on lines
+12
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Made alphabetical |
||
}, | ||
{ | ||
text: 'Use Basename', | ||
link: '/guides/use-basename-in-onchain-app', | ||
text: 'Contribution', | ||
link: '/guides/contribution', | ||
}, | ||
{ | ||
text: 'Build Onchain Apps', | ||
link: '/guides/build-onchain-apps', | ||
text: 'Framegear', | ||
link: '/guides/framegear', | ||
}, | ||
{ | ||
text: 'Framegear', | ||
link: '/frame/framegear', | ||
text: 'Lifecycle Status', | ||
link: '/guides/lifecycle-status', | ||
}, | ||
{ | ||
text: 'Reporting a bug', | ||
link: '/guides/reporting-bug', | ||
}, | ||
{ | ||
text: 'Tailwindcss Integration', | ||
link: '/guides/tailwind', | ||
}, | ||
{ | ||
text: 'Reporting a bug', | ||
link: '/guides/reporting-bug', | ||
text: 'OnchainKit Themes', | ||
link: '/guides/themes', | ||
}, | ||
{ | ||
text: 'Contribution', | ||
link: '/guides/contribution', | ||
text: 'Use Basename', | ||
link: '/guides/use-basename-in-onchain-app', | ||
}, | ||
], | ||
}, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo fix