tailwind-variants 3.2.1 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,35 @@
1
+ import { CnOptions, CnReturn, TV } from './types.cjs';
2
+ export { ClassProp, OmitUndefined, StringToBoolean, TVCompoundSlots, TVCompoundVariants, TVDefaultVariants, TVLite, TVProps, TVReturnProps, TVReturnType, TVReturnTypeLike, TVScreenPropsValue, TVVariantKeys, TVVariants, VariantProps, WithInitialScreen, isTrueOrArray } from './types.cjs';
3
+ import { T as TWMConfig, a as TVConfig } from './config-bO3A8WhU.cjs';
4
+ export { C as ClassValue, b as TWMergeConfig } from './config-bO3A8WhU.cjs';
5
+
6
+ /**
7
+ * Combines class names and merges conflicting Tailwind classes (default config).
8
+ */
9
+ declare const cn: <T extends CnOptions>(...classnames: T) => CnReturn;
10
+ /**
11
+ * Combines class names and merges conflicting Tailwind classes.
12
+ * Pass optional `twMerge` / `twMergeConfig` on the second call.
13
+ */
14
+ declare const cnMerge: <T extends CnOptions>(...classnames: T) => ((config?: TWMConfig) => CnReturn);
15
+
16
+ /**
17
+ * Creates a variant-aware component function with Tailwind CSS classes.
18
+ * Supports variants, slots, compound variants, and component composition.
19
+ * @see https://www.tailwind-variants.org/docs/getting-started
20
+ */
21
+ declare const tv: TV;
22
+ /**
23
+ * Creates a configured `tv` instance with custom default configuration.
24
+ */
25
+ declare const createTV: (config: TVConfig) => TV;
26
+ /**
27
+ * Default configuration object for tailwind-variants.
28
+ */
29
+ declare const defaultConfig: TVConfig;
30
+ /**
31
+ * Combines class names without merging conflicting Tailwind CSS classes.
32
+ */
33
+ declare const cx: <T extends CnOptions>(...classnames: T) => CnReturn;
34
+
35
+ export { CnOptions, CnReturn, TV, TVConfig, TWMConfig, cn, cnMerge, createTV, cx, defaultConfig, tv };
package/dist/index.d.ts CHANGED
@@ -1,133 +1,35 @@
1
- import type {TVConfig, TWMConfig, TWMergeConfig} from "./config.d.ts";
2
- import type {CnOptions, CnReturn, TV} from "./types.d.ts";
3
-
4
- export type * from "./types.d.ts";
1
+ import { CnOptions, CnReturn, TV } from './types.js';
2
+ export { ClassProp, OmitUndefined, StringToBoolean, TVCompoundSlots, TVCompoundVariants, TVDefaultVariants, TVLite, TVProps, TVReturnProps, TVReturnType, TVReturnTypeLike, TVScreenPropsValue, TVVariantKeys, TVVariants, VariantProps, WithInitialScreen, isTrueOrArray } from './types.js';
3
+ import { T as TWMConfig, a as TVConfig } from './config-bO3A8WhU.js';
4
+ export { C as ClassValue, b as TWMergeConfig } from './config-bO3A8WhU.js';
5
5
 
6
6
  /**
7
- * Combines class names into a single string. Similar to `clsx` - simple concatenation without merging conflicting classes.
8
- * @param classes - Class names to combine. Accepts strings, numbers, arrays, objects, and nested structures.
9
- * @returns A space-separated string of class names, or `undefined` if no valid classes are provided
10
- * @example
11
- * ```ts
12
- * // Simple concatenation
13
- * cx('text-xl', 'font-bold') // => 'text-xl font-bold'
14
- *
15
- * // Handles arrays and objects
16
- * cx(['px-4', 'py-2'], { 'bg-blue-500': true, 'text-white': false }) // => 'px-4 py-2 bg-blue-500'
17
- *
18
- * // Ignores falsy values (except 0)
19
- * cx('text-xl', false && 'font-bold', null, undefined) // => 'text-xl'
20
- * ```
7
+ * Combines class names and merges conflicting Tailwind classes (default config).
21
8
  */
