Tailwindcss styles completely disappears after running build-css - css

This is the import url
After writing npm run build-css on the terminal. The changes i made before and the change i wanted to make disappeared. None of the tailwindcss styles i had in my index.html was found.
extend: {
colors: {
primary: "FF6363"
},
fontfamily: {
body: ['Nunito'],
}
},

I would start by making sure the color-extend has the correct '#' before it and also wrapping the color name in quotes also.
Also check your webpack.mix.js file to make sure yourt calling the files in the correct order.
Should resemble something similar to mine.
mix.js("resources/js/app.js", "public/js")
.vue()
.sass("resources/sass/app.scss", "public/css")
.sass("resources/sass/components/sidebar.scss", "public/css")
.sass("resources/sass/components/modal.scss", "public/css")
.sass("resources/sass/components/language-picker.scss", "public/css")
.sass("resources/sass/custom.scss", "public/css")
.options({
processCssUrls: false,
postCss: [tailwindcss("tailwind.config.js")],
output: {
path: "birdboard",
publicPath: "/dist/js/",
filename: "./dist/js/bundle.js"
}
});
Also check your tailwind.config.js file for formatting issues, my version follows this simple layout.
module.exports = {
theme: {
screens: {
sm: "576px",
// => #media (min-width: 576px) { ... }
md: "960px",
// => #media (min-width: 960px) { ... }
lg: "1440px"
// => #media (min-width: 1440px) { ... }
},
backgroundColor: theme => ({
page: "var(--page-background-color)",
card: "var(--card-background-color)",
button: "var(--button-background-color)",
header: "var(--header-background-color)"
}),
colors: {
error: "var(--text-error-color)",
grey: {
default: "rgba(0, 0, 0, 0.4)",
lighter: "#F5F6F9"
},
white: {
default: "#fff"
},
blue: {
default: "#47cdff",
light: "#8ae2fe"
},
default: "var(--text-default-color)",
accent: {
default: "var(--user-accent-color)",
light: "var(--text-accent)"
},
muted: {
default: "var(--text-muted-color)",
light: "var(--text-muted-light-color)"
}
},
boxShadow: {
default: "0 0 5px 0 rgba(0, 0, 0, 0.08)",
blue: "0 2px 7px 0 #b0eaff"
},
extend: {}
},
variants: {},
plugins: []
};
Just as a quick note. You could try 'bg-rose-500' which is very similar to the color you was trying to add.
I use 'npm run dev' to build my assets in Laravel & Tailwind
This is for one-off colours using TailwindCSS
Arbitrary values
If you need a one-off custom color in your project, consider using Tailwind’s arbitrary value notation to generate a class for that color on-demand instead of adding it to your theme:
<button class="bg-[#1da1f2] text-white ...">
<svg><!-- ... --></svg>
Share on Twitter
</button>

Related

Vercel Deployment of Remix.js & Tailwind CSS (with NextUI) App: No CSS styling in Deployment

I'm pretty lost. Trying to deploy my Remix Tailwind App which is working perfectly in Dev Environment.
Dev Environment working fine
As soon as I deploy, almost anything is gone basically. See here:
Vercel Env not working
Here's my tailwind config file:
content: ["./app/**/*.{ts,tsx,jsx,js}"],
module: {
rules: [
{
test: /\.css$/i,
use: ["style-loader", "css-loader"]
}
]
},
safelist: [{ pattern: /.*/ }],
theme: {
screens: {
xxs: "350px",
custom3: "420px",
xs: "480px",
custom2: "580px",
sm: "676px",
md: "768px",
custom: "910px",
lg: "1050px", // laptop: Default screen size
xl: "1280px", //desktop
"2xl": "1526px",
"3xl": "1696px"
},
extend: {
colors: {
textLgColor: "var(--text-large-color)",
textSmColor: "var(--text-small-color)",
subText: "var(--sub-text-color)",
navBar: {
linkActive: "var(--nav-link-active)",
linkActiveStripe: "var(--nav-link-active-stripe)"
},
mobileNav: {
text: "var(--mobile-text)",
textHover: "var(--mobile-hover-text)",
border: "var(--mobile-border)"
},
aboutMe: {
smIconBg: "var(--sm-icon-bg)",
aboutMeText: "var(--aboutme-text)",
alissa: "var(--alissa)"
},
projects: {
text: "var(--project-text-color)",
subText: "var(--project-sub-text)",
arrow: "var(--project-arrow)",
recentBg: "var(--recent-project-bg)",
recentHover: "var(--recent-project-bg-hover)",
recentShadow: "var(--recent-project-shadow)"
},
contact: {
label: "var(--label-text)",
send: "var(--send-btn)",
sendHover: "var(--send-btn-hover)"
},
blog: {
lgText: "var(--blog-lg-text)",
border: "var(--blog-input-border)",
tagBg: "var(--tag-btn-bg)"
},
post: {
bodyText: "var(--text-body)",
bodyTextLg: "var(--text-body-lg)",
icon: "var(--icon)",
iconHover: "var(--icon-hover)",
hyperlink: "var(--hyperlink)",
hyperlinkHover: "var(--hyperlink-hover)",
quote: "var(--quote)",
quoteAuthor: "var(--quote-author)"
}
}
}
},
plugins: [require("#tailwindcss/line-clamp")]
};
As this point I'm so frustrated, idgaf about my codebase anymore so here you go, I just made the repo public: https://github.com/flo-s99/Devato/settings
Any help appreciated

Tailwind breakpoint classes are not rendering based on the breakpoint

