Prevent zoom in on inputs, when browsing on mobile?
Answered
Japanese flying squid posted this in #help-forum
Japanese flying squidOP
Hey,
So i'm making a React app using Next.js and handling my forms with react-hook-forms and shadcn/ui and i was wondering if there is a way to control when to allow zoom in on inputs?
If anyone has played around with this themselves, and found a good way to do it. I'd greatly some tips 🙂
So i'm making a React app using Next.js and handling my forms with react-hook-forms and shadcn/ui and i was wondering if there is a way to control when to allow zoom in on inputs?
If anyone has played around with this themselves, and found a good way to do it. I'd greatly some tips 🙂
Answered by Japanese flying squid
Fixed by making sure input fields text-size is not below 16px
Here is a blog post about it:
https://www.expiredqueues.com/css/stop-zoom-in-on-input-focus-on-mobile-devices/
Here is a blog post about it:
https://www.expiredqueues.com/css/stop-zoom-in-on-input-focus-on-mobile-devices/
2 Replies
Japanese flying squidOP
Fixed by making sure input fields text-size is not below 16px
Here is a blog post about it:
https://www.expiredqueues.com/css/stop-zoom-in-on-input-focus-on-mobile-devices/
Here is a blog post about it:
https://www.expiredqueues.com/css/stop-zoom-in-on-input-focus-on-mobile-devices/
Answer
Harrier
Hello for all that are trying to fix this problem
i have used the advice listed on the web to adjust to 16px on css
But that doesnt work
eventually i changed my entire component,
especially the input component from shadcn to 16px
and that solved the problem
i have used the advice listed on the web to adjust to 16px on css
.input, textarea, select {
font-size: 16px;
}But that doesnt work
eventually i changed my entire component,
especially the input component from shadcn to 16px
and that solved the problem
import * as React from "react"
import { cn } from "@/lib/utils"
const Input = React.forwardRef(({ className, type, ...props }, ref) => {
return (
<input
type={type}
className={cn(
"flex h-10 w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm ring-offset-white file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-slate-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-950 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-800 dark:bg-slate-950 dark:ring-offset-slate-950 dark:placeholder:text-slate-400 dark:focus-visible:ring-slate-300",
className
)}
ref={ref}
style={{ fontSize: '16px' }} // Set font size to 16px
{...props}
/>
);
})
Input.displayName = "Input"
export { Input }