22
- export declare const cx: <T extends CnOptions>(...classes: T) => CnReturn;
23
-
24
- /**
25
- * Type representing a callable function that can also be coerced to a string.
26
- * This allows `cn` to work both as a function and directly in template literals.
27
- */
28
- type CnCallable = ((config?: TWMConfig) => CnReturn) & {
29
- toString(): string;
30
- valueOf(): CnReturn;
31
- [Symbol.toPrimitive](hint: "string" | "number" | "default"): string | CnReturn;
32
- } & string;
33
-
9
+ declare const cn: <T extends CnOptions>(...classnames: T) => CnReturn;
34
10
  /**
35
- * Combines class names and merges conflicting Tailwind CSS classes using `tailwind-merge`.
36
- * @param classes - Class names to combine (strings, arrays, objects, etc.)
37
- * @returns A callable function that returns the merged class string. Works directly in template literals (coerces to string) or can be called with optional config.
38
- * @example
39
- * ```ts
40
- * // twMerge defaults to true - works directly in template literals
41
- * `${cn('bg-red-500', 'bg-blue-500')}` // => 'bg-blue-500'
42
- * String(cn('bg-red-500', 'bg-blue-500')) // => 'bg-blue-500'
43
- *
44
- * // Can still be called with config for explicit control
45
- * cn('bg-red-500', 'bg-blue-500')() // => 'bg-blue-500'
46
- *
47
- * // Note: If you need simple concatenation without merging, use `cx` instead:
48
- * // Instead of: cn('bg-red-500', 'bg-blue-500')({ twMerge: false })
49
- * // Use: cx('bg-red-500', 'bg-blue-500') // => 'bg-red-500 bg-blue-500'
50
- * ```
11
+ * Combines class names and merges conflicting Tailwind classes.
12
+ * Pass optional `twMerge` / `twMergeConfig` on the second call.
51
13
  */
52
- export declare const cn: <T extends CnOptions>(...classes: T) => CnCallable;
14
+ declare const cnMerge: <T extends CnOptions>(...classnames: T) => ((config?: TWMConfig) => CnReturn);
53
15
 
54
16
  /**
55
17
  * Creates a variant-aware component function with Tailwind CSS classes.
56
18
  * Supports variants, slots, compound variants, and component composition.
57
- * @example
58
- * ```ts
59
- * const button = tv({
60
- * base: "font-medium rounded-full",
61
- * variants: {
62
- * color: {
63
- * primary: "bg-blue-500 text-white",
64
- * secondary: "bg-purple-500 text-white",
65
- * },
66
- * size: {
67
- * sm: "text-sm px-3 py-1",
68
- * md: "text-base px-4 py-2",
69
- * },
70
- * },
71
- * defaultVariants: {
72
- * color: "primary",
73
- * size: "md",
74
- * },
75
- * });
76
- *
77
- * button({ color: "secondary", size: "sm" }) // => 'font-medium rounded-full bg-purple-500 text-white text-sm px-3 py-1'
78
- * ```
79
19
  * @see https://www.tailwind-variants.org/docs/getting-started
80
20
  */
81
- export declare const tv: TV;
82
-
21
+ declare const tv: TV;
83
22
  /**
84
23
  * Creates a configured `tv` instance with custom default configuration.
85
- * Useful when you want to set default `twMerge` or `twMergeConfig` options for all components.
86
- * @param config - Configuration object with default settings for `twMerge` and `twMergeConfig`
87
- * @returns A configured `tv` function that uses the provided defaults
88
- * @example
89
- * ```ts
90
- * // Create a tv instance with twMerge disabled by default
91
- * const tv = createTV({ twMerge: false });
92
- *
93
- * const button = tv({
94
- * base: "px-4 py-2",
95
- * variants: {
96
- * color: {
97
- * primary: "bg-blue-500",
98
- * },
99
- * },
100
- * });
101
- *
102
- * // Can still override config per component
103
- * const buttonWithMerge = tv(
104
- * {
105
- * base: "px-4 py-2",
106
- * variants: { color: { primary: "bg-blue-500" } },
107
- * },
108
- * { twMerge: true }
109
- * );
110
- * ```
111
24
  */
112
- export declare function createTV(config: TVConfig): TV;
113
-
25
+ declare const createTV: (config: TVConfig) => TV;
114
26
  /**
115
27
  * Default configuration object for tailwind-variants.
116
- * Can be modified to set global defaults for all components.
117
- * @example
118
- * ```ts
119
- * import { defaultConfig } from "tailwind-variants";
120
- *
121
- * defaultConfig.twMergeConfig = {
122
- * extend: {
123
- * theme: {
124
- * spacing: ["medium", "large"],
125
- * },
126
- * },
127
- * };
128
- * ```
129
28
  */
130
- export declare const defaultConfig: TVConfig;
29
+ declare const defaultConfig: TVConfig;
30
+ /**
31
+ * Combines class names without merging conflicting Tailwind CSS classes.
32
+ */
33
+ declare const cx: <T extends CnOptions>(...classnames: T) => CnReturn;
131
34
 
132
- // types
133
- export type {TVConfig, TWMConfig, TWMergeConfig};
35
+ export { CnOptions, CnReturn, TV, TVConfig, TWMConfig, cn, cnMerge, createTV, cx, defaultConfig, tv };