I am using tailwind.css. I got stuck while using the responsive css classes. I tried applying the width to an element, but the default mobile class is only getting applied, but not the breakpoint css. The class names are available in the tailwind css library.
Thanks in advance.
Below is tailwind.config.js
module.exports = {
purge: {
content: [
'./src/hbs/**/*.hbs',
'./src/js/**/*.js',
]
},
plugins:[
require('postcss-import'),
require('tailwindcss'),
require('autoprefixer'),
],
theme: {
colors: {
// Configure your color palette here
primary: {
red: '#D9272E',
orange: '#EF7622',
teal: '#00B3C9',
grey: '#818181',
},
secondary: {
tealDark: '#0099AC',
tealDarkest: '#007E8F',
black: '#1A1818',
darkGrey: '#4D4D4F',
grey: '#DBDBDB',
lightGrey: '#F7F7F7',
white: '#FFFFFF',
}
},
fontFamily: {
"exo": ['"Exo"'],
},
screens: {
'md': '768px',
// => #media (min-width: 768px) { ... }
},
fontSize: {
// // mobile
// cfs: customFontSize
'cfs': '1rem',
'c2fs': '1.125rem',
'c3fs': '1.188rem',
'c4fs': '1.25rem',
'c5fs': '1.313rem',
'c6fs': '1.5rem',
'c7fs': '2rem',
'c8fs': '2.375rem',
'c9fs': '2.75rem',
}
}
}
This snippet:
plugins:[
require('postcss-import'),
require('tailwindcss'),
require('autoprefixer'),
],
Belongs in your postcss.config.js not your tailwind.config.js. Here is the relevant documentation https://tailwindcss.com/docs/using-with-preprocessors#build-time-imports.
Edit:
The rest of your config works fine, here it is working on Tailwind Play.

Enable hover only on top/bottom/left/right

I'm trying to create a variant in Tailwind file configuration.
What I would like to have is something like hover:border-l-4 hover:border-green-400, so a class that enables a border on the left (or only on top / bottom / right).
So I create this inside tailwind.config.js:
module.exports = {
purge: {
enabled: process.env.NODE_ENV === 'production',
content: ['./src/**/*.html', './src/**/*.{js,ts,jsx,tsx}'],
},
darkMode: false,
theme: {
extend: {
colors: {
...
},
},
borderLeft: (theme) => ({}),
...
},
variants: {
extend: {
borderLeft: ['hover', 'focus']
},
},
plugins: [],
}
It doesn't work. I get TypeError: variantsValue is not iterable.
I didn't find anything useful in the documentation page.
Checkout docs on tailwind.
variants: {
extend: {
borderWidth: ['hover'],
}
}
From here, hover:border-l-4 hover:border-green-400 will work.

Tailwind custom forms: how to add your own color (hex value)

This site: https://tailwindcss-custom-forms.netlify.app/ gives this example tailwind.config.js file:
// tailwind.config.js
module.exports = {
theme: {
customForms: theme => ({
dark: {
'input, textarea, multiselect, checkbox, radio': {
backgroundColor: theme('colors.gray.900'),
},
select: {
backgroundColor: theme('colors.gray.600'),
},
},
sm: {
'input, textarea, multiselect, select': {
fontSize: theme('fontSize.sm'),
padding: `${theme('spacing.1')} ${theme('spacing.2')}`,
},
select: {
paddingRight: `${theme('spacing.4')}`,
},
'checkbox, radio': {
width: theme('spacing.3'),
height: theme('spacing.3'),
},
}
})
},
plugins: [
require('#tailwindcss/custom-forms'),
]
}
it uses colors.gray.600 notation for setting colors. However I need a #f90f39 color. How do I set it?
Use Tailwind’s arbitrary value notation to generate a class for that color on-demand instead of adding it to your theme
<button class="bg-[#1da1f2] text-white ..."></button>
You need customize colors in tailwind.config.js: https://tailwindcss.com/docs/customizing-colors#app

How to build CSS/PostCSS only during CSS changes?

Everytime I update .js code in my Ember App (components, tests, etc.) my app.css file is rebuilt, even though I'm not touching any CSS!
I am using PostCSS and TailwindCSS plugin. Every time I save a .js the entire TailwindCSS library is rebuilt and takes 1200-2000ms. This is really unnecessary and I would like to know how to avoid it. If I disable TailwindCSS the rebuild time of PostCSS drops to 191ms on every .js save.
There are a few solution ideas I'd like to explore:
Is it possible to configure Ember rebuild my CSS ONLY when I change
CSS?
Is it possible to configure PostCSS to rebuild only when CSS has
changed?
How can I configure TailwindCSS to use a static CSS file for the library, and then setup
PostCSS to build only my custom tailwind classes using the
tailwind plugin?
ember-cli-build.js
postcssOptions: {
compile: {
plugins: [
{
module: require("postcss-import"),
options: {
path: ["node_modules"]
}
},
require("tailwindcss")("./config/tailwind.config.js")
]
}
}
config/tailwind.config.js
module.exports = {
theme: {
extend: {
height: {
"80": "20rem",
"screen-80": "80vh",
"screen-60": "60vh"
},
minWidth: {
"96": "24rem",
screen: "100vw"
},
maxWidth: {
"min-content": "min-content",
screen: "100vw"
},
screens: {
xxl: "1920px"
},
zIndex: {
"9999": 9999
},
colors: {
puke: {
100: "#fff5f7",
200: "#fed7e2",
300: "#fbb6ce",
400: "#f687b3",
500: "#ed64a6",
600: "#d53f8c",
700: "#b83280",
800: "#97266d",
900: "#702459"
}
},
backgroundColor: theme => theme("colors"),
textColor: theme => theme("colors"),
borderColor: theme => ({
...theme("colors"),
default: theme("colors.gray.300", "currentColor")
})
}
},
variants: {},
plugins: []
};

Resources