Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

mui adding eye toggle at password field

// Add these variables to your component to track the state
const [showPassword, setShowPassword] = useState(false);
const handleClickShowPassword = () => setShowPassword(!showPassword);
const handleMouseDownPassword = () => setShowPassword(!showPassword);
// Then you can write your text field component like this to make the toggle work.
<TextField
  label='Some label'
  variant="outlined"
  type={showPassword ? "text" : "password"} // <-- This is where the magic happens
  onChange={someChangeHandler}
  InputProps={{ // <-- This is where the toggle button is added.
    endAdornment: (
      <InputAdornment position="end">
        <IconButton
          aria-label="toggle password visibility"
          onClick={handleClickShowPassword}
          onMouseDown={handleMouseDownPassword}
        >
          {showPassword ? <Visibility /> : <VisibilityOff />}
        </IconButton>
      </InputAdornment>
    )
  }}
/>
Comment

PREVIOUS NEXT
Code Example
Javascript :: como usar variables en selector jquery 
Javascript :: swr vs axios 
Javascript :: data tables ajust columns after init 
Javascript :: on refresh action set position rainmeter 
Javascript :: how to invoke a function in a class 
Javascript :: white when respons show code 
Javascript :: angular reactive forms bootstrap 4 
Javascript :: nodejs stream pipeline with custom transform 
Javascript :: find numeric Unicode value of the character with charCodeAt() method 
Javascript :: iterate over array of html elements 
Javascript :: the document has mutated since the result was returned 
Javascript :: Self Invoking Functions Can Also be Used To Make Variables Global In JavaScript 
Javascript :: this javascript 
Javascript :: loop in object 
Javascript :: select and select based on value in jquery 
Javascript :: js print 
Javascript :: convert html to javascript 
Javascript :: javascript numbers 
Javascript :: parse query url javascript 
Javascript :: for loop in js 
Javascript :: turn string into number javascript 
Javascript :: javascript sort object by value descending 
Javascript :: convert excel file to json using node js 
Javascript :: .unshift 
Javascript :: for in loops javascript 
Javascript :: Liquid shopify 
Javascript :: upload file in node 
Javascript :: discord.js command cooldown 
Javascript :: how to declare objects inside arrays in javascript 
Javascript :: datapack structure 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =