Buttons Custom Styling

So you have a bunch of Buttons and the built in color options just aren't cutting it. You want to get a little fancier with Button styles. This tutorial will show you how.

1. Change Default Button Styles

Style Settings

The most straightforward way to update how a default button looks is to use the Style Settings plugin. This plugin is awesome and provides a visual editor for styles. I've specifically built in support for Style Settings into Buttons. Once installed and enabled you should see the following options:

style-settings.png
Changing these settings will update the styles for all buttons in your vault.

Override .default-button class

Default styling is applied to Buttons using the .default-button class. You can override values in that class using your own CSS tweak.

2. Individual Button Styling

By adding a class attribute to a button you can write custom CSS styles for that button. Here's a step-by-step guide.

  1. Add class to the button you would like to style:

classy-button.png
You can also supply a class when making a Button with the Button Maker:
button-maker-class.png
2. Open Obsidian Settings > Appearance and ensure Apply Custom CSS is toggled on:

custom-css.png
Locate your CSS Snippets folder and create a new file called custom-buttons.css. You can click the little folder icon to open the CSS Snippets folder:

css-snippets.png
3. Open custom-buttons.css in a text editor (I like VS Code) and add your custom class and CSS styling to the file. Then Save.

.classy-button {
    background-color: rebeccapurple;
}
  1. Go back into Settings > Appearance. Click the reload snippets button and then enable the custom-buttons snippet.

buttons-snippet-enabled.png

3. Multiple Classes

The last thing you need to know is that a button can have multiple classes listed. When you supply a custom class to a Button it strips all the default styling. If all you want is a different background color, this can be annoying. You can re-add the default styles by adding button-default to the class argument:

multi-class.png
What happened to our custom color? The styles in button-default is overriding the background color. To fix this, we can add !important to our custom styles:

.classy-button {
    background-color: rebeccapurple !important;
}

And our button should look like:

classy-preview.png

Conclusion

Hope this helps in getting your Buttons looking perfect. If you spot any errors in the instructions, or have a question. Hit me up on discord @shabegom

buttons-custom-styling
Interactive graph
On this page
Buttons Custom Styling
1. Change Default Button Styles
Style Settings
Override .default-button class
2. Individual Button Styling
3. Multiple Classes
Conclusion