Default is 150ms, was looking to extend this to 250ms as an application default.
Tried everything I could think of, last attempt being
transitionDuration: {
DEFAULT: '250ms'
},
in tailwind.config.js under theme, theme.extend, variants, and variants.extend.
Any help would be appreciated!
theme: {
transitionDuration: {
DEFAULT: '250ms'
}
}
in your tailwind.config.js should work.
Demo: https://play.tailwindcss.com/zSWIMghZQf
(Default transition duration overwritten to 2000ms.)
For reference: With npx tailwindcss init --full you can create a configuration file that contains all tailwind default values.
Just like ptts answered before me, inserting an override in the theme section of your tailwind.config.js will do the trick.
What I'd like to add is that the new value for transitionDuration will completely replace Tailwind’s default configuration for that key, and the initial transition duration utilities will not be generated. So if you only define DEFAULT under the transitionDuration key, your classes like .duration-500 will not work.
The solution is to define the full set of duration values you might use. For your convenience, here's the full set from the default theme:
transitionDuration: {
DEFAULT: '150ms',
75: '75ms',
100: '100ms',
150: '150ms',
200: '200ms',
300: '300ms',
500: '500ms',
700: '700ms',
1000: '1000ms',
},
If you want to update the DEFAULT while still retaining all of the other durations, use something like:
transitionDuration: {
DEFAULT: '500ms',
75: '75ms',
100: '100ms',
150: '150ms',
200: '200ms',
300: '300ms',
500: '500ms',
700: '700ms',
1000: '1000ms',
},
Related
DaisyUI has default themes and you can change them with the data-theme attribute e.g. <html data-theme="cupcake">. It seems as though the default is the light theme.
The problem is that I want to be able to use the #apply directive with DaisyUI so that I can have BEM class names in the template and DaisyUI utility classes in the style block. It seems that I can't set a default that will be picked up at compile time.
In my tailwind.config I've tried using the light theme to see if I could overwrite it, e.g.:
plugins: [require('daisyui')],
daisyui: {
themes: [
{
light: {
primary: '#EF3054',
secondary: '#C67F43',
accent: '#43AA8B',
neutral: '#FBF5F3',
base100: '#FFFFFF',
info: '#3ABFF8',
success: '#36D399',
warning: '#FBBD23',
error: '#F87272',
},
},
],
}
But this doesn't work. I've tried looking into the library itself for clues into how I could overwrite the default theme at compile time but I can't see how.
Although some people consider BEM with Tailwind an anti-pattern, I had long held this view myself as well, I have since changed my mind and feel that the extra effort does help disambiguate your template with the added benefit of allowing bespoke CSS whenever you need to drop into it so please don't suggest just using the inline utility classes as I know this works.
I'm not sure what is your issue exactly.
But once you changed tailwind config, then it should work.
If you want to change your default theme with another one, it requires some code.
But now you changed your light theme, so it will directly work.
Please check your content property again. I'm working on Next JS.
And I think base100 property should be base-100.
module.exports = {
content: [
"./pages/**/*.{js,ts,jsx,tsx}",
"./components/**/*.{js,ts,jsx,tsx}",
],
...
daisyui: {
themes: [
{
light: {
...require("daisyui/src/colors/themes")["[data-theme=light]"],
primary: '#EF3054',
secondary: '#C67F43',
accent: '#43AA8B',
neutral: '#FBF5F3',
"base-100": '#FFFFFF',
info: '#3ABFF8',
success: '#36D399',
warning: '#FBBD23',
error: '#F87272',
},
},
],
}
...
Is it possible to make the color dynamic in tailwind config.
I want to received the desired color for (primary , accent) from backend via api.
So the user can change the color from the admin panel.
i want to get this hex value from api
Yes this is possible but instead of only primary, you need to return the complete string like bg-primary(as tailwind only recognises the string) where your primary color should be defined in tailwind.config.js file.
For an example you can refer to my answer for this question.
You can try fetching the CSS variables to change you color palette without changing tailwind.config.js
config file:
module.exports = {
theme: {
extend: {
colors: {
"primary": {
100:"var(--primary-color-100)",
200:"var(--primary-color-200)",
},
"accent": "var(--accent-color)"
},
},
},
};
css file:
:root {
--primary-color-100: #fff;
--primary-color-200: #fff00;
--accent-color: #000;
}
In an attempt to update PHP version, I came up with some funky node issues oddly enough instead. I'm having some weird Tailwind 3.0 compiling issues where not all the color shades are appearing. The defaultTheme colors are not compiling right. I have colors in the tailwind-config.js but not all shades are appearing like the 700 for blue. I noticed if I put the colors I want in the array (view gray in the example attached), it works. Do I have to add every color shade? This suddenly just started happening. It was fine before the PHP update. I'm trying to use text-blue-700 and it can't find it.
Example of the setup: https://play.tailwindcss.com/HSzmza7os3?file=config
Has anyone else had this issue before where the defaultTheme won't pull in all the theme color shades?
You don't have to use defaultTheme if you're trying to add variations to the existing theme. Instead, you can put your color additions in the extend section of the config object. For example, to keep the default Tailwind classes like text-gray-500 and add your new ones:
module.exports = {
plugins: [],
theme: {
extend: {
colors: {
gray: {
lightest: '#F7F7F7',
lighter: '#f1f1f1',
light: '#e1e1e1',
default: '#57677A',
dark: '#C2CAD3',
darker: '#656565',
darkest: '#808080',
},
},
},
},
}
If you only want to use the default colors (no additions), you should not have to add anything to the config.
Working version of your example: https://play.tailwindcss.com/rKi0lRmivh
Tailwind provides good option to get value from config inside another config object
module.exports = {
theme: {
colors: {
primary: 'red'
},
extend: {
colors: theme => ({
secondary: theme('colors.primary') // will be red
})
}
}
}
But this doesn't work when I want to create classes using RGBA. I want to create something like
module.exports = {
theme: {
colors: {
primary: 'red'
},
extend: {
boxShadow: theme => ({
extra: "0 0 999px rgba(theme('colors.primary'), .25))"
}),
}
}
}
This will render 0 0 999px rgba(red, .25) which is not correct CSS value - you need to pass red as 255, 0, 0. But I want to use colors.primary as it was defined in my config
I know Tailwind has it's own build utils for converting colors like asRgba, withAlphaVariable. For example, when you use text-white Tailwind renders it as color: rgba(255,255,255,var(--tw-text-opacity));. But how can I use it?
So basically how can I achieve this - pass color key from my config into another property and get rendered it as RGB/RGBA?
Update: I want third square (TW) to work as others
DEMO
I think your idea was wrong, because tailwind colors is defined with HEX number, but you trying to use it into RGBA type, so I think you need to convert firstly if you want to make your way.
Anyway let us know your success :)
check this doc
So I want to make a TailWindCSS Super Config in which I have every height fraction up-to 12, same for height screen and font size, and a lot of colours.
I know that TailWindCSS gives a pretty good default config, but I want it bigger, better.
FileSize is not an issue for the CSS and it is going to be Purged, after working with PurgeCSS for a little while, I feel confident that it will only include what is needed.
Having a large StyleSheet does mean that some developers may take it too far and start to overuse classes, however I personally feel that this will not be an issue within my company, and I would still like to have a large config.
I want to automatically generate the config so that I can have the 1/2, 2/3, 5/5 etc generated without me having to enter them manually into the config, along with this I want every variant for every attribute, making the end CSS even bigger!
In Short, I would like a way to generate some of the config automatically, and I want to know the correct order to declare the config (EG: height, width, box shadow etc).
Thanks, Justin.
Everything that you mentioned you can do it easily with the default config file that TailwindCSS gives you
This is the beauty of TailwindCSS, easy configuration, unlimited choices
Try https://tailwindcss.com/docs/configuration
Example:
// tailwind.config.js
module.exports = {
theme: {
extend: {
colors: {
'lollipop': {
100: '#FFFFEE',
200: '#FFFFD5',
300: '#FFFFBB',
400: '#FFFE88',
500: '#FFFE55',
600: '#E6E54D',
700: '#999833',
800: '#737226',
900: '#4D4C1A',
},
'lola': {
100: '#FCFBFC',
200: '#F8F4F7',
300: '#F4EDF1',
400: '#EBE0E7',
500: '#E3D3DD',
600: '#CCBEC7',
700: '#887F85',
800: '#665F63',
900: '#443F42',
}
},
spacing: {
'96': '24rem',
'128': '32rem',
'254': '64rem',
}
}
}
}
So, the result of my investigations is just to use the native ability of Javascript to generate parts of the config automatically, saving me time writing out config lines.
myVariants = {};
for(let x = 1; x < 12; x++)
myVariants[x + "/12"] = (8.33333 * x) + "%";
console.log(myVariants);
There is much more you can do to make your config even more automated too!