Extend Styles
Smooth UI’s power lies in its ability to easily extend components’ styles.
Use system props
System props are probably the easiest way to extend a component.
For example, you can define the width of a button:
See system props documentation to learn how to use it.
Local override using style
Inline styles are still a good approach for a lot of use-cases. They can be used for very specific changes that don't need media queries or auto-prefixer. All components supports inline style using style
property.
An example of inline style to change the padding
of a button:
Override values in theme
To extend style, the cleanest way is probably to use the theming feature of Smooth UI. It allows you to change global settings that will impact all components.
Example of possible changes using theme:
- Modify
primary
color - Modify breakpoints
- Modify form control margins
- Modify the focus glow on controls
- ...
For example, you can change the primary color:
See theming documentation to learn how to use theme.
Override components style in theme
All components can be overrided directly in the theme.
In the following example, the alert is now just something colored in red
:
Hello world
See theming documentation to learn how to use theme.
css
prop
Local override using Styled Components and Emotion both support the css
property. This is a simple method to extend component style.
<Buttoncss={css`font-size: 20px;`}>A customized button</Button>
Local extend using styled
You can override any CSS property of the original component using styled
. It creates a new component and doesn't affect other components.
An example of a BorderedButton
extended from a Button
:
Extend components deeply
Some components are more complex than a Button
. The Switch
for example is a component that includes several elements: a container, a ball... All of these elements have their own classes. To extend it, just use the browser inspector, pick the class and override it 👌.
An example of a custom Switch
with a black ball 🎱.