React Semantic UI - A modern solution for semantic web development

Having trouble styling React Components with Semantic UI for React (). I've customized Semantic UI's styles Core, but sometimes I need to incorporate my own styles into their components.

I prefer using the BEM methodology for CSS naming conventions when defining class names.

For example, if I have a <Menu /> Component and want to change its background, I would add a class

<Menu className="menu-header">
, where .menu-header has a different background-color property.

The issue arises because I can't modify it without using !important due to Semantic UI having higher priority. Their styles are more specific, utilizing multiple classes instead of just one like I intend to do. All styles are captured by webpack, and my .menu-header styles end up at the bottom of bundle.js - webpack output, below Semantic UI's. The .menu-header class is imported directly to my new component which uses

<Menu className="menu-header">
via CSS loader in webpack.

What can I do in this situation?

Some solutions I'm considering include modifying the core of Semantic UI entirely, but that doesn't fully resolve my issue. Every time I need to make a modification, I'd have to resort to using !important, which isn't ideal.

I've realized that inline JS styling in React holds the highest priority and can override Semantic UI styles. However, it's a bit more complex than what I currently use and may not be the best approach for a large application like the one I aim to develop.

Answer №1

It seems that the inclusion of !important in semantic-ui is causing some issues that may be considered a bug. I have encountered similar challenges, and one workaround I found is to utilize inline styles.

If you are facing this issue, you might want to explore using a tool like react css modules to assist with resolving it.

Answer №2

It doesn't seem feasible to me. A complete overhaul of semantic ui using the BEM methodology would be required.

For my part, I wouldn't consider employing it unless it adhered to BEM/SASS standards. I imagine many others feel the same way too.

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

Scrolling automatically to a DIV is possible with jQuery, however, this feature is functional only on the initial

I'm currently working on a Quiz site and I've encountered a puzzling issue. Since the explanation only appears after an answer is selected - essentially a "hidden" element, I decided to wrap that explanation into a visible DIV. The code I'v ...

How can I change the color of the Material UI Icons npm package within a React project?

Just diving into React and exploring the npm package Material UI icons (https://www.npmjs.com/package/@material-ui/icons) for displaying icons within my React components. Here's how I'm doing it: First, I import the icon like this: import Keyb ...

Exploring the realms of development and production with Next JS and Vercel

I've recently developed a movie database application using Next JS to explore its functionality. This app allows users to create, read, update, and delete data in Firebase by utilizing the API endpoints provided by NextJS. While the app works smoothl ...

Is there a way to stop mUI from displaying the dropdown menu once Chrome automatically fills in a user's address details?

I am currently developing a form for users to enter their address in order to collect a billing address for payment information. Our services are only available to customers within the United States, so we have implemented an autocomplete UI component with ...

Acquiring information in React using DynamicRoutes, nextJS, and the power of useEffect

I've got a blog link that is generated dynamically with a unique blog id. The Link function used here is a wrapper from Next.js. //link <h3 className="blogTitle"> <Link href="[blog]" as={props.item.postingId}>{props ...

Babylon entities failing to run

Encountering a strange issue in my current project. I am working on a react application that incorporates Babylonjs for 3D rendering. While I am able to successfully load objects into the scene, I am facing a problem when attempting to create a PBR Materia ...

Is there a way to implement a Lottie animation that plays on scroll in a React application?

I've been experimenting with Lottiefiles' interactive guide to understand how it works, but I'm having some trouble getting it to function properly in my React project. Below is the code I have tried so far. If you're interested, you ca ...

What is the process by which photoswipe applies styles to blur an image upon clicking the share button?

If you want to see an example, check out this link: http://codepen.io/dimsemenov/pen/gbadPv By clicking on the Share button, you'll notice that it blurs the image (and everything else). Despite inspecting it closely, I still can't seem to figu ...

Generating an array within the custom hook results in the value being re-rendered with each change in state

While working on a custom hook in react native, I ran into an issue with the combination of useEffect and useState that led to an infinite loop. To demonstrate the problem, I created a small snack: import React, { useEffect, useState, useMemo } from &apos ...

Changing the background color of MUI TextField for autocomplete suggestions

I am currently facing an issue with the background color of auto-complete fields in my React.js and Material UI app. https://i.sstatic.net/lZdDh.png The auto-complete fields are adding a white background which is unnecessary. Interestingly, when I manua ...

"Help needed: The HTML dialog element is obstructing the invisible reCAPTCHA challenge popup. Any solutions for resolving this

Visit this link to access the example in incognito mode. Click on the "open" button to open the sample signin form, then click on the "Sign Up" button to trigger the challenge. There seems to be an issue with using recaptcha inside a dialog. I'm not ...

Ways to keep the position of an expanded collapsible table from Material UI intact

I found a collapsible table code snippet on this website: https://mui.com/material-ui/react-table/#collapsible-table However, there seems to be an issue where when I expand a row, the table "grows up" as it increases in size. This behavior is not ideal. I ...

Utilizing React to manage state values for multiple input fields

As I embark on my journey with React, one of my initial tasks is to create a form with multiple input fields. These fields come with preset default values when the component loads and are meant to be editable. To generate these fields dynamically based on ...

Error encountered with Paypal code. Being redirected to error code 400

Hello everyone, I am currently working on creating a simple webpage and practicing how to integrate PayPal into our website. However, I seem to be encountering an issue where it is redirecting me to a 400 error page. Below is the code snippet that I have ...

Center align Bootstrap 4 dropdown menu

I am attempting to center align my dropdown menu using Bootstrap 4. Following the given example: [ This is the result I am achieving: [ This is the code I have implemented: <div class="container"> <div class="row"> <div class=" ...

Animating with CSS3 triggered by JavaScript

Can you help me with an issue I'm having? When attempting to rotate the blue square using a function, it only works once. After that, the page needs to be reloaded in order for the rotation function to work again. Additionally, after rotating 120 degr ...

Setting up material-ui with electron-react-boilerplate the right way

I am encountering difficulties using the material-ui (v4.9.5) library with electron-react-boilerplate. To replicate the issue: Follow the installation guide yarn add @material-ui/core Add some components from the library: diff --git a/app/components/Ho ...

What is the best way to apply a background-image to a DIV while also implementing a double line border to prevent the image from showing through the border?

Within my DIV, I have applied a background-image and added a double border to the DIV. The image is currently visible in between the lines. Is there a method to resolve this issue and prevent the image from displaying in this manner? ...

Encountering an issue after running the command 'npm start' following the execution of 'npx create-react-app my-app' while setting up a new react project

The version of Node installed is v12.18.2 and npm is 6.14.7 After completing all the steps and running 'npm start', I keep getting the same error consistently. This doesn't seem to be an issue with npm, despite what the error message indic ...

Typescript enhances React Native's Pressable component with a pressed property

I'm currently diving into the world of typescript with React, and I've encountered an issue where I can't utilize the pressed prop from Pressable in a React Native app while using typescript. To work around this, I am leveraging styled comp ...