React-native-paper: Web: Unwanted TextInput focus outline

Created on 10 Oct 2019  路  6Comments  路  Source: callstack/react-native-paper

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?

question

Most helpful comment

This worked for me, no libs

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

All 6 comments

Fixed wtih Emotion Global Styles .

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

This worked for me, no libs

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

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

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

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.

This worked for me!

import { Platform } from "react-native";

const TextInput = styled.TextInput`
  ${Platform.select({
    web: css`
      outline-style: none;
    `,
  })};
`;
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ferrannp picture ferrannp  路  4Comments

talaikis picture talaikis  路  3Comments

mihaidaviddev picture mihaidaviddev  路  3Comments

satya164 picture satya164  路  4Comments

yaronlevi picture yaronlevi  路  3Comments