mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-15 17:31:25 +08:00
29 lines
923 B
TypeScript
29 lines
923 B
TypeScript
|
import React from 'react';
|
||
|
import { EyeInvisibleOutlined, EyeTwoTone } from '@ant-design/icons';
|
||
|
import { Button, Input, Space } from 'antd';
|
||
|
|
||
|
const App: React.FC = () => {
|
||
|
const [passwordVisible, setPasswordVisible] = React.useState(false);
|
||
|
|
||
|
return (
|
||
|
<Space direction="vertical">
|
||
|
<Input.Password placeholder="input password" />
|
||
|
<Input.Password
|
||
|
placeholder="input password"
|
||
|
iconRender={visible => (visible ? <EyeTwoTone /> : <EyeInvisibleOutlined />)}
|
||
|
/>
|
||
|
<Space direction="horizontal">
|
||
|
<Input.Password
|
||
|
placeholder="input password"
|
||
|
visibilityToggle={{ visible: passwordVisible, onVisibleChange: setPasswordVisible }}
|
||
|
/>
|
||
|
<Button style={{ width: 80 }} onClick={() => setPasswordVisible(prevState => !prevState)}>
|
||
|
{passwordVisible ? 'Hide' : 'Show'}
|
||
|
</Button>
|
||
|
</Space>
|
||
|
</Space>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
export default App;
|