Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styled-components and react-bootstrap?

Is there a way to use styled-components together with react-bootstrap? react-bootstrap exposes bsClassproperties instead of className for their component which seems to be incompatible with styled-components.

Any experiences?

like image 569
jpfollenius Avatar asked Aug 26 '17 12:08

jpfollenius


People also ask

Can you use styled-components with React Bootstrap?

Bootstrap Styled is a front-end ecosystem for React made with Bootstrap 4 philosophy, using the power of css-in-js thanks to styled-components. It offer a community an ecosystem of tools, components and variables to create standardized, sharable and highly customizable front-end modules.

Is styled-components better than Bootstrap?

Styled components is a hands down win if you will be implementing custom design or have a designer onboard. React Bootstrap library if you're happy with the look and feel of their components and do not plan to make many changes.

Is styled-components good for React?

Advantages of using Styled-components Below are some of benefits of using styled-components: Eliminates class name bugs: styled-components provide unique class names for your styles, thus eliminating the problems with class names duplications, misspellings, and overlaps.

Is styled component A React component?

styled-components utilises tagged template literals to style your components. It removes the mapping between components and styles. This means that when you're defining your styles, you're actually creating a normal React component, that has your styles attached to it.


1 Answers

You can extend the style keeping the original styles of the component from bootstrap. You will find more documentation on using third party libraries like react bootstrap with styled-components here.

const StyledButton = styled(Button)`   color: palevioletred;   font-size: 1em;   margin: 1em;   padding: 0.25em 1em;   border: 2px solid palevioletred;   border-radius: 3px; `; 

Here is a sandbox for reference: https://codesandbox.io/s/2vpm40qk90

like image 119
Agney Avatar answered Sep 23 '22 17:09

Agney