You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ui/icons-and-styling.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -149,6 +149,23 @@ Tips for theme compatibility:
149
149
150
150
## Custom CSS
151
151
152
+
### Namespace Your Class Names
153
+
154
+
Unraid's core pages use common class names with unscoped jQuery selectors. If your plugin uses the same class names, Unraid's JavaScript may inadvertently modify your elements, causing visual glitches.
155
+
156
+
Always prefix your CSS classes with your plugin name:
157
+
158
+
| Generic (avoid) | Namespaced (use) |
159
+
|-----------------|------------------|
160
+
|`.sortable`|`.myplugin-sortable`|
161
+
|`.updatecolumn`|`.myplugin-updatecolumn`|
162
+
|`.container`|`.myplugin-container`|
163
+
|`.status`|`.myplugin-status`|
164
+
165
+
This is especially important when adding tabs to existing Unraid pages like the Docker menu, where your tab's DOM shares the page with Unraid's JavaScript.
When your plugin adds a tab to an existing Unraid page (like adding a tab to the Docker menu), your JavaScript runs in the same context as that page's JavaScript. Unscoped selectors can accidentally target elements from the parent page, causing visual glitches or broken functionality.
583
583
584
-
Common classes like `.auto_start`, `.advanced`, `.basic`, and `.updatecolumn` are used by multiple Unraid pages. jQuery plugins like `switchButton` should never be re-initialized on elements that are already set up.
584
+
Common classes like `.auto_start`, `.advanced`, `.basic`, `tr.sortable`, and `.updatecolumn` are used by multiple Unraid pages. jQuery plugins like `switchButton` should never be re-initialized on elements that are already set up.
585
585
586
586
```javascript
587
-
// BAD - Selects ALL .auto_start elements on the page
588
-
// If Docker tab already initialized these, you'll break them
> The Docker tab uses unscoped selectors like `$('tr.sortable')` and `$('.updatecolumn')`. If your plugin uses these same class names, clicking "Check for Updates" on Docker will animate *your* plugin's rows too. See [Namespace Your CSS Classes](#namespace-your-css-classes) below.
603
+
602
604
For elements added to shared areas (like the tab bar), use plugin-specific class names:
See [Tab Pages - Adding Tabs to Existing Pages](tab-pages.md#adding-tabs-to-existing-pages) for more details.
620
+
See [Tab Pages - Adding Tabs to Existing Pages](tab-pages.md#adding-tabs-to-existing-pages) and [Icons and Styling - Namespace Your Class Names](icons-and-styling.md#namespace-your-class-names) for more details.
621
+
622
+
### Namespace Your CSS Classes
623
+
624
+
Even with scoped selectors in your own code, Unraid's core pages use unscoped selectors that will match your elements if you use common class names. The only reliable solution is to use plugin-specific class names.
625
+
626
+
Classes to avoid (used by Docker tab with unscoped selectors):
627
+
-`sortable` - Used for drag-to-reorder rows
628
+
-`updatecolumn` - Update status column
629
+
-`ct-name` - Container name cells
630
+
631
+
```html
632
+
<!-- BAD - Docker's JavaScript will target these rows -->
633
+
<trclass="sortable"id="stack-row-1">
634
+
<tdclass="ct-name">My Stack</td>
635
+
<tdclass="updatecolumn">not checked</td>
636
+
</tr>
637
+
638
+
<!-- GOOD - Unique class names prevent cross-tab interference -->
For elements that need to be globally unique (like an Advanced View toggle in the tab bar), use plugin-specific class names:
240
+
Even with scoped selectors in your own code, Unraid's core pages use **unscoped selectors** that will still match your elements. For example, the Docker tab's JavaScript uses `$('tr.sortable')` and `$('.updatecolumn')` without scoping to its own container. If your plugin uses these class names, Docker's "Check for Updates" button will animate your plugin's rows too.
241
+
242
+
The only reliable solution is to use plugin-specific class names:
243
+
244
+
```html
245
+
<!-- BAD - Docker's unscoped JavaScript will target these -->
246
+
<trclass="sortable">
247
+
<tdclass="updatecolumn">not checked</td>
248
+
</tr>
249
+
250
+
<!-- GOOD - Unique class names prevent cross-tab interference -->
251
+
<trclass="myplugin-sortable">
252
+
<tdclass="myplugin-updatecolumn">not checked</td>
253
+
</tr>
254
+
```
255
+
256
+
For elements added to shared areas (like an Advanced View toggle in the tab bar), always use plugin-specific class names:
241
257
242
258
```javascript
243
259
// BAD - may conflict with Docker tab's advancedview toggle
@@ -272,4 +288,5 @@ function loadMyPluginContent() {
272
288
273
289
-[Page Files]({% link docs/page-files.md %})
274
290
-[Form Controls]({% link docs/ui/form-controls.md %})
275
-
-[JavaScript Patterns]({% link docs/ui/javascript-patterns.md %})
291
+
-[JavaScript Patterns]({% link docs/ui/javascript-patterns.md %}) - See "Scope Your Selectors" and "Namespace Your CSS Classes"
292
+
-[Icons and Styling]({% link docs/ui/icons-and-styling.md %}) - See "Namespace Your Class Names"
0 commit comments