react-native-paper icon indicating copy to clipboard operation
react-native-paper copied to clipboard

Web: Unwanted TextInput focus outline

Open globophobe opened this issue 7 years ago • 7 comments

Ask your Question

I thought this would remove the focus outline style with react-native-web, but it doesn't 😞.

const styles = StyleSheet.create({
  textInput: {
    outlineStyle: "none",
    outlineWidth: 0,
    outlineColor: "transparent"
  }
});

<TextInput style={styles.textInput} />

How can I remove it?

globophobe avatar Oct 10 '19 00:10 globophobe

Fixed wtih Emotion Global Styles .

globophobe avatar Oct 11 '19 23:10 globophobe

Fixed wtih Emotion Global Styles .

Did you find a way the doesn't involve including a whole new library?

actuallymentor avatar Mar 26 '20 09:03 actuallymentor

This worked for me, no libs

<TextInput
   style={{outline: "none"}}
/>

timsonater avatar May 27 '20 06:05 timsonater

Screen Shot 2020-08-28 at 5 30 43 PM

I'm seeing this error when I do outline: none.

nandorojo avatar Aug 28 '20 21:08 nandorojo

This is a react native web issue rather than react-native-paper issue.

Here is a patch without a third-party library

import React from 'react';
import { Platform } from 'react-native';

export interface GlobalStyleProps {
  css: string;
}

const GlobalStyle: React.FC<GlobalStyleProps> = ({ css }) => {
  React.useEffect(() => {
    if (Platform.OS === 'web') {
      const style = document.createElement('style');
      style.textContent = css;
      document.head.append(style);
      return () => style.remove();
    }
  }, [css]);
  return null;
};

export default React.memo(GlobalStyle);

In your App.tsx:

<GlobalStyle css="input {outline: none;}" />

Note: This takes effects globally.

seancheung avatar Feb 20 '21 05:02 seancheung

This worked for me!

import { Platform } from "react-native";

const TextInput = styled.TextInput`
  ${Platform.select({
    web: css`
      outline-style: none;
    `,
  })};
`;

sangheeeeeee avatar Mar 09 '21 05:03 sangheeeeeee

if you use typescript

import { TextInput, TextInputProps } from "react-native";

<TextInput
  style={
    {
      outline: "none",
    } as TextInputProps["style"]
  }
  {..._props}
/>;

add as ... to disable error message :>

minhquan1313 avatar Jun 11 '24 05:06 minhquan1313