Skip to content

Conversation

@msamgan
Copy link
Contributor

@msamgan msamgan commented Oct 30, 2025

No description provided.

@tdubouchet
Copy link

tdubouchet commented Oct 31, 2025

@msamgan good idea ! I think the InputGroup component would be more appropriate.

@SantosVilanculos
Copy link
Contributor

@msamgan good idea ! I think the InputGroup component would be more appropriate.

Yes, but a reusable component would be better.

import { EyeClosedIcon, EyeIcon } from 'lucide-react';
import * as React from 'react';
import {
    InputGroup,
    InputGroupAddon,
    InputGroupButton,
    InputGroupInput
} from '@/components/ui/input-group';

function PasswordInput(
    props: Omit<React.ComponentProps<typeof InputGroupInput>, 'type'>
) {
    const [type, setType] = React.useState<'password' | 'text'>('password');

    return (
        <InputGroup>
            <InputGroupInput type={type} {...props} />
            <InputGroupAddon align="inline-end">
                <InputGroupButton
                    size="icon-xs"
                    onClick={() => {
                        setType(value => {
                            return value === 'password' ? 'text' : 'password';
                        });
                    }}
                >
                    {type === 'password' ? <EyeClosedIcon /> : <EyeIcon />}
                </InputGroupButton>
            </InputGroupAddon>
        </InputGroup>
    );
}

export { PasswordInput };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants