Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat]: Autofocus for Input-OTP #4035

Closed
2 tasks done
WhyFenceCode opened this issue Jun 18, 2024 · 2 comments
Closed
2 tasks done

[feat]: Autofocus for Input-OTP #4035

WhyFenceCode opened this issue Jun 18, 2024 · 2 comments

Comments

@WhyFenceCode
Copy link

Feature description

I am wondering if we can add some simple code to the Input-OTP object that makes the first box of the Input-OTP object get selected when it begins to render. This should be a simple bool just like disabled, so that it can quickly work and is easy to use.

Affected component/components

Input-OTP

Additional Context

No response

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues and PRs
@bhaskarkhoraja
Copy link

This features already exist just pass attribute autoFocus to InputOTP component

const InputWithAutoFocus = () => {
  return (
    <InputOTP maxLength={6} autoFocus> {/* <- autoFocus as boolean */}
      <InputOTPGroup>
        <InputOTPSlot index={0} />
        <InputOTPSlot index={1} />
        <InputOTPSlot index={2} />
      </InputOTPGroup>
      <InputOTPSeparator />
      <InputOTPGroup>
        <InputOTPSlot index={3} />
        <InputOTPSlot index={4} />
        <InputOTPSlot index={5} />
      </InputOTPGroup>
    </InputOTP>
  );
};

@shadcn shadcn added the Stale label Jul 8, 2024
@shadcn
Copy link
Collaborator

shadcn commented Jul 15, 2024

This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.

@shadcn shadcn closed this as completed Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants