Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

react typescript tailwind toggle button

import React from "react"
import cx from "classnames"

function App() {
  const [toggle, setToggle] = React.useState<boolean>(false)

  const buttonClasses = cx({
    "bg-blue-500 hover:bg-blue-700": !toggle,
    "bg-red-500 hover:bg-red-500": toggle,
  })
  return (
    <div className="bg-gray-200 flex items-center justify-center h-screen">
      <button
        className={`p-3 rounded-sm ${buttonClasses}`}
        onClick={() => setToggle(!toggle)}
      >
        Toggle
      </button>
    </div>
  )
}

export default App
Comment

PREVIOUS NEXT
Code Example
Typescript :: create react native app typescript 
Typescript :: skip specific test in jasmine 
Typescript :: python retrieve name of sheets in workbook 
Typescript :: adonis where ilike 
Typescript :: typescript dictionary typing 
Typescript :: typescript take user input from console 
Typescript :: nestjs mongoose schema virtual 
Typescript :: google sheets empty functions 
Typescript :: get number of objects in enum c++ 
Typescript :: typescript key value loop 
Typescript :: css selector starts with 
Typescript :: styled components last child 
Typescript :: angular convert file to base64 
Typescript :: angle between two points unity 
Typescript :: ratio of subplots matplotlib 
Typescript :: what is the name of belt around the orbits of earth and mars 
Typescript :: react router dom move to another page 
Typescript :: get all the ids in an array of objects ts 
Typescript :: sql server results to comma delimited string 
Typescript :: cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. 
Typescript :: replace string in typescript 
Typescript :: remove empty objects from array lodash 
Typescript :: open rails secrets file 
Typescript :: angular forkjoin 
Typescript :: How to do Email validation using Regular expression in Typescript 
Typescript :: exists query elasticsearch 5.4 
Typescript :: vscode collapse all 
Typescript :: withStyles(DateRangePicker) 
Typescript :: create file object from url typescript 
Typescript :: sample typescript code 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =