I'm currently styling my buttons using the following CSS with Bootstrap.
.btn-primary {
background-color: #229ac8;
background-image: linear-gradient(to bottom, #23a1d1, #1f90bb);
background-repeat: repeat-x;
border-color: #1f90bb #1f90bb #145e7a;
color: #ffffff;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
}
.btn-primary:hover, .btn-primary:active, .btn-primary.active, .btn-primary.disabled, .btn-primary[disabled] {
background-color: #1f90bb;
background-position: 0 -15px;
}
In React, I have created a button component like this:
const MyButton = ({children, onClick, classNames, ...rest }) =>
(
<button
onClick = {onClick}
className = {`${classNames}`}
{...rest}
>
{children}
</button>
);
Now, I need to change the button's color dynamically based on server data.
Question 1:
How can I apply inline styles to completely change the button's appearance?
Question 2:
Is it possible to utilize SCSS features like mixins in React to generate button styles based on a variable like color?
Question 3:
Should I opt for inline styles or use CSS-in-JS with classnames?
When creating a reusable component like a button, is it better to use a global class that can be reused across different instances or define local inline styles for each instance?