Skip to content

Commit 3ed0578

Browse files
committed
Add example of overriding an icon.
1 parent b6e9804 commit 3ed0578

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed
Loading
Loading

Sources/DocCDocumentation/DocCDocumentation.docc/customizing-your-documentation-appearance.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,47 @@ borders](theme-screenshot-05.png)
151151
![A screenshot of a documentation page with custom code listing and aside border
152152
styles](theme-screenshot-07.png)
153153

154+
### Icons
155+
156+
It is also possible to use `theme-settings.json` to specify custom icons to use
157+
in place of the default ones provided by DocC-Render. There are a few basic
158+
steps to follow in order to override an icon:
159+
160+
1. Find the identifier that maps to the icon you want to override.
161+
2. Add this value as an `id` attribute to the new SVG icon.
162+
3. Associate a relative or absolute URL to the new SVG icon with the identifier
163+
in `theme-settings.json`.
164+
165+
> Note:
166+
> You can find all the possible identifier values for every valid icon kind in
167+
> the Open API [specification][1] for `theme-settings.json`.
168+
169+
**Example**
170+
171+
As a simple example, here is how you could update the icon used for articles in
172+
the sidebar to be a simple box:
173+
174+
1. Find the identifier for article icons: `"article"`
175+
2. Add the `id="article"` attribute to the new SVG icon: `simple-box.svg`
176+
```svg
177+
<svg viewBox="0 0 14 14" xmlns="http://www.w3.org/2000/svg" id="article">
178+
<rect x="2" y="2" width="10" height="10" stroke="currentColor" fill="none"></rect>
179+
</svg>
180+
```
181+
3. Configure `theme-settings.json` to map the URL for the new article icon
182+
```json
183+
{
184+
"theme": {
185+
"icons": {
186+
"article": "/images/simple-box.svg"
187+
}
188+
}
189+
}
190+
```
191+
192+
![A screenshot of the sidebar using a custom icon for
193+
articles](theme-screenshot-08.png)
194+
154195
### Metadata
155196

156197
You can specify some text that will be used in the HTML `<title>` element for

0 commit comments

Comments
 (0)