how to create dynamic classes in tailwind typescript react
const classes = {
wrapper: 'border-2 m-16 p-16 text-center',
title: 'text-gray-800 text-xl font-bold',
description: (active) =>
`my-6 ${active ? 'text-red-900 font-medium' : 'text-gray-800'}`,
button: 'py-2 px-4 bg-gray-100 border-2 focus:outline-none',
buttonActive: 'bg-gray-400',
};
const AdvancedComponent = () => {
const [active, setActive] = useState(false);
return (
<div className={classes.wrapper}>
<h1 className={classes.title}>Advanced Component</h1>
<p className={classes.description(active)}>
I change based on the button click state.
</p>
<button
className={clsx([classes.button, active && classes.buttonActive])}
onClick={() => setActive((prevState) => !prevState)}
>
Click Me
</button>
</div>
);
};
Also in JavaScript:
- change style on click react
- identify chrome on android using javascript
- hoe verbind je de nodemcu 8266 met adafruit io
- angular material upload file
- game winner pop up in javascript
- js import and export
- create react app scaffolding
- should i put firebase in redux thunk
- swap function javascript
- make directive to return dropdown values angular
- trigger click jquery
- node express dynamic route and error handler
- vue js link image link in props doesnt work
- angular get current time
- js match any number string
- call laravel route js
- how to reload page on button click in javascript
- 3. What are private member variables. in js
- react native map repeate
- react make an ascending descending button
- angular import service
- checkbox default value and checked value get in jquery
- template literal syntax' is only available in ES6 (use 'esversion: 6'). (W119)jshint(W119)
- string contains in javascript