tailwind-to-style 2.12.3 → 2.12.5

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.
package/README.md CHANGED
@@ -15,7 +15,28 @@ The library exposes two main functions and a CLI tool:
15
15
  2. **`twsx`**: A more advanced function that allows you to define nested and complex styles similar to SCSS, including support for responsive design, state variants, grouping, and enhanced CSS capabilities.
16
16
  3. **`twsx-cli`**: A command-line tool for generating CSS files from `twsx.*.js` files with watch mode support.
17
17
 
18
- ## ✨ What's New in v2.12.0
18
+ ## ✨ What's New in v2.12.4
19
+
20
+ - **🏷️ Custom Classname Prefix**: Full control over styled component classnames
21
+ - **Configurable Prefix**: Change from `twsx-` to any prefix (e.g., `myapp-`)
22
+ - **Custom Separator**: Use `-`, `_`, `__` or any separator
23
+ - **Flexible Hash Length**: Adjust uniqueness vs size (4-8 characters)
24
+ - **Component Name Toggle**: Include/exclude component type in classname
25
+ - **Per-Component Override**: Different naming for specific components
26
+ - **Design System Ready**: Perfect for branded design systems
27
+
28
+ **Example:**
29
+ ```javascript
30
+ // Global config
31
+ configure({ styled: { prefix: 'myapp', separator: '_' }})
32
+
33
+ const Button = styled('button', { base: 'px-4 py-2' })
34
+ // Generates: myapp_button_a3k9x (instead of twsx-button-a3k9x2)
35
+ ```
36
+
37
+ **[📖 See Custom Prefix Guide →](#custom-classname-prefix-configuration)** | **[💻 Examples →](examples/custom-prefix.js)**
38
+
39
+ ### Previous Updates (v2.12.0)
19
40
 
20
41
  - **🚀 Complete Optimization Suite**: Production-ready performance tools
21
42
  - **Bundle Analysis**: Analyze size, get recommendations, export reports
@@ -764,6 +785,124 @@ document.querySelector('.my-button').className = className
764
785
  </template>
765
786
  ```
766
787
 
788
+ ### Custom Classname Prefix Configuration
789
+
790
+ **New in v2.12.4** - Customize how styled components generate classnames with configurable prefix, separator, and naming options.
791
+
792
+ #### Global Configuration
793
+
794
+ Set global defaults for all styled components:
795
+
796
+ ```javascript
797
+ import { configure } from 'tailwind-to-style'
798
+
799
+ configure({
800
+ styled: {
801
+ prefix: 'myapp', // Default: 'twsx'
802
+ separator: '_', // Default: '-'
803
+ hashLength: 5, // Default: 6
804
+ includeComponentName: true // Default: true
805
+ }
806
+ })
807
+
808
+ const Button = styled('button', {
809
+ base: 'px-4 py-2 rounded-lg'
810
+ })
811
+ // Generates: myapp_button_a3k9x (instead of twsx-button-a3k9x2)
812
+ // Variants: myapp_color_primary (instead of twsx-color-primary)
813
+ ```
814
+
815
+ #### Per-Component Override
816
+
817
+ Override naming for specific components:
818
+
819
+ ```javascript
820
+ const CustomButton = styled('button',
821
+ {
822
+ base: 'px-4 py-2 rounded-lg',
823
+ variants: {
824
+ variant: {
825
+ solid: 'bg-blue-500',
826
+ outline: 'border border-blue-500'
827
+ }
828
+ }
829
+ },
830
+ {
831
+ // Component-specific naming options
832
+ prefix: 'btn',
833
+ separator: '-',
834
+ hashLength: 8,
835
+ includeComponentName: false
836
+ }
837
+ )
838
+ // Generates: btn-a3k9x2f1 (no component type)
839
+ // Variants: btn-variant-solid
840
+ ```
841
+
842
+ #### Use Cases
843
+
844
+ **1. Brand-specific Prefix:**
845
+ ```javascript
846
+ configure({ styled: { prefix: 'shopify' }})
847
+ // shopify-button-a3k9x2
848
+ ```
849
+
850
+ **2. Minimal Classnames:**
851
+ ```javascript
852
+ configure({
853
+ styled: {
854
+ prefix: 'c',
855
+ separator: '',
856
+ hashLength: 4,
857
+ includeComponentName: false
858
+ }
859
+ })
860
+ // c1a2b (super compact!)
861
+ ```
862
+
863
+ **3. Monorepo Isolation:**
864
+ ```javascript
865
+ // Admin app
866
+ configure({ styled: { prefix: 'admin' }})
867
+ // admin-button-xxx
868
+
869
+ // Customer portal
870
+ configure({ styled: { prefix: 'portal' }})
871
+ // portal-button-yyy
872
+ ```
873
+
874
+ **4. BEM-like Convention:**
875
+ ```javascript
876
+ configure({ styled: { separator: '__' }})
877
+ // twsx__button__a3k9x2
878
+ ```
879
+
880
+ **5. Design System:**
881
+ ```javascript
882
+ configure({ styled: { prefix: 'ds' }})
883
+ const Button = styled('button', config)
884
+ const Card = styled('div', config)
885
+ // ds-button-a3k9x2, ds-card-f8d2k1
886
+ ```
887
+
888
+ #### HTML Output Examples
889
+
890
+ ```html
891
+ <!-- Default (prefix: 'twsx', separator: '-') -->
892
+ <button class="twsx-button-a3k9x2 twsx-color-primary">Click</button>
893
+
894
+ <!-- Custom (prefix: 'myapp', separator: '_') -->
895
+ <button class="myapp_button_a3k9 myapp_color_primary">Click</button>
896
+
897
+ <!-- Minimal (prefix: 'c', no component name) -->
898
+ <button class="c-1a2b c-color-primary">Click</button>
899
+
900
+ <!-- BEM-like (separator: '__') -->
901
+ <button class="twsx__button__a3k9x2 twsx__color__primary">Click</button>
902
+ ```
903
+
904
+ **[📖 Full Example →](examples/custom-prefix.js)**
905
+
767
906
  ### Batch Variant Creation
768
907
 
769
908
  Create multiple variant functions at once:
@@ -1265,6 +1404,13 @@ export default {
1265
1404
  },
1266
1405
  },
1267
1406
  },
1407
+ // Styled components configuration
1408
+ styled: {
1409
+ prefix: 'myapp', // Customize classname prefix
1410
+ separator: '-', // Customize separator
1411
+ hashLength: 6, // Hash length (4-8 recommended)
1412
+ includeComponentName: true // Include component type in classname
1413
+ }
1268
1414
  };
1269
1415
  ```
1270
1416
 
@@ -1277,6 +1423,65 @@ import config from "./tailwind-to-style.config.js";
1277
1423
  configure(config);
1278
1424
  ```
1279
1425
 
1426
+ ### Configuration Options
1427
+
1428
+ ```javascript
1429
+ configure({
1430
+ // Theme customization
1431
+ theme: {
1432
+ extend: {
1433
+ colors: { /* custom colors */ },
1434
+ spacing: { /* custom spacing */ },
1435
+ borderRadius: { /* custom border radius */ },
1436
+ fontSize: { /* custom font sizes */ },
1437
+ // ... any Tailwind theme property
1438
+ },
1439
+ },
1440
+
1441
+ // Optional: Add prefix to utility classes
1442
+ prefix: 'tw-',
1443
+
1444
+ // Optional: Disable specific core plugins
1445
+ corePlugins: {
1446
+ float: false,
1447
+ clear: false,
1448
+ },
1449
+
1450
+ // NEW: Styled components naming configuration
1451
+ styled: {
1452
+ prefix: 'twsx', // Global prefix (default: 'twsx')
1453
+ separator: '-', // Separator between parts (default: '-')
1454
+ hashLength: 6, // Hash length 4-8 (default: 6)
1455
+ includeComponentName: true // Include component type (default: true)
1456
+ }
1457
+ });
1458
+ ```
1459
+
1460
+ **Examples:**
1461
+
1462
+ ```javascript
1463
+ // Brand-specific prefix
1464
+ configure({ styled: { prefix: 'myapp' }})
1465
+ // Generated: myapp-button-a3k9x2
1466
+
1467
+ // Minimal classnames
1468
+ configure({
1469
+ styled: {
1470
+ prefix: 'c',
1471
+ separator: '',
1472
+ hashLength: 4,
1473
+ includeComponentName: false
1474
+ }
1475
+ })
1476
+ // Generated: c1a2b
1477
+
1478
+ // BEM-like style
1479
+ configure({ styled: { separator: '__' }})
1480
+ // Generated: twsx__button__a3k9x2
1481
+ ```
1482
+
1483
+ See [Custom Classname Prefix Configuration](#custom-classname-prefix-configuration) for more details.
1484
+
1280
1485
  ## Custom Plugins (v2.10.0+)
1281
1486
 
1282
1487
  Create custom utility classes with the plugin API:
@@ -1,5 +1,5 @@
1
1
  /**
2
- * tailwind-to-style v2.12.3
2
+ * tailwind-to-style v2.12.5
3
3
  * Convert tailwind classes to inline style
4
4
  *
5
5
  * @author Bigetion
@@ -1933,7 +1933,16 @@ let userConfig = {
1933
1933
  },
1934
1934
  plugins: [],
1935
1935
  corePlugins: {},
1936
- prefix: ""
1936
+ prefix: "",
1937
+ styled: {
1938
+ prefix: "twsx",
1939
+ // Global prefix for styled components
1940
+ separator: "-",
1941
+ // Separator between prefix and component
1942
+ hashLength: 6,
1943
+ // Length of generated hash
1944
+ includeComponentName: true // Include component type in classname
1945
+ }
1937
1946
  };
1938
1947
 
1939
1948
  // Cache for extended theme to avoid redundant lookups
@@ -9488,16 +9497,18 @@ function useUpdateTwsxConfig() {
9488
9497
  /**
9489
9498
  * Simple hash function for deterministic class names
9490
9499
  * @param {string} str - String to hash
9500
+ * @param {number} length - Length of hash (default: 6)
9491
9501
  * @returns {string} Hash string
9492
9502
  */
9493
9503
  function simpleHash(str) {
9504
+ let length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
9494
9505
  let hash = 0;
9495
9506
  for (let i = 0; i < str.length; i++) {
9496
9507
  const char = str.charCodeAt(i);
9497
9508
  hash = (hash << 5) - hash + char;
9498
9509
  hash = hash & hash; // Convert to 32bit integer
9499
9510
  }
9500
- return Math.abs(hash).toString(36).substr(0, 6);
9511
+ return Math.abs(hash).toString(36).substr(0, length);
9501
9512
  }
9502
9513
 
9503
9514
  /**
@@ -9505,21 +9516,56 @@ function simpleHash(str) {
9505
9516
  * @param {Object|Function} config - Style configuration
9506
9517
  * @param {string} componentType - Component type (e.g., 'button', 'div')
9507
9518
  * @param {string} instanceId - Unique instance identifier (optional)
9519
+ * @param {Object} options - Naming options (prefix, separator, etc)
9508
9520
  * @returns {string} Deterministic class name
9509
9521
  */
9510
9522
  function generateClassName(config) {
9511
9523
  let componentType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "component";
9512
9524
  let instanceId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
9525
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
9526
+ // Get global config
9527
+ const globalConfig = getConfig();
9528
+ const styledConfig = globalConfig.styled || {};
9529
+
9530
+ // Merge options with global config (options override global)
9531
+ const {
9532
+ prefix = styledConfig.prefix || "twsx",
9533
+ separator = styledConfig.separator || "-",
9534
+ hashLength = styledConfig.hashLength || 6,
9535
+ includeComponentName = styledConfig.includeComponentName !== false
9536
+ } = options;
9537
+
9513
9538
  // If config is a function (from tv()), use its string representation
9514
9539
  const configStr = typeof config === "function" ? config.toString() : JSON.stringify(config);
9515
9540
 
9516
9541
  // Include instanceId in hash to ensure uniqueness per component
9517
9542
  const hashInput = configStr + componentType + (instanceId || "");
9518
- const hash = simpleHash(hashInput);
9543
+ const hash = simpleHash(hashInput, hashLength);
9519
9544
 
9520
- // Generate unique class name with instance ID if provided
9521
- const suffix = instanceId ? `-${instanceId}` : "";
9522
- return `twsx-${componentType}-${hash}${suffix}`;
9545
+ // Build class name parts
9546
+ const parts = [prefix];
9547
+ if (includeComponentName) {
9548
+ parts.push(componentType);
9549
+ }
9550
+ parts.push(hash);
9551
+ if (instanceId) {
9552
+ parts.push(instanceId);
9553
+ }
9554
+ return parts.join(separator);
9555
+ }
9556
+
9557
+ /**
9558
+ * Get variant prefix from config or options
9559
+ * @param {Object} namingOptions - Naming options
9560
+ * @returns {string} Variant prefix
9561
+ */
9562
+ function getVariantPrefix() {
9563
+ let namingOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
9564
+ const globalConfig = getConfig();
9565
+ const styledConfig = globalConfig.styled || {};
9566
+ const prefix = namingOptions.prefix || styledConfig.prefix || "twsx";
9567
+ const separator = namingOptions.separator || styledConfig.separator || "-";
9568
+ return `${prefix}${separator}`;
9523
9569
  }
9524
9570
 
9525
9571
  /**
@@ -9529,6 +9575,11 @@ function generateClassName(config) {
9529
9575
  * @param {Object} options - Additional options
9530
9576
  * @param {string} options.scope - Component scope for isolation (optional)
9531
9577
  * @param {boolean} options.isolate - Whether to isolate from other components (default: false)
9578
+ * @param {string} options.prefix - Custom prefix for classnames (default: from global config)
9579
+ * @param {string} options.separator - Custom separator (default: from global config)
9580
+ * @param {number} options.hashLength - Custom hash length (default: from global config)
9581
+ * @param {boolean} options.includeComponentName - Include component name in classname (default: from global config)
9582
+ * @param {string} options.displayName - Custom display name for component (optional)
9532
9583
  * @returns {React.Component} Styled component
9533
9584
  */
9534
9585
  function styled(component) {
@@ -9536,9 +9587,30 @@ function styled(component) {
9536
9587
  let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
9537
9588
  const {
9538
9589
  scope = null,
9539
- isolate = false
9590
+ isolate = false,
9591
+ prefix,
9592
+ separator,
9593
+ hashLength,
9594
+ includeComponentName,
9595
+ displayName
9540
9596
  } = options;
9541
9597
 
9598
+ // Extract naming options
9599
+ const namingOptions = {
9600
+ ...(prefix !== undefined && {
9601
+ prefix
9602
+ }),
9603
+ ...(separator !== undefined && {
9604
+ separator
9605
+ }),
9606
+ ...(hashLength !== undefined && {
9607
+ hashLength
9608
+ }),
9609
+ ...(includeComponentName !== undefined && {
9610
+ includeComponentName
9611
+ })
9612
+ };
9613
+
9542
9614
  // Generate unique instance ID for isolation - FIXED: Always use scope when provided
9543
9615
  const instanceId = scope || (isolate ? `${Date.now()}-${Math.random().toString(36).substr(2, 9)}` : null);
9544
9616
 
@@ -9548,7 +9620,7 @@ function styled(component) {
9548
9620
 
9549
9621
  // Generate deterministic class name based on component and config
9550
9622
  const componentType = typeof component === "string" ? component : "component";
9551
- const componentId = generateClassName(config, componentType, instanceId);
9623
+ const componentId = generateClassName(config, componentType, instanceId, namingOptions);
9552
9624
  const baseClassName = `.${componentId}`;
9553
9625
 
9554
9626
  // Create styled component
@@ -9581,12 +9653,16 @@ function styled(component) {
9581
9653
  ...variantProps
9582
9654
  };
9583
9655
 
9584
- // Generate variant class names with twsx- prefix
9656
+ // Generate variant class names with configurable prefix
9657
+ const globalConfig = getConfig();
9658
+ const styledConfig = globalConfig.styled || {};
9659
+ const variantPrefix = getVariantPrefix(namingOptions);
9660
+ const sep = namingOptions.separator || styledConfig.separator || "-";
9585
9661
  const variantClassNames = [];
9586
9662
  Object.entries(finalVariantProps).forEach(_ref => {
9587
9663
  let [key, value] = _ref;
9588
9664
  if (value) {
9589
- variantClassNames.push(`twsx-${key}-${value}`);
9665
+ variantClassNames.push(`${variantPrefix}${key}${sep}${value}`);
9590
9666
  }
9591
9667
  });
9592
9668
 
@@ -9609,9 +9685,14 @@ function styled(component) {
9609
9685
  let [variantKey, variantValues] = _ref2;
9610
9686
  Object.entries(variantValues).forEach(_ref3 => {
9611
9687
  let [variantValue, variantClasses] = _ref3;
9612
- const variantSelector = `&.twsx-${variantKey}-${variantValue}`;
9613
- if (variantClasses && variantClasses.trim()) {
9614
- nestedVariants[variantSelector] = variantClasses;
9688
+ const variantPrefix = getVariantPrefix(namingOptions);
9689
+ const sep = namingOptions.separator || styledConfig.separator || "-";
9690
+ const variantSelector = `&.${variantPrefix}${variantKey}${sep}${variantValue}`;
9691
+
9692
+ // Handle both string and array of classes
9693
+ const normalizedClasses = Array.isArray(variantClasses) ? variantClasses.join(" ") : variantClasses;
9694
+ if (normalizedClasses && normalizedClasses.trim()) {
9695
+ nestedVariants[variantSelector] = normalizedClasses;
9615
9696
  }
9616
9697
  });
9617
9698
  });
@@ -9624,21 +9705,29 @@ function styled(component) {
9624
9705
  } = compound;
9625
9706
 
9626
9707
  // Build selector with all condition classes
9708
+ const variantPrefix = getVariantPrefix(namingOptions);
9709
+ const sep = namingOptions.separator || styledConfig.separator || "-";
9627
9710
  const conditionClasses = Object.entries(conditions).map(_ref4 => {
9628
9711
  let [key, value] = _ref4;
9629
- return `twsx-${key}-${value}`;
9712
+ return `${variantPrefix}${key}${sep}${value}`;
9630
9713
  }).join(".");
9631
9714
  const compoundSelector = `&.${conditionClasses}`;
9632
- if (compoundClass && compoundClass.trim()) {
9633
- nestedVariants[compoundSelector] = compoundClass;
9715
+
9716
+ // Handle both string and array of classes
9717
+ const normalizedClass = Array.isArray(compoundClass) ? compoundClass.join(" ") : compoundClass;
9718
+ if (normalizedClass && normalizedClass.trim()) {
9719
+ nestedVariants[compoundSelector] = normalizedClass;
9634
9720
  }
9635
9721
  });
9636
9722
 
9637
9723
  // 3. Build final structure: [base, { nested variants }]
9638
9724
  // This matches the twsx() format exactly
9639
9725
  const styleArray = [];
9640
- if (base.trim()) {
9641
- styleArray.push(base);
9726
+
9727
+ // Handle both string and array of classes for base
9728
+ const normalizedBase = Array.isArray(base) ? base.join(" ") : base;
9729
+ if (normalizedBase && normalizedBase.trim()) {
9730
+ styleArray.push(normalizedBase);
9642
9731
  }
9643
9732
  if (Object.keys(nestedVariants).length > 0) {
9644
9733
  styleArray.push(nestedVariants);
@@ -9663,7 +9752,7 @@ function styled(component) {
9663
9752
  ...componentProps
9664
9753
  }, children);
9665
9754
  });
9666
- StyledComponent.displayName = `Styled(${typeof component === "string" ? component : component.displayName || component.name || "Component"})`;
9755
+ StyledComponent.displayName = displayName || `Styled(${typeof component === "string" ? component : component.displayName || component.name || "Component"})`;
9667
9756
  return StyledComponent;
9668
9757
  }
9669
9758
 
@@ -9682,7 +9771,7 @@ function styled(component) {
9682
9771
 
9683
9772
  // Generate deterministic class name based on component and config
9684
9773
  const componentType = typeof component === "string" ? component : "component";
9685
- const componentId = generateClassName(config, componentType, instanceId);
9774
+ const componentId = generateClassName(config, componentType, instanceId, namingOptions);
9686
9775
  const className = `.${componentId}`;
9687
9776
 
9688
9777
  // Create styled component
@@ -9711,18 +9800,24 @@ function styled(component) {
9711
9800
  ...variantProps
9712
9801
  };
9713
9802
 
9714
- // Generate variant class names with twsx- prefix
9803
+ // Generate variant class names with configurable prefix
9804
+ const globalConfig = getConfig();
9805
+ const styledConfig = globalConfig.styled || {};
9806
+ const variantPrefix = getVariantPrefix(namingOptions);
9807
+ const sep = namingOptions.separator || styledConfig.separator || "-";
9715
9808
  const variantClassNames = [];
9716
9809
  Object.entries(appliedVariantProps).forEach(_ref5 => {
9717
9810
  let [key, value] = _ref5;
9718
9811
  if (value) {
9719
- variantClassNames.push(`twsx-${key}-${value}`);
9812
+ variantClassNames.push(`${variantPrefix}${key}${sep}${value}`);
9720
9813
  }
9721
9814
  });
9722
9815
 
9723
9816
  // Build twsx styles object with nested structure
9724
9817
  const styles = useMemo(() => {
9725
9818
  const styleObj = {};
9819
+ const globalConfig = getConfig();
9820
+ const styledConfig = globalConfig.styled || {};
9726
9821
 
9727
9822
  // Build nested variants structure
9728
9823
  const nestedVariants = {};
@@ -9732,9 +9827,14 @@ function styled(component) {
9732
9827
  let [variantKey, variantValues] = _ref6;
9733
9828
  Object.entries(variantValues).forEach(_ref7 => {
9734
9829
  let [variantValue, variantClasses] = _ref7;
9735
- const variantSelector = `&.twsx-${variantKey}-${variantValue}`;
9736
- if (variantClasses && variantClasses.trim()) {
9737
- nestedVariants[variantSelector] = variantClasses;
9830
+ const variantPrefix = getVariantPrefix(namingOptions);
9831
+ const sep = namingOptions.separator || styledConfig.separator || "-";
9832
+ const variantSelector = `&.${variantPrefix}${variantKey}${sep}${variantValue}`;
9833
+
9834
+ // Handle both string and array of classes
9835
+ const normalizedClasses = Array.isArray(variantClasses) ? variantClasses.join(" ") : variantClasses;
9836
+ if (normalizedClasses && normalizedClasses.trim()) {
9837
+ nestedVariants[variantSelector] = normalizedClasses;
9738
9838
  }
9739
9839
  });
9740
9840
  });
@@ -9742,19 +9842,21 @@ function styled(component) {
9742
9842
  // Generate compound variant selectors
9743
9843
  compoundVariants.forEach(compound => {
9744
9844
  const {
9745
- className: compoundClass,
9845
+ class: compoundClass,
9746
9846
  ...conditions
9747
9847
  } = compound;
9748
9848
 
9749
9849
  // Build selector with :not() for false values
9750
9850
  const positiveConditions = [];
9751
9851
  const negativeConditions = [];
9852
+ const variantPrefix = getVariantPrefix(namingOptions);
9853
+ const sep = namingOptions.separator || styledConfig.separator || "-";
9752
9854
  Object.entries(conditions).forEach(_ref8 => {
9753
9855
  let [key, value] = _ref8;
9754
9856
  if (value === false) {
9755
- negativeConditions.push(`twsx-${key}-true`);
9857
+ negativeConditions.push(`${variantPrefix}${key}${sep}true`);
9756
9858
  } else {
9757
- positiveConditions.push(`twsx-${key}-${value}`);
9859
+ positiveConditions.push(`${variantPrefix}${key}${sep}${value}`);
9758
9860
  }
9759
9861
  });
9760
9862
 
@@ -9768,15 +9870,21 @@ function styled(component) {
9768
9870
  compoundSelector += `:not(.${negClass})`;
9769
9871
  });
9770
9872
  }
9771
- if (compoundClass && compoundClass.trim()) {
9772
- nestedVariants[compoundSelector] = compoundClass;
9873
+
9874
+ // Handle both string and array of classes
9875
+ const normalizedClass = Array.isArray(compoundClass) ? compoundClass.join(" ") : compoundClass;
9876
+ if (normalizedClass && normalizedClass.trim()) {
9877
+ nestedVariants[compoundSelector] = normalizedClass;
9773
9878
  }
9774
9879
  });
9775
9880
 
9776
9881
  // Build final nested structure: [base, { nested variants }]
9777
9882
  const styleArray = [];
9778
- if (base.trim()) {
9779
- styleArray.push(base);
9883
+
9884
+ // Handle both string and array of classes for base
9885
+ const normalizedBase = Array.isArray(base) ? base.join(" ") : base;
9886
+ if (normalizedBase && normalizedBase.trim()) {
9887
+ styleArray.push(normalizedBase);
9780
9888
  }
9781
9889
 
9782
9890
  // Add pseudo-state classes to nested
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * tailwind-to-style v2.12.3
2
+ * tailwind-to-style v2.12.5
3
3
  * Convert tailwind classes to inline style
4
4
  *
5
5
  * @author Bigetion
@@ -1845,7 +1845,16 @@ let userConfig = {
1845
1845
  },
1846
1846
  plugins: [],
1847
1847
  corePlugins: {},
1848
- prefix: ""
1848
+ prefix: "",
1849
+ styled: {
1850
+ prefix: "twsx",
1851
+ // Global prefix for styled components
1852
+ separator: "-",
1853
+ // Separator between prefix and component
1854
+ hashLength: 6,
1855
+ // Length of generated hash
1856
+ includeComponentName: true // Include component type in classname
1857
+ }
1849
1858
  };
1850
1859
 
1851
1860
  // Cache for extended theme to avoid redundant lookups
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * tailwind-to-style v2.12.3
2
+ * tailwind-to-style v2.12.5
3
3
  * Convert tailwind classes to inline style
4
4
  *
5
5
  * @author Bigetion
@@ -1843,7 +1843,16 @@ let userConfig = {
1843
1843
  },
1844
1844
  plugins: [],
1845
1845
  corePlugins: {},
1846
- prefix: ""
1846
+ prefix: "",
1847
+ styled: {
1848
+ prefix: "twsx",
1849
+ // Global prefix for styled components
1850
+ separator: "-",
1851
+ // Separator between prefix and component
1852
+ hashLength: 6,
1853
+ // Length of generated hash
1854
+ includeComponentName: true // Include component type in classname
1855
+ }
1847
1856
  };
1848
1857
 
1849
1858
  // Cache for extended theme to avoid redundant lookups