## Symbolic icon format GTK has been using a simple subset of SVG for symbolic, recolorable icons for a long time. This document is an attempt to describe the format that we use. Note that support for strokes, and style classes other than "success", "warning" and "error" has been added in GTK 4.20 and GTK 3.24.50. ### Allowed primitives We use `path`, `circle` and `rect` elements as graphics primitives. They may be grouped with `g` elements, but those are otherwise ignored. ### Supported attributes The `d` attribute is required on `path` elements, to specify the path. The `cx`, `cy` and `r` attributes are required on `circle` elements. The `x`, `y`, `width` and `height` attributes are required on `rect` elements. These attributes are allowed on `path` elements: - `fill`: ignored. The fill is determined based on the `class` attribute - `stroke`: ignored. The stroke is determined based on the `class` attribute - `class`: the symbolic part of symbolic icons. This can contain one of the following classes to determine the symbolic fill color: "success", "warning", "error", "success-fill", "warning-fill", "error-fill", "foreground-fill", "transparent-fill". The first 3 classes are the originally supported values, they have been duplicated with a -fill suffix for consistency. Any element that does not have one of these classes set is filled using the foreground color. The `class` attribute can also contain one of the following classes to determine the symbolic stroke color: "foreground-stroke", "success-stroke", "warning-stroke", "error-stroke". Any element that does not have one of these classes is not stroked. - `opacity`: overall opacity - `fill-opacity`: opacity for filled paths, in addition to the symbolic color alpha - `stroke-opacity`: opacity for stroked paths, in addition to the symbolic color alpha - `fill-rule`: the fill rule used when filling - `stroke-width`: line width used when stroking - `stroke-linecap`: the line cap value used when stroking - `stroke-linejoin`: the line join value used when stroking - `stroke-miterlimit`: the miter limit value used when stroking - `stroke-dasharray`: the dash array used when stroking - `stroke-dashoffset`: the dash offset used when stroking - `style`: ignored - `id`: ignored - `color`: ignored - `overflow`: ignored Note that when a full SVG renderer is used to render symbolics, other attributes or elements may have an effect. But you should not rely on that. GTK may use its own parser for this subset of SVG, and ignore everything else. ### Styling The effective style that is used for recoloring is the following: ``` path,.foreground-fill { fill: !important; } .warning,.warning-fill { fill: !important; } .error,.error-fill { fill: !important; } .success,.success-fill { fill: !important; } .transparent-fill { fill: none !important; } .foreground-stroke { stroke: !important; } .warning-stroke { stroke: !important; } .error-stroke { stroke: !important; } .success-stroke { stroke: !important; } ``` ### Example icon Here is a silly example, just to demonstrate some of the possibilities: ``` ```