react-icons/bs#BsEyeSlash TypeScript Examples

The following examples show how to use react-icons/bs#BsEyeSlash. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: formElements.tsx    From DevC-benin-jobs with GNU General Public License v3.0 5 votes vote down vote up
PasswordField: React.FC<InputFieldProps> = ({
  placeholder,
  value,
  onChange,
  err,
  name,
  className = '',
  min,
  max,
  label,
  ...rest
}) => {
  const [type, setType] = useState<string>('password');
  const errRef = useRef<HTMLSpanElement>(null);
  const interact = useCallback((type: 'blur' | 'focus'): void => {
    if (errRef.current) {
      if (type === 'blur') errRef.current.style.display = 'inline';
      if (type === 'focus') errRef.current.style.display = 'none';
    }
  }, []);
  return (
    <label
      className={`d-flex column margin-bottom-sm ${className}`}
      style={{ width: '100%' }}>
      <span className="font-sm font-weight-500 color-dark">{label}</span>
      <div className="d-flex input-container position-relative">
        <input
          onBlur={(): void => interact('blur')}
          onFocus={(): void => interact('focus')}
          type={type}
          name={name}
          value={value}
          onChange={onChange(min, max)}
          placeholder={placeholder}
          className="form-control border-r-5 padding-vertical-sm padding-horizontal-sm font-sm font-weight-500"
          {...rest}
        />
        <div className="field-check-icon">
          {type === 'password' ? (
            <BsEyeSlash
              className="font-md color-gray fadeIn-animation"
              onClick={(): void => setType('text')}
            />
          ) : (
            <BsEye
              className="font-md color-gray fadeIn-animation"
              onClick={(): void => setType('password')}
            />
          )}
        </div>
      </div>
      <span ref={errRef} className="font-xs font-weight-400 color-google">
        {err}
      </span>
    </label>
  );
}