Skip to content

Commit

Permalink
Merge pull request #5 from yp717/feat(theme-override)
Browse files Browse the repository at this point in the history
feat(theme-override)
  • Loading branch information
yp717 authored Jul 27, 2023
2 parents d11cffe + 46785d0 commit a498926
Show file tree
Hide file tree
Showing 8 changed files with 2,015 additions and 1,650 deletions.
27 changes: 27 additions & 0 deletions apps/docs/src/app/advanced-usage/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,30 @@ plugins: [
// ...
],
```

## Theme Pinning

If you want to pin a specific theme on a subset of elements in the DOM, you can do this by using the `pin-theme-light` and `pin-theme-dark` classNames. This enables you to have a top level theme on your application (that is light, dark, or can switch between both), and simultaneously fix a subset of the page to a specific theme.

To enable this feature, you should set the `darkMode` option in your tailwind config to `radix`:

```{javascript}
module.exports = {
darkMode: 'radix',
// ...
}
```

This is because of clashes between the Tailwind dark mode strategy and the radix strategy. Please note you only need to enable this feature if you want to use the `pin-theme-light` and `pin-theme-dark` classNames.

```{html}
<!-- Any divs in the scope of pin-theme-light will always be light themed -->
<div class="pin-theme-light">
<div className="w-10 h-10 bg-green-500 dark:bg-crimson-500"></div>
</div>
<!-- Any divs in the scope of pin-theme-dark will always be dark themed -->
<div class="pin-theme-dark">
<div className="w-10 h-10 bg-yellow-500 dark:bg-blue-500"></div>
</div>
```
3 changes: 2 additions & 1 deletion apps/docs/src/app/color-palette/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import Link from 'next/link'
const ColorPalettePage: NextPage = () => {
return (
<div className="h-full w-5xl">
<h1 className="text-slate-1200 text-4xl font-bold">Color Palette</h1>
<h1 className="text-4xl font-bold text-slate-1200">Color Palette</h1>

<p className="text-slate-1100">
This plugin integrates the wonderful{' '}
<Link href="https://www.radix-ui.com/colors">
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { tailwindRadixPlugin } = require('tailwindcss-radix-colors-plugin')
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['./src/**/*.{js,ts,jsx,tsx,mdx}'],
darkMode: 'class',
darkMode: 'radix',
theme: {
extend: {},
},
Expand Down
Loading

1 comment on commit a498926

@vercel
Copy link

@vercel vercel bot commented on a498926 Jul 27, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.