shadcn-ui / ui

Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source.
https://ui.shadcn.com
MIT License
62.84k stars 3.53k forks source link

Remove the outline in input #769

Closed Ghoral closed 1 year ago

Ghoral commented 1 year ago

Hi, How can I remove the outline in input when focused?

Screenshot 2023-06-29 at 18 59 46

Thank you.

dan5py commented 1 year ago

Hi @Ghoral, you can add the focus-visible:ring-0 classname to the <Input> component. This will disable the focus ring just for a single instance.

If you want to remove it from all Input you can remove all the classnames that start with focus-visible: in the input.tsx file.

Ghoral commented 1 year ago

Thank you for quick response.

VadBe commented 11 months ago

focus-visible:ring-transparent works better for me.

lisaspotty commented 8 months ago

focus-visible:ring-transparent works better for me.

same solution as u 🍭

MimmyJau commented 6 months ago

Neither focus-visible:ring-0 nor focus-visible:ring-transparent seem to be working for me. Anyone else?

reinaldo-vombo commented 6 months ago

<Input type="email" className="bg-transparent border-0 border-b-2 border-gray-500 px-6 py-8 focus-visible:ring-offset-0 focus-visible:ring-0" placeholder="Email" /> do this

abhishek61067 commented 6 months ago

You can remove the classname: focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 from input component provided by the shadn in components/ui/input.jsx.

<input
      type={type}
      className={cn(
        "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none  disabled:cursor-not-allowed disabled:opacity-50",
        className
      )}
      ref={ref}
      {...props} />

i am directly changing from the component provided by shadcn to preserve the consistency in your project.

Jervx commented 5 months ago

this works for me

focus-visible:ring-0 focus-visible:ring-transparent focus-visible:ring-offset-0

tonyljx commented 4 months ago

focus-visible:ring-0 focus-visible:ring-transparent focus-visible:ring-offset-0

thank you ! it works!!!!!!

Garvit1809 commented 3 months ago

how do we do this in select component. Tried many things but none is working ;(

pedrogrigorio commented 3 months ago

how do we do this in select component. Tried many things but none is working ;(

Just use "focus:" instead of "focus-visible", like this:

<Select>
  <SelectTrigger className="w-[180px] focus:ring-offset-0 focus:ring-0">
    <SelectValue placeholder="Select a fruit" />
  </SelectTrigger>

  <SelectContent>
    <SelectGroup>
      <SelectLabel>Fruits</SelectLabel>
      <SelectItem value="apple">Apple</SelectItem>
      <SelectItem value="banana">Banana</SelectItem>
      <SelectItem value="blueberry">Blueberry</SelectItem>
      <SelectItem value="grapes">Grapes</SelectItem>
      <SelectItem value="pineapple">Pineapple</SelectItem>
    </SelectGroup>
  </SelectContent>
</Select>
You can also verify what properties your component uses opening the file that shadcnui creates (like select.tsx).
nightmare14226 commented 1 month ago

I tried it but the ring is visible yet when the select trigger is closed.

ParshvLimbad commented 1 month ago

focus-visible:ring-[none] worked for me

vekaev commented 2 weeks ago

tabindex=-1