Incorporating a unique variant with Tailwind called "

I'm currently struggling with inputting the configuration file for Tailwind. Despite my efforts, I cannot seem to get it right. The code appears correct to me, but I am unsure of what mistake I might be making.

Below is the snippet of my code:

import type { Config } from "tailwindcss";
import formsPlugin from "@tailwindcss/forms";
import plugin from "tailwindcss/plugin";

interface Props {
  modifySelectors: (className: string) => string;
  separator: string;
}
interface modifySelectorsProps {
  className: string;
}

const config: Config = {
  content: [
    "./src/pages/**/*.{js,ts,jsx,tsx,mdx}",
    "./src/components/**/*.{js,ts,jsx,tsx,mdx}",
    "./src/app/**/*.{js,ts,jsx,tsx,mdx}",
    "./src/layouts/**/*.{js,ts,jsx,tsx,mdx}"
  ],
  plugins: [
    formsPlugin,
    plugin(({ addVariant, e }) => {
      addVariant("label-checked", ({ modifySelectors, separator }: Props) => {
        modifySelectors(({ className }: modifySelectorsProps) => {
          const eClassName = e(`label-checked${separator}${className}`);
          const yourSelector = 'input[type="radio"]';
          return `${yourSelector}:checked ~ .${eClassName}`;
        });
      });
    })
  ]
};
export default config;

With regards to the addVariant line, an error message is appearing:

Argument of type '({ modifySelectors, separator }: Props) => void' is not assignable to parameter of type 'string | string[] | (() => string) | (() => string)[]'.
  Type '({ modifySelectors, separator }: Props) => void' is not assignable to type '() => string'.
    Target signature provides too few arguments. Expected 1 or more, but only got 0.ts(2345)

Despite indicating that it expects the className parameter, the issue persists.

As for the modifySelectors line, another error arises:

Argument of type '({ className }: modifySelectorsProps) => string' is not assignable to a type of 'string'.ts(2345)

This problem disappears when I maintain this type and eliminate the type declaration from the line above.

Answer №1

If you're currently utilizing the tailwind v2 API for plugins, be aware that it has been updated in v3.

To ensure compatibility with recent tailwind installations, adjust your plugin to utilize the version 3 plugin API.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The Font Awesome icons are functioning flawlessly in the local environment, but encountering issues in production when implemented in Next

While developing in Next JS, I encountered an issue where font awesome icons were displaying perfectly on localhost but not appearing once the project was deployed to Vercel. I made sure to include a separate font CSS file that contained all necessary font ...

Guidelines for Organizing Angular Interface Files and Implementing Custom Type Guards

In my Angular 2 project, I am utilizing Interfaces and have implemented User Defined Type Guards: grid-metadata.ts export interface GridMetadata { activity: string; createdAt: object; totalReps: number; updatedAt: object; } grid.service.ts ... ...

Leveraging the power of Next.js version 13 in tandem with Elastic

I can't seem to figure out why I am getting an error when trying to read from an existing index using this API route and client-side page setup: import { Client } from "@elastic/elasticsearch"; import { NextResponse } from "next/server& ...

What are the best ways to handle data using the .pipe() function?

Looking to optimize an Angular component Typescript function that returns an Observable<book[]>. The logic involves: If (data exists in sessionStorage) Then return it Else get it from remote API save it in sessionStorage return it End ...

There was an issue serializing the `.product` data that was returned from `getStaticProps` in the "/prints/[name]" route in Next.js

My Strapi nextjs application has 2 categories of products. Everything works fine locally, but I encounter an error when trying to build: Error serializing .product returned from getStaticProps in "/prints/[name]". Reason: undefined cannot be se ...

NEXT JS - Application renders twice due to rewrites in place

I'm currently working on a NEXT JS project and facing the issue of the app rendering twice! Challenge After implementing rewrites in next.config.js, the app is being rendered twice. Removing the rewrites solves the issue and only renders once. next ...

The situation I find myself in frequently is that the Angular component Input

There seems to be an issue with a specific part of my application where the inputs are not binding correctly. The component in question is: @Component({ selector : 'default-actions', templateUrl : './default.actions.template.html&a ...

What is the method for importing styles in Next.js without including the file extension?

I've got a project set up with Next.js, TypeScript, and SCSS. In every app/*/page.tsx or components/*/page.tsx, there's a line importing the stylesheet like import style from "styles/*/index.module.scss". I find these lines to be too lo ...

Encountering a URL issue in my NextJS project and struggling to identify the root cause

I am facing an issue that occurs in both development and production modes, but strangely, it only crashes the website in production. The error message I am getting is: unhandledRejection: TypeError: Only absolute URLs are supported at getNodeRequestOption ...

Pause and be patient while in the function that delivers an observable

I have a function that loads user details and returns an observable. This function is called from multiple places, but I want to prevent redundant calls by waiting until the result is loaded after the first call. Can anyone suggest how this can be accompli ...

What methods can be used to display data using TypeScript's Optional Chaining feature?

I came across this Try it Yourself TypeScript Optional Chaining example in W3Schools TypeScript Null & Undefined section, and I have attached a screenshot for reference. https://i.sstatic.net/s8q1J.png The example demonstrates that when data is undef ...

Tips for Loading CSS Asynchronously in NextJS

Is there a way to make my global CSS file load asynchronously in Next.js, without causing render-blocking issues? Currently, my page is waiting for First Contentful Paint (FCP) until the CSS is loaded. This is what I have: <link rel="stylesheet&qu ...

When an anchor tag is embedded within a string response, ReactJS fails to render it as a clickable link

I am in the process of transitioning our code from Freemarker to React JS and I am encountering an issue with rendering anchor tags from a JSON string response. When I display this string in my React JS application, the anchor tags are appearing as plain t ...

Achieving fixed width and automatic height for images in Next JS: a guide

I am struggling to showcase a list of images with a fixed width while utilizing the original image height set at 100%. A similar inquiry can be found here, yet it remains unanswered. I have gone through the responses shared here and attempted them. The im ...

What is the best way to adjust the value of largePageDataBytes in Next.js?

I am looking to modify the largePageDataBytes setting, despite knowing it may impact performance. I made an attempt in next.config.js with the following code: /** * @type {import('next').NextConfig} */ const nextConfig = { /* config options h ...

Utilize Next JS pages api to generate dynamic routes based on unique ids

In the content of my website, there is a collection of objects named stories that are displayed as an array. Additionally, I have a section where each individual story is showcased in detail. I intend to enable users to click on any story link within the ...

Encountering an issue: Next.js application with Sendgrid API requiring an array for `personalizations`

I am encountering an issue with my sendAlerts.js file in the api folder. Every time I try to run it, I receive the Error: Array expected for personalizations at http://localhost:3000/api/sendAlerts This is the code inside api/sendAlerts: const mail = requ ...

When I utilize a component to create forms, the React component does not refresh itself

One of the components I am working with is a form handling component: import React, { useState } from "react"; export const useForm = (callback: any, initialState = {}) => { const [values, setValues] = useState(initialState); const onCha ...

What might be causing the reducer to not be invoked in Redux?

Check out my user reducer code: // reducers/User.js import { Action, createSlice, PayloadAction } from "@reduxjs/toolkit"; import { GetUserOut } from "../tikexModule/Types"; const initialState = { value: null, }; const userReducer ...

What is the most effective approach for annotating TypeScript abstract classes that are dynamically loaded?

I am in the process of developing a library that allows for the integration of external implementations, and I am exploring the optimal approach to defining types for these implementations. Illustration abstract class Creature { public abstract makeN ...