ironbar/docs/Styling guide.md
Jake Stanger dea66415c2
feat: module-level name and class options
BREAKING CHANGE: To allow for the `name` property, any widgets that were previously targeted by name should be targeted by class instead. This affects **all modules and all popups**, as well as several widgets inside modules. **This will break a lot of rules in your stylesheet**. To attempt to mitigate the damage, a migration script can be found [here](https://raw.githubusercontent.com/JakeStanger/ironbar/master/scripts/migrate-styles.sh) that should get you most of the way.

Resolves #75.
2023-05-06 13:22:35 +01:00

2.0 KiB

Ironbar ships with no styles by default, so will fall back to the default GTK styles.

To style the bar, create a file at ~/.config/ironbar/style.css.

Style changes are hot-loaded so there is no need to reload the bar.

Since the bar is GTK-based, it uses GTK's implementation of CSS, which only includes a subset of the full web spec (plus a few non-standard properties).

The below table describes the selectors provided by the bar itself. Information on styling individual modules can be found on their pages in the sidebar.

Selector Description
.background Top-level window.
#bar Bar root box.
#bar #start Bar left or top modules container box.
#bar #center Bar center modules container box.
#bar #end Bar right or bottom modules container box.
.container All of the above.
.popup Any popup box.

Every widget can be selected using a kebab-case class name matching its name. You can also target popups by prefixing popup- to the name. For example, you can use .clock and .popup-clock respectively.

Setting the name option on a widget allows you to target that specific instance using #name. You can also add additional classes to re-use styles. In both cases, popup- is automatically prefixed to the popup (#popup-name or .popup-my-class).

You can also target all GTK widgets of a certain type directly using their name. For example, button:hover will select the hover state on all buttons. These names are all lower case with no separator, so MenuBar -> menubar.

GTK CSS does not support custom properties, but it does have its own custom @define-color syntax which you can use for re-using colours:

@define-color color_bg #2d2d2d;

box, menubar {
    background-color: @color_bg;
}