ponychicken
HOWTO: Adding Material Design Icons to tailwind in a Phoenix project
Hello!
Hero Icons are nice, but sometimes you might need an icon set with a larger set.
Material Design Icons are visually quite compatible (imo).
To add them efficiently to your Phoenix project without loading the whole icon font:
Add to mix.exs:
{:materialdesignicons,
github: "Templarian/MaterialDesign", sparse: "svg", app: false, compile: false, depth: 1},
Add to tailwindconfig.js
// Embeds Material Desing Icons into your main.css bundle
// See your `CoreComponents.icon/1` for more information.
plugin(function ({ matchComponents, theme }) {
let iconsDir = path.join(__dirname, "../deps/materialdesignicons/svg");
let values = {};
fs.readdirSync(iconsDir).forEach((file) => {
let name = path.basename(file, ".svg");
values[name] = { name, fullPath: path.join(iconsDir, file) };
});
matchComponents(
{
mdi: ({ name, fullPath }) => {
let content = fs
.readFileSync(fullPath)
.toString()
.replace(/\r?\n|\r/g, "");
let size = theme("spacing.6");
return {
[`--mdi-${name}`]: `url('data:image/svg+xml;utf8,${content}')`,
"-webkit-mask": `var(--mdi-${name})`,
mask: `var(--mdi-${name})`,
"mask-repeat": "no-repeat",
"background-color": "currentColor",
"vertical-align": "middle",
display: "inline-block",
width: size,
height: size,
};
},
},
{ values }
);
}),
That’s it! Use them with the classes mdi-ICONAME
Popular in Guides/Tuts
I thought I’d share a small project I’m working on to gain some familiarty with LiveView in a Phoenix app.
Github Repo
Deployment
It’s...
New
Typed my very first blog post ever, hope it will help some people
https://henricus.xyz/roll-your-own-email-password-authentication-with-...
New
I wrote a small article on how to use current_user with coherence on Phoenix. There are already a couple of blogposts about it but I thin...
New
Another cool plugin for Neovim, GitHub - jmbuhr/otter.nvim: Just ask an otter! 🦦 · GitHub makes it possible to run linters for embedded c...
New
I just published an article on creating Phoenix LiveView modals using Tailwind CSS and AlpineJS.
New
I’ve been working on a phoenix project lately and I wanted to use the latest versions of everything. Webpack 5 had some breaking changes ...
New
Just leaving some breadcrumbs for future me and future others like me.
Connect with TCP (not secured) - most servers will reject but use...
New
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
Hi everyone,
I recently implemented a real-time search feature in a Phoenix application using LiveView and Tailwind, and I wanted to sha...
New
I just finished a long process of configuring and debugging a Docker Compose-based dev environment. Several late-night hours! I think I’v...
New
Other popular topics
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode.
The solution seems to be, in a hyphena...
New
I have an umbrella app.
Some of the apps inside depend on other apps in the umbrella, unsurprisingly.
I’m writing a test for one of the...
New
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
New
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
Hello guys,
I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
Hey,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something…
Haskell reminds me of Java, and e...
New
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









