Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to define CSS files in React-Bootstrap?

Defining custom css for a class got me confused.

The React-Bootstrap documentation says, you can define a custom non-bootstrap style by using bsClass.

But, here are my doubts:-

  1. Do we need to include the custom stylesheet link in the entry html page?
  2. If no, then how is node environment, able to recognise where are the css files located?
like image 356
Aseem Upadhyay Avatar asked Dec 10 '25 04:12

Aseem Upadhyay


1 Answers

how is node environment able to recognize where are the css files located?

You need to add it to your page manually.

One approach (if you use webpack and have css-loader plugin installed, which is by default for react-create-app) is to include your .css file inside a component that needs specific stylesheet:

import './mystylesheet.css'

So your component will look something like this:

import React from 'react'
import { Button } from 'react-bootstrap'
import './mystylesheet.css'

export default function MyCustomButton(props) {
  return <Button bsClass="my-custom-class">My button</Button>
}
like image 130
AlexM Avatar answered Dec 12 '25 17:12

AlexM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!