Home

Awesome

base16-tailwind

Easily use base16 color schemes with Tailwind CSS.

Features

Installation

npx jsr add @donovanglover/base16-tailwind

See the jsr page for other package managers.

Usage

See Base16Options for the list of available options.

tailwind.config.ts:

import { base16Tailwind } from 'base16-tailwind'
import type { Config } from 'tailwindcss/types/config'

const tailwindConfig: Partial<Config> = {
  plugins: [
    base16Tailwind
  ]
}

export default tailwindConfig

app/layout.tsx:

import '@/app/globals.css'

export interface RootLayoutProps {
  children: React.ReactNode
}

export default function RootLayout ({ children }: RootLayoutProps): React.ReactElement {
  return (
    <html lang='en-US' className='base16-emil dark:base16-monokai'>
      <body className='text-100 bg-800'>
        {children}
      </body>
    </html>
  )
}

components/ChangeThemeButton.tsx:

'use client'

const themes = [
  'base16-danqing',
  'base16-tarot',
  'base16-embers'
]

function changeTheme (): void {
  document.documentElement.className = themes[Math.floor(Math.random() * themes.length)]
}

export default function ChangeThemeButton (): React.ReactElement {
  return (
    <button onClick={changeTheme}>Change Theme</button>
  )
}

Contributing

Run npm ci to do a clean install and use the lint and test scripts to check your work.