GitHub

@@ -6,7 +6,7 @@ import { addTemplate, addTypeTemplate, hasNuxtModule, logger, updateTemplates, g

66

import type { Nuxt, NuxtTemplate, NuxtTypeTemplate } from '@nuxt/schema'

77

import type { Resolver } from '@nuxt/kit'

88

import type { ModuleOptions } from './module'

9-

import { applyDefaultVariants, applyPrefixToObject } from './utils/theme'

9+

import { applyDefaultVariants, applyPrefixToObject, applyUnstyled } from './utils/theme'

1010

import { detectUsedComponents } from './utils/components'

1111

import * as theme from './theme'

1212

import * as themeProse from './theme/prose'

@@ -32,6 +32,8 @@ export function getTemplates(options: ModuleOptions, uiConfig: Record<string, an

32323333

// Override default variants from nuxt.config.ts

3434

result = applyDefaultVariants(result, options.theme?.defaultVariants)

35+

// Strip default theme classes if `unstyled` is enabled

36+

result = applyUnstyled(result, options.theme?.unstyled)

3537

// Apply Tailwind prefix if configured

3638

result = applyPrefixToObject(result, options.theme?.prefix)

3739

@@ -65,14 +67,16 @@ export function getTemplates(options: ModuleOptions, uiConfig: Record<string, an

6567

const themeUtilsPath = fileURLToPath(new URL('./utils/theme', import.meta.url))

6668

const defaultVariantsJson = JSON.stringify(options.theme?.defaultVariants) ?? 'undefined'

6769

const prefixJson = JSON.stringify(options.theme?.prefix) ?? 'undefined'

70+

const unstyledJson = JSON.stringify(options.theme?.unstyled) ?? 'undefined'

68716972

return [

7073

`import template from ${JSON.stringify(templatePath)}`,

71-

`import { applyDefaultVariants, applyPrefixToObject } from ${JSON.stringify(themeUtilsPath)}`,

74+

`import { applyDefaultVariants, applyPrefixToObject, applyUnstyled } from ${JSON.stringify(themeUtilsPath)}`,

7275

...generateVariantDeclarations(variants),

7376

`const options = ${JSON.stringify(options, null, 2)}`,

7477

`let result = typeof template === 'function' ? (template as Function)(options) : template`,

7578

`result = applyDefaultVariants(result, ${defaultVariantsJson})`,

79+

`result = applyUnstyled(result, ${unstyledJson})`,

7680

`result = applyPrefixToObject(result, ${prefixJson})`,

7781

`const theme = ${json}`,

7882

`export default result as typeof theme`

Read the original on github.com ↗