Removing the outline border from a Material IconButton when clicked using styled Components: A guide

Is there a way to remove the outline border that appears when using a material iconButton and it is clicked? I've tried various methods without success. Can styled components help achieve this?

Take a look at the image below.

Image

https://i.sstatic.net/a5xuH.jpg

Here is the code snippet:

Code

import React from "react";
import { Paper, Grid, Typography } from "@material-ui/core";
import styled from "styled-components";
import IconButton from "@material-ui/core/IconButton";
import CheckCircleIcon from "@material-ui/icons/CheckCircle";
import EditIcon from "@material-ui/icons/Edit";

const StyledContainer = styled.div`
  width: 90%;
  text-align: left;
  padding: 10px 16px;
`;

const DataContainer = styled.div`
  display: flex;
  justify-content: space-between;
  align-items: center;
`;

const InfoContainer = styled.div`
  display: flex;
  align-items: center;
`;

const EditButton = styled(IconButton)`
  outline: none;
  border: none;
`;

function DocItem({ title, author }) {
  return (
    <StyledContainer>
      <Grid item xs={12}>
        <Paper elevation={3} style={{ padding: "10px 16px" }}>
          <DataContainer>
            <InfoContainer>
              <CheckCircleIcon
                style={{ width: "64px", height: "64px", marginRight: "22px" }}
              />
              <div>
                <h3>{title}</h3>
                <h4>{author}</h4>
              </div>
            </InfoContainer>
            <EditButton>
              <EditIcon />
            </EditButton>
          </DataContainer>
        </Paper>
      </Grid>
    </StyledContainer>
  );
}

export default DocItem;

Answer №1

After facing a similar problem, I found that including the mat button resolved it successfully.

For instance: import {MatButtonModule} from '@angular/material/button' imports: [ MatButtonModule,

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The MaterialUI Dropdown Icon fails to open the menu

I am currently experimenting with the MaterialUI Select component and trying to incorporate the IconComponent option. The icon is displaying correctly, but unfortunately, when clicked, the menu does not expand as expected. If you would like to see an exam ...

Personalizing the hamburger icon in Bootstrap 4.0

I want to modify the color of the three lines as well as the border around the icon using CSS, but I'm unsure which tags to target. CSS: .navbar-toggler .navbar-toggler-icon { background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox=& ...

Navigating to a dynamic route in Next.js and a static hosting platform such as Github Pages results in a 404 error page being displayed

In the process of developing my web app using Next.js, I have encountered an issue with hosting it on Github Pages (due to external constraints, as I would prefer to use Vercel or another platform). One particular challenge involves a dynamic route: webap ...

Error in ReactJS: Trying to call a function from within a map function in ReactJS, but

Attempting to make a call to getElementByKey() function while mapping a collection: {this.state.sections.map(function(section) { return (<Tab key={section.value} title={section.label}> {this.getElementByKey(se ...

I exclusively use CSS for my tooltips, no images involved

I created some CSS code for a tooltip element .toolTip{ display:inline; position:relative; } .toolTip:hover:after{ background: #333; background: rgba(0,0,0,.8); border-radius: 5px; bottom: 26px; color: #fff; content: attr( ...

Define the position of a scrolled area within an HTML document to create a

In my current project, I have a scrollable area that highlights the selected div in gray. The HTML is written using Ember (hbs) and includes code to handle this functionality. Below is an example of how the div looks: https://i.sstatic.net/T2Lur.png Here ...

Adjusting elements in Material UI without distorting them

Struggling with resizing a select component from material UI led to some unexpected challenges. Despite attempting to adjust the size using the className property, the label ended up misaligned and the selection shade appeared larger than the select box it ...

React useContext Returns Unexpected Value

I am new to React and encountering an issue with useContext. My goal is to connect to an API, retrieve data from it, and store it in a context. Here is the file MovieContextProvider.jsx which handles this: import React, { useState, createContext, useEffe ...

Encountering a hurdle: Unable to run npm run dev in Next.js due to NPM error

> @ dev C:\Users\Mustafa\Desktop\React&Next\insta-2.0 > next dev 'Next\insta-2.0\node_modules\.bin\' is not recognized as an internal or external command, operable program or batch file. int ...

Tips for getting my navigation bar menu button functioning properly?

I am struggling to make my button show the menu when clicked. I have tried various methods but still can't pinpoint the issue. I utilized the "checkbox" trick to display the hamburger button when the site width is under 500px for a responsive menu, ye ...

Exploring different rendering strategies such as hydrateRoot in React 18 or utilizing alternative design patterns to improve performance of sluggish

As I embark on upgrading my extensive web application from React 16 to React 18, which is built on .NET 6, I am also planning a complete overhaul. Currently, the application does not utilize any hydration SSR techniques. Despite my thorough research, I hav ...

showcase web content in an application package (APK)

I recently built an application using Next.js and React. The client has asked for an Android app, so I'm contemplating creating an APK file that would open our domain. Essentially, if our domain is example.com, the APK file would function like a web b ...

react-oidc-context automatically redirects to the original route upon successful login using Auth0

Greetings! I am currently attempting to implement authentication using react-oidc-context with auth0, but I have encountered an issue. Upon successful authentication with auth0, I always get redirected back to the route I was on when I clicked the login bu ...

Steps for making a toggle button with Bootstrap

Initially, I developed a web application using HTML, CSS, and JavaScript. Later on, I was requested to recreate it using Bootstrap as well. While I managed to complete the task successfully, I encountered an issue where toggle buttons in the web app revert ...

Customizing the input field to have a width of 100%

Could someone provide a solution, like a link or working example, for creating input fields with rounded corners that have a width of 100% and a customizable right border? Here is the current structure I am using: <span class="rounded left-corner" ...

Tips for stopping multiple executions of dispatch using hooks

I am currently working on a React Redux project where I need to make an API call and periodically update the progress value displayed on the screen. To achieve this, I am using a combination of useEffect and useState hooks. However, I have encountered an i ...

The inner function of a functional component does not have access to the context value

My current project involves creating a component that can handle a large list of items and display them in chunks as the user scrolls. The goal is to automatically load more items as the user reaches the end of the visible list. However, I've encount ...

Are there any instances where CSS is overlooking certain HTML elements?

In the following HTML code snippet, the presence of the element with class ChildBar is optional: <div class="Parent"> <div class="ChildFoo"></div> <div class="ChildBar"></div> <!-- May ...

Is it possible to utilize the map method to extract objects that are nested multiple layers deep?

I am working on accessing the change order information in order to compile a list of all the change_order_names. The code I am currently using is yielding the results displayed below. Could someone assist me in understanding how to access the change order ...

I am experiencing issues with my React application form not being able to successfully submit data

I've successfully built a backend api using node and express, which functions perfectly when tested with Postman and Insomnia. However, I'm facing an issue where my create function fails to post to the api. The login to the API works fine, and th ...