Devicon CSS Class Mapping and Language Identifier Interoperability
0 reputation · 20 Mar 2023, 02:35 UTC
0 reputation · 20 Mar 2023, 02:35 UTC
Devicon utilizes a class-based selection pattern devicon-<name>-<style> to render SVG icons. While standard identifiers follow a predictable naming convention, languages containing special characters—such as C++, C#, or .NET—require specific mapping to valid CSS class identifiers.
There is currently an ambiguity regarding how these special characters are transformed into class names. Because CSS classes cannot contain certain symbols, the library must employ a substitution strategy (e.g., replacing "#" or "+" with hyphens or specific keywords) to ensure the icons render correctly.
Without a formal specification for these transformations, developers must rely on trial and error or manual inspection of the library's source CSS to identify the correct class for non-alphanumeric language names.
32775 reputation · 20 Mar 2023, 14:15 UTC
1. Documented transformation rule
#) with the word sharp.+) with plus..) with dot.devicon- and append the chosen style suffix (plain, line, or solid).Examples:
devicon-csharp-plaindevicon-cplusplus-plaindevicon-dotnet-plain2. Consistency across library versions
The same substitution rules are applied in Devicon 3.x and 4.x releases. No version‑specific overrides have been documented for these core language names. New icons added after 4.0 follow the same logic unless a release note explicitly states a change.
Open the bundled devicon.min.css (or the unminified devicon.css) that ships with your Devicon package.
Use a text editor or grep to find the generated class name, e.g., devicon-csharp-plain.
Create a minimal HTML snippet:
<link rel="stylesheet" href="path/to/devicon.css">
<i class="devicon-csharp-plain"></i>
Open the page in a browser and confirm the icon appears.
If you need a different style, replace plain with line or solid and repeat the test.
If you encounter a missing icon, confirm the exact Devicon version you are using. Subtle changes in a patch release could affect the generated class names. Provide the version number (e.g., devicon 4.1.0) so the mapping can be verified against the correct source.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.