如何在React material-ui Tab组件中删除焦点突出显示? [英] How to remove focused highlight in React material-ui Tab Component?

查看:42
本文介绍了如何在React material-ui Tab组件中删除焦点突出显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 react Material-ui 库中的 Tab 组件.当Tab元素处于焦点位置时,该选项卡将在左右边框上显示此怪异的轮廓.

I am using a Tab component from the react Material-ui library. The tab appears with this weird outline on the left and right borders when the Tab element is in focus.

有什么方法可以删除此活动/焦点轮廓?

Is there any way to remove this active / focus outline?

下面是有关焦点样式奇怪的图像

Below is an image of the weird focus styling in question

我的代码如下:

import { Fragment } from 'react';
import styled from 'styled-components'
import Card from 'components/Elements/Card';
import CardItem from 'components/Elements/CardItem';
import CreateAccountForm from 'components/Forms/CreateAccount/container';
import { withTheme } from 'styled-components';
import { Container, Row, Col } from 'styled-bootstrap-grid';
import { pure } from 'recompact';

import Tabs from '@material-ui/core/Tabs';
import Tab from '@material-ui/core/Tab';
import { withStyles } from '@material-ui/core/styles';
import AppBar from '@material-ui/core/AppBar';

import OpenModalButton from 'components/Modal/OpenModalButton/container';

const styles = theme => ({
  indicator: {
    backgroundColor: "red",
    border: '5px solid blue !important',
    '&:active': {
      outline: 'none',
    },
    '&:focus': {
      outline: 'none',
    }
  },
  selected: {
    backgroundColor: 'blue',
  },
  wrapper: {
    border: '5px solid blue',
  }
});

import { LogoElement } from 'components/Elements/Icons';

const StyledCard = styled(withTheme(Card))`
  border: 15px solid ${ props => props.theme.colors.blue[3]};
  text-align: left;
  border-radius: 3px;
  padding-top: ${ props => props.theme.spacer[2]};
  padding-bottom: ${ props => props.theme.spacer[2]};
  position: relative;
  width: 98%;
  max-width: 1250px;
  min-height: 600px;
  display: flex;
  align-items: flex-start;

  h5 {
    color: ${ ({ theme }) => theme.colors.orange[3]};
  }
`;

const CloseButton = styled.a`
  transform: rotate(45deg);
  font-size: 50px !important;
  border: none !important;
  position: absolute;
  top: -20px;
  right: 5px;
  color: ${ props => props.theme.colors.blue[3]} !important;
  font-weight: 200 !important;
  &:hover{
    text-decoration: none;
  }
`;

const LogoContainer = styled.div`
  position: absolute;
  top: 10px;
  left: 15px;
  width: 45px;
  height: 100%;

  svg, path, g, polygon, rect {
    fill: ${ props => props.theme.colors.orange[1]} !important;
  }
`;

const Renderer = ({ handleClose, className, classes, handleTabChangeClick }) => {
  return (
    <StyledCard>
      <CloseButton href="#" onClick={handleClose}>+</CloseButton>
      <CardItem>
        <Container>
          <Row>
            <Col>
              <Tabs
              variant="fullWidth"
              onChange={handleTabChangeClick}
              >
                <Tab label="Profile" />
                <Tab label="Activity" />
                <Tab label="Score" />
                <Tab label="Edit" />
              </Tabs>
            </Col>
          </Row>
        </Container>
      </CardItem>
    </StyledCard>
  );
};

export default withStyles(styles)(Renderer);

推荐答案

我遇到了同样的问题.尝试更改:

I had the same problem. Try changing:

    '&:active': {
      outline: 'none',
    },

收件人:

    '&:hover': {
      outline: 'none',
    },

我使用样式化组件来覆盖material-ui样式,因此我的设置有些不同,但是解决方案应该相同.

I use styled-components to override material-ui styling, so my setup is a little different, but the solution should be the same.

这篇关于如何在React material-ui Tab组件中删除焦点突出显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