Skip to content

Instantly share code, notes, and snippets.

@somidad
Last active July 20, 2024 13:04
Show Gist options
  • Save somidad/7f4251097a5c4230aa548bee8edafa2e to your computer and use it in GitHub Desktop.
Save somidad/7f4251097a5c4230aa548bee8edafa2e to your computer and use it in GitHub Desktop.
CSS snippets for folder and file icons on Obsidian file explorer

How to:

  1. Visit https://lucide.dev/icons/
  2. Pick and click an icon you like
  3. Click 'Copy SVG' button
  4. Replace <svg ...></svg> with copied code
  5. Adjust size (width="24" height="24")
  6. Adjust stroke color (stroke="currentColor")
  7. Adjust margin-inline-start. It determines indentation level of file entry
  8. Adjust margin-right. It is space between icon and text

file-icon.css and folder-icon.css are snippets I use.

div.tree-item.nav-file > div.tree-item-self.nav-file-title::before {
content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="rgb(179, 179, 179)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-dot"><circle cx="12.1" cy="12.1" r="1"/></svg>');
margin-inline-start: -20px;
margin-right: 4px;
}
/* Folder icon when folder is closed */
div.tree-item-icon.collapse-icon.nav-folder-collapse-indicator.is-collapsed::before {
content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="rgb(179, 179, 179)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-folder"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></svg>');
}
/* Folder icon when folder is open */
div.tree-item-icon.collapse-icon.nav-folder-collapse-indicator:not(.is-collapsed)::before {
content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="rgb(179, 179, 179)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-folder-open"><path d="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"/></svg>');
}
div.tree-item-icon.collapse-icon.nav-folder-collapse-indicator > svg {
display: none;
}
@somidad
Copy link
Author

somidad commented Jul 20, 2024

It looks like:

스크린샷 2024-07-20 오후 10 01 12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment