Minimal TailwindCSS classes on standard opt-in menu #98
Replies: 1 comment 2 replies
-
Hi Marco—thanks for this! Just to confirm, your thinking is that there should be something more in terms of a built-in approach to menu styling and mobile menus? I agree that things are fairly barebones at present. My concern is always with pushing too far past reasonable defaults, leading to developers having code in their themes that they don't expect to be there and that ends up unused. That's why I ended up removing Alpine.js: While I use it for every project, not everyone who chooses _tw to add Tailwind to WordPress is going to want to use it, and that no doubt means a non-trivial number of websites loading Alpine.js and using nothing at all that it offers. I do want to document options for styling menus in a lot more depth. That's the biggest priority I have on the documentation side. In terms of boilerplate code for menus, I think I'd only add that if I were to build some kind of "pro" version of _tw. I would want it to be opt-in, and I would likely want options within the opt-in, and I don't want to add that kind of maintenance overhead to the existing generator. Hopefully that all makes sense! If I'm misunderstanding anything on your side, please let me know. |
Beta Was this translation helpful? Give feedback.
-
Hi Greg, first of all: awesome work and many many thanks for this amazing project. I think and hope it will become the standard (if it's not already) to scaffold a new WordPress theme.
My two cents: adding an opt-in class to the
wp_nav_menu
call, and adding some TW classes to that specific class only.So, for example:
And then, in the CSS file:
It's the bare minimum and perhaps not even decent, but it's a functional approach, and most of all, opt-in. For the mobile version it still requires a button to show the menu (in the example I am triggering it via AlpineJS, but you could do it via vanilla Javascript as well).
Beta Was this translation helpful? Give feedback.
All reactions