Skip to content
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 15 commits into from
Oct 15, 2024
5 changes: 4 additions & 1 deletion site/docs/pages/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ export default function RootLayout(props: { children: ReactNode }) {

This ensures that the OnchainKit styles are loaded and applied to your entire application.

For Tailwind CSS users, check out our [Tailwind Integration Guide](/guides/tailwind).
- For Tailwind CSS users, check out our [Tailwind Integration Guide](/guides/tailwind).

- Update the appearance of components by using our built-in themes or crafting your own custom theme.
Explore the possibilities in our [Theming Guide](/guides/themes).

::::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bun run dev
Visit http://localhost:1337 to start the **Framegear** interface. Enter the URL of your locally
running frame (e.g., `http://localhost:3000`) and click `Fetch` to validate your frame response and start testing.

![Fetch Frame](https://onchainkit.xyz/assets/fetch-frame.png)]
![Fetch Frame](https://onchainkit.xyz/assets/fetch-frame.png)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo fix


### Frame-specific setup

Expand Down
104 changes: 46 additions & 58 deletions site/docs/pages/guides/tailwind.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,64 +52,52 @@ To override default colorscheme, you need to modify the following css variables:

@layer base {
:root {
--ock-text-inverse: theme(colors.gray.50);
--ock-text-foreground: theme(colors.gray.950);
--ock-text-foreground-muted: theme(colors.gray.600);
--ock-text-error: theme(colors.rose.600);
--ock-text-primary: theme(colors.indigo.600);
--ock-text-success: theme(colors.lime.600);
--ock-text-warning: theme(colors.orange.600);
--ock-text-disabled: theme(colors.gray.400);

--ock-bg-default: theme(colors.gray.50);
--ock-bg-default-hover: theme(colors.gray.200);
--ock-bg-default-active: theme(colors.gray.300);
--ock-bg-alternate: theme(colors.gray.200);
--ock-bg-alternate-hover: theme(colors.gray.300);
--ock-bg-alternate-active: theme(colors.gray.400);
--ock-bg-inverse: theme(colors.gray.100);
--ock-bg-inverse-hover: theme(colors.gray.200);
--ock-bg-inverse-active: theme(colors.gray.300);
--ock-bg-primary: theme(colors.indigo.600);
--ock-bg-primary-hover: theme(colors.indigo.700);
--ock-bg-primary-active: theme(colors.indigo.800);
--ock-bg-secondary: theme(colors.slate.200);
--ock-bg-secondary-hover: theme(colors.slate.300);
--ock-bg-secondary-active: theme(colors.slate.400);
--ock-bg-error: theme(colors.rose.600);
--ock-bg-warning: theme(colors.orange.600);
--ock-bg-success: theme(colors.lime.300);
--ock-bg-default-reverse: theme(colors.gray.950);
}

.dark {
--ock-text-inverse: theme(colors.gray.950);
--ock-text-foreground: theme(colors.gray.50);
--ock-text-foreground-muted: theme(colors.gray.400);
--ock-text-error: theme(colors.rose.400);
--ock-text-primary: theme(colors.indigo.400);
--ock-text-success: theme(colors.lime.400);
--ock-text-warning: theme(colors.orange.400);
--ock-text-disabled: theme(colors.gray.600);
--ock-bg-default: theme(colors.gray.950);
--ock-bg-default-hover: theme(colors.gray.800);
--ock-bg-default-active: theme(colors.gray.700);
--ock-bg-alternate: theme(colors.gray.800);
--ock-bg-alternate-hover: theme(colors.gray.700);
--ock-bg-alternate-active: theme(colors.gray.600);
--ock-bg-inverse: theme(colors.gray.900);
--ock-bg-inverse-hover: theme(colors.gray.800);
--ock-bg-inverse-active: theme(colors.gray.700);
--ock-bg-primary: theme(colors.indigo.400);
--ock-bg-primary-hover: theme(colors.indigo.300);
--ock-bg-primary-active: theme(colors.indigo.200);
--ock-bg-secondary: theme(colors.slate.800);
--ock-bg-secondary-hover: theme(colors.slate.700);
--ock-bg-secondary-active: theme(colors.slate.600);
--ock-bg-error: theme(colors.rose.400);
--ock-bg-warning: theme(colors.orange.400);
--ock-bg-success: theme(colors.lime.700);
--ock-bg-default-reverse: theme(colors.gray.50);
--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';
}
}
```
Expand Down
129 changes: 129 additions & 0 deletions site/docs/pages/guides/themes.mdx
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';
}
}
```
28 changes: 16 additions & 12 deletions site/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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',
},
],
},
Expand Down