I'm going to bring in our first mixin from Radium. It's going to be Radium.StyleResolverMixin. Let's go ahead and output our component. It's our app. We'll put that in the document.body. Up here, inside of our render method...There's our button, nothing special.
Inside of our render method, I'm going to create a variable called "styles." It's going to be an object, just like normal CSS in React. I'm just going to paste in some style here. Again, no big deal. We are going to assign our style attribute to this.buildStyles. We're going to pass that our styles variable. We'll load that up in the browser.
You can see we've got our style, again, very similar to what you're probably used to with React. Getting to some of the interesting stuff here, we're going to create a key in our styles called "modifiers." It's going to be an array. We're going to have an object here with a key of kind. That's going to be like our attribute on our component.
We're going to have another object here. Each of these keys is going to be the value that we can pass in for our attribute, and then we're just going to create a new style. Here, I'm going to say "background." If it's primary, it's going to be green. I'll create one more. I'm going to call this one "warning." We'll make that background red.
Now we can come down to our component. We can pass in the kind attribute and then pass in the kind value. We're going to say, "warning." Now our button is red. If we say "primary," now our button is green. That's how modifiers work from the StyleResolverMixin.
Each of those elements is going to be an object. The key is going to be our state. In this case, I'm saying, "hover." I'm passing in my new style. I'm going to say the background is black. Create one more of these for focus.
Here, I'm going to say my background is pink. I'm going to get rid of the ugly outline. Since our background is pink, we're going to make our color black. The way we get to this is by using the JSX spread operator. We can just pass it in so that our button will inherit these properties. this.getBrowserStateEvents is the method from our mixin.
We'll go ahead and save that, load it up over here. Now, when we hover, we've got our black background. When we select it, focus it, we've got our pink background with our black text. That is a quick look at Radium.