
#Button color ui how to#
I also show how to minimize the amount of code. I am going to show how selectors can be used in the sx prop to get really specific. It’s also possible to create a custom variant in MUI 5. Contained is the only variant with shadow. There are three commonly used button variants: text, contained, and outlined. You can set the value to any of the color scales from your design system, like whiteAlpha, blackAlpha, gray, red, blue, or your custom color scale. The sx prop impressed me while I was testing it out it can do everything the previous styling syntax could do, there are some new shortcuts, and there’s a lot less boiler-plate code. Button Colors Use the colorScheme prop to change the color scheme of the Button. The sx prop is new in MUI 5 and replaces the makeStyles hook syntax. Button size should reflect the priority of this element on the screen. I used it in the previous section because it is the fastest way to style the Button. A potentially dangerous action ‘Disable card’ is colored in red in this interface. If you need to style a Button in just one place (or a few), you might want to style using the sx prop.

Set Button Color By Variant With The MUI SX Prop I usually don’t use this prop because it only changes background color, and it only accepts string values of ‘primary’, ‘secondary’, and other theme palette field names. Button Colors Inspirational designs, illustrations, and graphic elements from the world’s best designers.

and secondary color variables in site.variables will allow you to use your color theming for UI elements. The Button component also has a color prop. A button indicates a possible user action.
