Enhancing the appearance of your website by incorporating external stylesheets and utilizing multiple class names through

Is it possible to use external CSS frameworks like Bootstrap, Semantic UI, or Foundation and still generate base64 class names? This could be achieved if there was a way to apply multiple class names.

Currently, you can only assign one class name like this:

import React, {Component} from 'react';
import style from './App.scss';
import styles from '../semantic/dist/components/button.min.css'

  render() {
    return (
      <div className="App">
        <div className={style.button}>Hello Webpack!!!</div>
    );
  }
}

I require the ability to apply multiple class names like so:

<div className={style.btn} + {style.red}>Hello Webpack!!!</div>

Is there a solution that allows me to utilize CSS frameworks and retain the base64 class names for styling?

TL;DR: I want to combine multiple class names from a file without the :local(...) syntax (as seen in Semantic UI) and maintain the base64 random class names when using them. While importing
../semantic/dist/components/button.min.css
enables me to use
className="ui red button"
effectively, importing as
Semantic from '../semantic/dist/components/button.min.css'
hinders me from utilizing
className={Semantic.ui + " " + Semantic.button}
.

Answer №1

Try utilizing the classnames npm package

import classNames from 'classnames'

render: <div className={classNames(style.red,style.btn)}>Hello Webpack!!!</div>

Answer №2

If you want to combine bootstrap with your own CSS styles, check out this helpful guide: Webpack Multiple CSS Loaders

For using multiple class names together, you can simply do it like this:

{style1} + {style2}: 
   className={
       styles.button + " " + styles.red
   }

Answer №3

Alternatively, you can use the following syntax: className={ [styles.button, styles.red].join(' ') }

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

Trouble retrieving Conversations on React Application due to incorrect token authentication in Axios GET request

In my React application, I am currently working on fetching a list of conversations for the logged-in user. While I have successfully achieved this using Postman on the production API, I am facing issues with the GET request in the API-connected front-end. ...

What are some ways to achieve a smoother hover effect?

.proposal p{ font-size: 14px; color: #494949; margin-bottom: 15px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; line-height: 20px; max-height: 100px; -webkit-line-clamp: 3; -webkit-box-orient: vertical; } .proposal: ...

Utilizing an external SCSS or CSS file with Material UI in React: A step-by-step guide

Encountering issues with external CSS files in my React project that uses Material UI components. Despite creating a CSS file for each component in the react components folder, they fail to load upon hard reloading the site. I prefer using external CSS ov ...

Sending a POST request to an external API using NextJs

I am a newcomer to Next.js and I am trying to figure out how to send a post request to an external API. Despite going through the documentation, I couldn't find any clear examples that could help me. Basically, I have an external endpoint for regist ...

Tips for adjusting the color of child elements when hovering over a card in Material UI

Having trouble changing the color of typography by hovering on a card? I tried many things, but finally decided to seek help here. When I remove the default color from typography and hover over the card, the text color changes as desired. However, I want t ...

The localhost on port 3000 seems to be malfunctioning on Windows when trying to develop a ReactJS app using Create React App

For the past few days, I have been encountering a few issues that I have been trying to resolve without success. I attempted to stop localhost:3000 with netstat -ano | findstr :3000 taskkill /PID myPIDhere /F Despite my efforts, I still see- TCP 0. ...

How can I make an image fill the container with CSS zoom effect

My website features a full viewport image as the background beneath the Nav Bar. I am looking to achieve a specific effect on mobile where the image is zoomed in and centered without distortion, allowing some of it to still be visible as a background. The ...

Exploring the plane intersection within a 3D object using Three.js

I attempted to create an animation using Three.js to display the intersection plane on a 3D object with the following code snippet: import React, { useRef, useEffect, useState } from 'react'; import * as THREE from 'three'; export cons ...

Custom React component with multiple accessors used as props in React-Table

While working with React-Table, I encountered a challenge: I am trying to utilize multiple accessors and pass those values as props to a custom component in order to display specific stats for each user in a modal. I understand that only a string or a fu ...

Enhancing the appearance of unvisited links with background styles

I am endeavoring to incorporate an icon into all unvisited links on a specific Wordpress category page. Below is the CSS code that I am utilizing. It has been placed at the conclusion of my final CSS file. .category-xyzzy .entry-title a:link { background ...

Using JavaScript in Node, you can pass an object by throwing a new Error

How can I properly throw an error in my node application and access the properties of the error object? Here is my current code: throw new Error({ status: 400, error: 'Email already exists' }); However, when I do this, I get the following outpu ...

Re-enable VueJS Devtools during the development process

While working in my homestead development environment, I decided to run the command npm run production to test if the vuejs devtools would disappear and make sure everything was functioning properly. Surprisingly, the devtools did vanish. Now, I am struggl ...

Issue: Module not found; Typescript error encountered in a react application

I have a load_routes.js file in the node_express folder that is responsible for loading all the routes for my project. Everything was working smoothly until I decided to change the file extension from .js to .ts. Suddenly, I started encountering the follow ...

Is there a way to position two forms next to each other in alignment?

I would like to display two forms side by side. Currently, I have one form shown here: http://gyazo.com/093efe95337ace40fe633adb88b76c2d. I want the same form to be displayed on the right-hand side as well. .comments-section .comment-form { padding: 20p ...

BS grid malfunctioning in a non-uniform manner

When a division in the advantage grid is clicked, the card body of another division collapses. However, this does not occur in the disadvantage grid. Clicking on one section in the disadvantage grid does not collapse another section as it does in the advan ...

"Exploring the functionalities of repeat and minmax in tailwind - a comprehensive guide

Hey there, I have a question about using repeat and minmax in grid with Tailwind CSS. I tried the following code but it didn't work as expected. const DetailedAssetCard = () => { return ( <div className=" bg-gray-100 rounded-lg grid ...

Looking for an open-source project that utilizes React along with Material-UI?

I've been on the lookout for an open source project on GitHub that incorporates React, react-router, and Material-UI, but my search hasn't turned up anything yet. I'm holding out hope that such a project exists, as it would greatly benefit m ...

What is the best way to show a filtered list using a state that was created with useState in React?

Check out my code in CodeSandbox, consisting of 4 divs categorized as "Book" and "Article". There are buttons at the top to toggle between displaying all divs, only books, or only articles. However, clicking on any button currently shows all divs and gives ...

How to bring in images from a local source in a React.js file

I've been looking into relative paths and absolute paths, but I'm having trouble importing local images correctly. My main objective is to create a React slideshow using these images. Why does it keep trying to find the images in the "components" ...

The webpage contains duplicate ID attribute value "x" that has been identified

In my Angular 7 project, three components (a, b, c) all use an input element with the same id of "x". However, component b has 4 input elements all using the id "x" as well. This poses Accessibility Issues as ids must be unique. The test cases utilize &apo ...