I'm creating my first custom wordpress theme using
but this tailwind border class is only generated if I specify it in PHP file statically without using PHP, like this: border-x-[80px]
. It doesn't work with dynamic PHP value as shown above. How can I get PHP and tailwind to work together? I heard it has something to do with PostCSS?
CodePudding user response:
There is no issue with PHP. When working with dynamic classes Tailwind cannot read them on the fly as it is working with source files. So instead you may use style attribute for such dynamic values
<div style="--my-border: <?php echo $GLOBALS['border_width'] ?>px">
or any other styling way. If you have predefined list of border_width_setting_id
(like 40, 80, 120), you may safelist it