The appearance of my sidebar items' right border varies depending on the web browser being used

My sidebar item's right border appears differently in Mozilla and Chrome. How can I resolve this issue?

Here are the images from both browsers:

https://i.stack.imgur.com/YGkkz.png

https://i.stack.imgur.com/JxNs3.png

"use client";
import { cn } from "@/lib/utils";
import { LucideIcon } from "lucide-react"
import { usePathname, useRouter } from "next/navigation";

interface SidebarItemProps {
    icon: LucideIcon;
    label: string;
    href: string;
}

export const SidebarItem = ({ icon: Icon, label, href }: SidebarItemProps) => {
    const pathname = usePathname()
    const router = useRouter()


    const isActive =
        (pathname === "/" && href === "/") ||
        pathname === href ||
        pathname?.startsWith(`${href}/`)

    const onClick = () => {
        router.push(href)
    }

    return (
        <button
            onClick={onClick}
            type="button"
            className={cn(
                "flex items-center gap-x-2 text-slate-500 text-sm font-[500] pl-6 transition-all hover:text-slate-600 hover:bg-slate-300/20", isActive && "text-sky-700 bg-sky-200/20 hover:bg-sky-200/20 hover:text-sky-700"
            )}
        >
            <div className="flex items-center gap-x-2 py-4">
                <Icon
                    size={22}
                    className={cn(
                        "text-slate-500",
                        isActive && "text-sky-700"
                    )}
                />
                {label}
            </div>
            {/* Right Active Border */}
            <div
                className={cn(
                    "ml-auto opacity-0 border-2 border-sky-700 h-full transition-all",
                    isActive && "opacity-100"
                )}
            />
        </button>
    )
}

I'm aiming for consistent display across all browsers like Mozilla and Chrome.

Answer №1

Perhaps consider removing the "items-center" from the button's class list.

This declaration in the CSS gives the button an alignment of center, potentially overriding the default display: flex; align-items property.

The default value for align-items is stretch, which means items within the flex container will expand to fill the available space evenly in terms of height.

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

What are the steps for defining a package once and utilizing it across multiple pages?

Hello, I'm new to Next.js and I have a question regarding the code organization. In my project, I have two pages: PostList (index.js) and PostSingle ([postId].js). I want to implement a feature that allows users to switch between dark and light theme ...

Connection to localhost at port 3001 is being denied

While busy with a project, I encountered an issue where my localhost3001 was constantly refusing to connect. Any ideas on how to resolve this? Check out the image of the problem here. Even after attempting to run my app, localhost3001 still refused to con ...

Using an HTML5 image icon as an input placeholder

Is there a way to incorporate an image icon into an input placeholder and have it disappear when the user starts typing, across all browsers? In trying to achieve this, I successfully implemented a solution for webkit (Safari+Chrome) using ::-webkit-input ...

Encountering problems with `npm run build` when using `con

Running a react app with express as the backend has been quite the adventure. After following this particular tutorial on how to connect the two and deploy to heroku, I found myself in a bit of a conundrum. Express is running smoothly on port 5000 as instr ...

Validate prop must consist of one of two functional components

I am looking to ensure that a prop can only be one of two different components. Here is what I currently have: MyComponent.propTypes { propA: PropTypes.oneOfType([ PropTypes.instanceOf(ClassComponentA) PropTypes.instanceOf(ClassCompon ...

Error in React-router: "Attempting to access property 'transitionTo' which is undefined"

I am utilizing webpack, ES6, react-router library, and the Link component for handling my links. I am trying to transition with the parent div of the link element, but every time I click on the div, I encounter this error: Uncaught TypeError: Cannot read ...

Encountering an error in React Native: When importing the 'localized-strings' object, it throws an "Undefined is not an

I'm currently facing a challenge in React Native and JS, as I am struggling with importing a function from another file and passing it. I am utilizing the 'localized-strings' library available at this website. Below is my code snippet where ...

Utilizing Auth0 in combination with ReactJS and Lumen, the specified audience appears as a unique and seemingly

I am in the process of developing an application with a ReactJS frontend and a Lumen backend. To ensure that only specific users can access the API, I have implemented Auth0 for authentication. Currently, JWT auth is set up in Lumen, and using postman, I ...

Working with CSS3 transitions in PHPStorm is a breeze

For some reason, my phpstorm does not provide code completion for CSS properties like -webkit-translate, translate, or animation. Has anyone encountered this issue before? Any suggestions on how to fix it? ...

How can we align the top edge of a div to the center of a circle within a separate div in a responsive manner?

I want to create 2 stacked divs: the first div contains a circular image, and the second div contains text. I want the second div to always cover half of the circle, with its upper edge positioned at the center point of the circle. This is my code: .cov ...

What is the best way to remove a CSS style using JavaScript?

For my website automation using Selenium, I encountered a challenging dropdown that was not the standard native one but a custom-designed version. To tackle this issue, I needed to set its CSS class to hidden in order to access the native functionality smo ...

"Utilizing Ag Grid pagination with React for efficient server-side data handling

I'm currently utilizing the AG-Grid library within my React JS project. I have a substantial amount of data totaling 40000 entries that I need to display using pagination (specifically page1, page2, page3, and so forth). Although I am quite new to th ...

Customize a theme component only when it is a child of another component

I am trying to customize the CSS of MuiButton only when it is nested inside a MuiDialog. https://i.stack.imgur.com/13doLm.png In regular CSS, you could achieve this with: .MuiDialog-root .MuiButton-root { border: 5px solid blue; } However, I am strug ...

The attempt to update the user with ID 10 at the specified API endpoint on localhost at port 4000 has resulted in

While attempting to modify the form in react, I encountered an error message that read "PUT http://localhost:4000/api/update/user/10 404 (Not Found)". Below is my code for both the frontend and backend. I am utilizing react, node, and MySQL. Can someone he ...

Combining Content on a GitHub Page

Within the <head> section of my index.html, I have successfully utilized these links on localhost: <link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet"> <link href=&apos ...

Transferring checkbox data to Bootstrap modals and dynamically summoning specific div modals using their unique identifiers

I have been trying to populate the checkbox values into corresponding modal divs based on button clicks, but I am facing difficulties in achieving it. Desired outcome: The buttons should trigger the display of selected checkbox values in their respective ...

Trouble displaying certain HTML code and its output on the browser?

I am in the process of developing a user profile page. I have designed a form with various fields, but the code within the section is not displaying correctly in the browser. I attempted to inspect the elements, but the code within that section remains inv ...

Although Angular allows for CSS to be added in DevTools, it seems to be ineffective when included directly in

Looking to set a maximum length for ellipsis on multiline text using CSS, I tried the following: .body { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; } However, this approach did not work. Interesti ...

What is the best way to adjust the size of a column when hovering

What I am attempting to achieve is, I would like the column box to have a 100% width, and when it is hovered over, I want it to transition to the left, with the width of the column box being about 60%, revealing a second block that shows up as 20% width o ...

Styling the scrollbar for the PDF element on an HTML page

I have a div that contains an object "linked" to a .pdf file. Is it possible to customize the scrollbar style using CSS or JavaScript/jQuery? <div id="container"> <object data="document.pdf" type="application/pdf" ...