diff --git a/docs/content/1.getting-started/3.theming.md b/docs/content/1.getting-started/3.theming.md index 9fe689a095..8ff1be46f9 100644 --- a/docs/content/1.getting-started/3.theming.md +++ b/docs/content/1.getting-started/3.theming.md @@ -221,6 +221,52 @@ export default defineAppConfig({ }) ``` +### Extend Tailwind Merge + +Tailwind Merge is a library that allows you to efficiently merge Tailwind CSS classes. It is used by this module to merge the classes from the `ui` prop, the `class` attribute, and the default classes. + +::callout{icon="i-heroicons-light-bulb" to="https://github.com/dcastil/tailwind-merge" target="_blank"} +Learn more about Tailwind Merge. +:: + +By default, Tailwind Merge doesn't handle custom Tailwind CSS configuration like custom colors, spacing, or other utilities you may have defined. You'll need to extend it to handle your custom configuration. + +You can extend Tailwind Merge by using the `tailwindMerge` option in your `app.config.ts`: + +::code-group +```ts [app.config.ts] +export default defineAppConfig({ + ui: { + tailwindMerge: { + extend: { + theme: { + spacing: ['sm', 'md', 'lg', 'xl', '2xl'] + } + } + } + } +}) +``` + +```ts [tailwind.config.ts] +import type { Config } from 'tailwindcss' + +export default >{ + theme: { + extend: { + spacing: { + sm: '0.5rem', + md: '1rem', + lg: '1.5rem', + xl: '2rem', + '2xl': '2.5rem' + } + } + } +} +``` +:: + ## Dark mode All the components are styled with dark mode in mind. diff --git a/src/module.ts b/src/module.ts index f5d36f5dac..928d0904ab 100644 --- a/src/module.ts +++ b/src/module.ts @@ -1,5 +1,6 @@ import { createRequire } from 'node:module' import { defineNuxtModule, installModule, addComponentsDir, addImportsDir, createResolver, addPlugin } from '@nuxt/kit' +import type { ConfigExtension, DefaultClassGroupIds, DefaultThemeGroupIds } from 'tailwind-merge' import { name, version } from '../package.json' import createTemplates from './templates' import type * as config from './runtime/ui.config' @@ -20,6 +21,7 @@ type UI = { gray?: string colors?: string[] strategy?: Strategy + tailwindMerge?: ConfigExtension [key: string]: any } & DeepPartial diff --git a/src/runtime/components/data/Table.vue b/src/runtime/components/data/Table.vue index 07d1e4eaca..57c9906fcf 100644 --- a/src/runtime/components/data/Table.vue +++ b/src/runtime/components/data/Table.vue @@ -144,7 +144,7 @@ import UButton from '../elements/Button.vue' import UProgress from '../elements/Progress.vue' import UCheckbox from '../forms/Checkbox.vue' import { useUI } from '../../composables/useUI' -import { mergeConfig, get } from '../../utils' +import { get, mergeConfig } from '../../utils' import type { TableRow, TableColumn, Strategy, Button, ProgressColor, ProgressAnimation, DeepPartial, Expanded } from '../../types/index' // @ts-expect-error import appConfig from '#build/app.config' diff --git a/src/runtime/components/elements/Alert.vue b/src/runtime/components/elements/Alert.vue index f3be56e414..4d03885570 100644 --- a/src/runtime/components/elements/Alert.vue +++ b/src/runtime/components/elements/Alert.vue @@ -42,13 +42,13 @@