"Enhance the appearance of bootstrap buttons by applying CSS to add shadow and border when the

Working on a frontend project using the React framework and Bootstrap 5.3 for design.

Noticing that shadows are deactivated in Bootstrap by default, which means buttons don't display shadows when active as per the Bootstrap v5.0 documentation.

Link to Bootstrap Buttons Documentation

Struggling to figure out how to customize individual buttons directly in the code. Is it possible to add a style tag to the button or use a label tag in grouped buttons to activate this shadow effect?

style={{*adding CSS magic here*}}

Below is sample code for three buttons where I want to apply this shadow effect like in v5.0:

<div className="row">
  <h4>Choose buffer</h4>
</div>
<div className="row">
  <div className="col-sm-4 p-3 d-flex justify-content-center">
    <input type="radio" className="btn-check" name="chooseBuffer" id="buffer1" autoComplete="off" onClick={() => measurementConfig.buffer = 1 } />
    <label className="btn btn-lg btn-warning" htmlFor="buffer1"><span className="bi-database-add"></span>&nbsp;Buffer 1</label>
  </div>
  <div className="col-sm-4 p-3 d-flex justify-content-center">
    <input type="radio" className="btn-check" name="chooseBuffer" id="buffer2" autoComplete="off" onClick={() => measurementConfig.buffer = 2 } />
    <label className="btn btn-lg btn-success" htmlFor="buffer2"><span className="bi-database-add"></span>&nbsp;Buffer 2</label>
  </div>
  <div className="col-sm-4 p-3 d-flex justify-content-center">
    <input type="radio" className="btn-check" name="chooseBuffer" id="buffer3" autoComplete="off" onClick={() => measurementConfig.buffer = 3 } />
    <label className="btn btn-lg btn-info" htmlFor="buffer3"><span className="bi-database-add"></span>&nbsp;Buffer 3</label>
  </div>
</div>

Appreciate any help on this matter!

Answer №1

To style the label directly following a selected radio input, apply this CSS snippet:

input[type="radio"]:checked+label.btn {
   border: 1px solid #000; //customize border or shadow as needed
}

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 is the best way to integrate a React component library that relies on Styled Components with another library that also has a dependency on Styled Components?

After recently converting my internal component library to Styled Components, I encountered an issue with duplicate instances of 'styled-components' in my Create React App (CRA) project. Both the component library and the CRA application are impo ...

Raycasting for collision detection is not very precise

I am facing a challenge in my project where I have multiple irregular shapes like triangles, trapezoids, and other custom designs in a 2D scene all located on the Y=0 axis. I am currently working on writing code for collision detection between these shapes ...

What is the best way to incorporate responsive centered text into my HTML element using Bootstrap 4?

Is there a way to add a responsive centered text element to my <a> element without being affected by the overlay color? Also, is there an alternative method to using an extra overlay div in Bootstrap 4? Check out this link for more details. HTML & ...

Organizing ToggleButtonGroup in Material Ui: Creating a Grid Layout with 2 Rows and 2 Columns

When using grid within toggle buttons, the OnChange event does not work The event works fine when using Grid or Stack How can I arrange 2 by 2 buttons? I'm unable to find any example of this on the material ui website Could someone please offer as ...

Encountered difficulties while attempting to set up React.js

Why am I encountering difficulties installing React? I managed to create a node module file, but it is being automatically deleted. I ran the command npx create-react-app my-app. Below is a screenshot. Aborting installation. npm install --no-audit --save ...

Animating Font Awesome content through CSS transitions

I am looking to animate a font awesome pseudo element on my website. Below is the HTML code I am working with: <li class="has-submenu"> <a onclick="$(this).toggleClass('open').closest('.has-submenu').find('.submenu&a ...

Position the final offspring adjacent to the one that came before it using Flexbox

I am trying to figure out how to position the last child (CVV) next to the previous one (Expiry), so they are on the same row: .form-col-1--cc { display: flex; flex: 30%; flex-direction: column; text-align: right; align-items: flex-end; } < ...

When using express and passport-local, the function `req.isAuthenticated()` will typically return a

I'm seeking some insight into my current situation. I've noticed that whenever I call req.isAuthenticated() in an app.router endpoint, running on port 3001 via the fetch API, it always returns false. It seems like the connect.sid is not being pro ...

Node.js is raising an error regarding strict mode, despite the fact that Babel 6 preset es2015 is being used, which

When working with node js, I encountered an error message stating uncaughtException: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode, despite using babel 6 es2015 preset which should include use strict. My pro ...

Flex column MUI Data Grid with minimum width to fit content

I am currently working with the MUI Data Grid under an MIT license. My columns are configured as flexible to make use of the available width. However, I want the table to have overflow capabilities for instances where it's resized too small. For ins ...

Ant Design Input: The frustrating issue of losing focus when changing input

Dealing with a form wrapped by a Security component can be challenging as it ensures that users without specific permissions cannot access it. However, one issue I have encountered is the loss of focus on the input field with each keystroke. <Security ...

Error: It seems that in your next.js + expo project, you may have overlooked properly exporting your component from its defined file, or there could be confusion between default and named imports

Whenever I attempt to execute yarn ios, the following error message appears: An issue arose with the element type, as it is invalid. The expected input should be a string for built-in components or a class/function for composite components, yet it receive ...

Unforeseen truncation issues within a table causing ellipsis to appear unexpectedly

I'm facing an issue with truncating text inside a table, and it's not working as expected. Can someone help me understand what I might be doing wrong? Edit: I need to ensure that the table width remains max-width: 100%; <script src="http ...

How can I set a value using document.getElementById(idPopUPImage).innerHTML to create a static popup in Leaflet?

I added a leaflet map to my project which you can find on Codpen In the map, I've included a button key that displays an image in a popup when clicked. However, after closing the popup and reopening it, the image doesn't show unless I click the ...

I am experiencing difficulty with aligning my input boxes to the center in my React-Native

Just a heads up, this is my first time diving into the world of React Native, so bear with me as I try to figure things out. Please be kind if my question seems silly... Here's a snapshot of what I currently have: https://i.stack.imgur.com/VWGFm.png ...

Fill a JavaScript array with values inserted in the middle position

I'm having trouble populating an array: var arr2 = ["x", "y", "z"]; I want to insert a random number/value between each original value using a for loop, like this: for (let i = 1; i < arr2.length; i+2) { arr2.splice(i, 0, Math.random()); } B ...

Displaying dates in Material UI datepicker is not working

My current setup involves using Material UI v14.4 with React, and I have encountered an issue with the DatePicker component not displaying the dates correctly as shown in the attached screenshot. Strangely, there are no visible error messages either. Any s ...

The React callback is failing to update before navigating to the next page

I'm facing an issue that seems like it can be resolved through the use of async/await, but I am unsure of where to implement it. In my application, there are three components involved. One component acts as a timer and receives a callback from its pa ...

The art of efficient state management in React: Which reigns supreme - useEffect or

I am curious about the best practices for utilizing useEffect and determining when it should be used to manage state changes. For instance, suppose I have a button that will trigger an email to be sent on the 5th click (pseudo code as I have not actually ...

Arranging elements in a Material-UI card in a horizontal layout

I am currently working on designing a user profile display. I want to create a card layout that showcases the details listed below. My goal is to have these items displayed side by side instead of being divided as shown in the image. Despite trying to giv ...