TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Building React and Vue Support for Tailwind UI

286 pointsby shayac2about 4 years ago

16 comments

brundolfabout 4 years ago
&gt; We crawl this document as an AST, and actually transform it into four formats...The key to getting sensible output is really just having total control of the input format. It&#x27;s still hard work, but when you can encode the intent of each example into a custom input format, converting that to another format turns out so much better than trying to write something that can convert arbitrary jQuery to React or something.<p>One tends to think of parsing&#x2F;compiling as a fairly esoteric skillset that a relatively small number of programmers ever actually need at their jobs, but it always makes me glad to see examples like this where a little DSL was a genuine boon to productivity in a real product. Once you know how to do it, you start to notice more and more little opportunities where it could be useful.
评论 #26788455 未加载
评论 #26785445 未加载
评论 #26785474 未加载
mike1o1about 4 years ago
Tailwind and Tailwind UI are really great. Tailwind UI as a series of blueprints is exactly what I&#x27;m looking for and I love how often they&#x27;re updating and adding new blueprints to their list of components.<p>This part from the blog post kind of confused me a bit, though.<p>&quot;The promise of Tailwind UI is that it&#x27;s just a code snippet&quot;<p>Am I the only one who never looks at the code snippets&#x2F;tab for Tailwind UI, and instead jumps straight into inspect element? As blueprints the components are great, but I almost always want to make some small tweaks or changes to fit my application. Are there other people out there actually copying&#x2F;pasting the snippets as they are?
评论 #26785610 未加载
评论 #26785560 未加载
评论 #26785603 未加载
评论 #26786996 未加载
welderabout 4 years ago
This is so ugly and error prone:<p>&lt;Button className=&quot;bg-gray-100 rounded-full flex&quot; ...<p>How do you remember the names of all your classes? Should your IDE know about these classes? Can you autocomplete class names? Where&#x27;s the import statement for these classes so you know where they&#x27;re defined and what they do. There&#x27;s a better way:<p>Use site-wide themes (Objects with keys like colors.heading.primary having value &#x27;#000&#x27;) and withStyles[1] and React.PureComponent[2]. Having your React component render the same result given the same props and state makes things so much easier to work with. Also, the compiler knows about your theme so your IDE helps auto-complete and makes sure the style you&#x27;re using is actually defined.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;airbnb&#x2F;react-with-styles" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;airbnb&#x2F;react-with-styles</a><p>[2] <a href="https:&#x2F;&#x2F;reactjs.org&#x2F;docs&#x2F;react-api.html#reactpurecomponent" rel="nofollow">https:&#x2F;&#x2F;reactjs.org&#x2F;docs&#x2F;react-api.html#reactpurecomponent</a>
评论 #26786131 未加载
评论 #26786050 未加载
评论 #26785972 未加载
评论 #26789890 未加载
评论 #26785984 未加载
willhoyleabout 4 years ago
This is great work, congrats on shipping a great product. I use TailwindCSS on my personal website.<p>I often wonder whether we need yet another UI framework implementation? I touched on this in my post a couple days ago: <a href="https:&#x2F;&#x2F;williamhoyle.ca&#x2F;blog&#x2F;2021&#x2F;vue-has-too-many-ui-frameworks" rel="nofollow">https:&#x2F;&#x2F;williamhoyle.ca&#x2F;blog&#x2F;2021&#x2F;vue-has-too-many-ui-framew...</a><p>To summarize:<p>We have 20+ UI frameworks written in Vue. Surely there&#x27;s enough common ground&#x2F;code to combine the implementation details for all these common components. For example, OP mentioned the complexities of implementing a modal with some corner cases for &#x27;ESC&#x27; behaviour. This is a universal concept whether you&#x27;re using WidgetUI or TailwindUI. How many times are we going to re-implement a modal&#x2F;button&#x2F;dialog&#x2F;menu?<p>We have to learn another set of APIs, props, component names, etc... Of course, no one is forcing us to use this. But it seems like we&#x27;re going in circles re-implementing the same UI patterns over and over again.<p>I wish we could standardize on a library. Imagine just pulling in GenericUI and sprinkling in your CSS of choice (e.g. tailwindCSS, Bulma, Material, etc...).<p>I&#x27;m a Vue guy, but I think my argument still stands for the React ecosystem.
评论 #26787714 未加载
评论 #26789626 未加载
评论 #26791135 未加载
评论 #26788305 未加载
评论 #26790057 未加载
AlchemistCampabout 4 years ago
It would be great to see AlpineJS as a first class option here, especially since it&#x27;s already there in the source for the examples.
brianzelipabout 4 years ago
What an effing great article. Not only for the clarity and care behind the writing, but also for useful links like [0].<p>Adam&#x27;s (author) podcast Full Stack Radio is useful like this too [1].<p>[0] <a href="https:&#x2F;&#x2F;www.w3.org&#x2F;TR&#x2F;wai-aria-practices&#x2F;examples&#x2F;menu-button&#x2F;menu-button-links.html" rel="nofollow">https:&#x2F;&#x2F;www.w3.org&#x2F;TR&#x2F;wai-aria-practices&#x2F;examples&#x2F;menu-butto...</a><p>[1] <a href="https:&#x2F;&#x2F;fullstackradio.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;fullstackradio.com&#x2F;</a>
评论 #26790385 未加载
ssijakabout 4 years ago
Or just use something like Chakra UI, which is like Tailwind CSS but based on styled system and built with Typescript for React from the beginning and has a nice set of basic components.<p>I even built something like Tailwind UI but for Chakra (link is in my bio if you want to check it out)
评论 #26785691 未加载
评论 #26785683 未加载
评论 #26789002 未加载
评论 #26785531 未加载
评论 #26790097 未加载
rwieruchabout 4 years ago
Super interesting to read this. Especially how you eventually bridged HTML to React&#x2F;Vue. Thanks for sharing!<p>One year ago I had to do something similar and used Web Components (<a href="https:&#x2F;&#x2F;www.robinwieruch.de&#x2F;react-web-components" rel="nofollow">https:&#x2F;&#x2F;www.robinwieruch.de&#x2F;react-web-components</a>). Did you consider using Web Components or a Web Components library such as lit-html in the first place?
CapriciousCptlabout 4 years ago
Well this completely deprecates my personal react&#x2F;tailwindui library starting on tax day. I guess that’s good!
评论 #26785528 未加载
pansa2about 4 years ago
I&#x27;m currently using Tailwind CSS to style a fairly simple static website that&#x27;s being generated using Hugo. I&#x27;ve been considering using some Tailwind UI components, e.g. modals (in particular, lightboxes to show zoomed-in versions of images).<p>I assumed that I would use Tailwind UI&#x27;s HTML for these and write vanilla JS for interactivity, but now I am rethinking, especially having read this quote in the article: &quot;If we tried to write it in custom vanilla JS, well we&#x27;d be making it harder for literally everyone&quot;.<p>So given this announcement, in my situation would you recommend against vanilla JS, and instead to adopt one of React or Vue?
评论 #26787873 未加载
franciscopabout 4 years ago
Ah I&#x27;m not a huge fan of this:<p><pre><code> &lt;Menu.Items className=&quot;absolute mt-1 right-0&quot;&gt; </code></pre> I&#x27;d prefer it to be like this:<p><pre><code> &lt;Menu.Items absolute mt-1 right-0&gt; </code></pre> I did some experimenting (I&#x27;m the owner of `react-tailwind`, please reach out if you want it!) and it&#x27;s definitely possible to do that; but it does imply components are purely visual, which I&#x27;m not sure it&#x27;s the way they want to go. It&#x27;s also not possible to use the colon like `md:...`, but you can do `md=&quot;...&quot;` instead, which is a good approximation IMHO
评论 #26785731 未加载
评论 #26785660 未加载
评论 #26788166 未加载
ablekhabout 4 years ago
Could someone clarify why &#x2F; when would it make sense to use Tailwind UI with upcoming Vue support versus just using one of also very popular Vue component libraries, such as PrimeVue or Quasar?
sudhirjabout 4 years ago
I thought I’d be getting a couple of examples of nicely designed components, but this an excellent example of getting my money’s worth and more.
734129837261about 4 years ago
Tailwind is the weirdest thing I&#x27;ve ever ran across. It&#x27;s basically inline CSS.<p>Personally, I write CSS this way:<p>1. Select based on cascaded semantic HTML elements; 2. Don&#x27;t repeat yourself; 3. No unnecessary classnames; 4. No style-descriptions in classnames.<p>Only when you have troubles selecting an element based on its position in your DOM you should choose a classname. It should not be &quot;.text-gray-500&quot; (like Tailwind does) but it should be &quot;p.author-role&quot;.<p>In my case the classname is semantically descriptive whereas Tailwind is not. In my case you just need to update the CSS and in the case of Tailwind you need to change your HTML and then probably also create a new CSS class.<p>But still, ideally, you&#x27;d simply select it like this:<p>The author name:<p><pre><code> figure.author figcaption h5 { ... } </code></pre> The author role:<p><pre><code> figure.author figcaption h6 { ... } </code></pre> And even the .author selector would be optional, depending on whether that figure elements needs custom styling that is exclusive to the author or not.
评论 #26786380 未加载
评论 #26786420 未加载
评论 #26786984 未加载
评论 #26786448 未加载
评论 #26786416 未加载
评论 #26786384 未加载
sbacicabout 4 years ago
Honestly, the only two things missing in Tailwind for me are:<p>1. @apply as a JS function that I can use in CSS in JS.<p>2. Some way to override existing Tailwind classes with new ones (ex: Generic Button =&gt; Specialized Button =&gt; Unique Button).
评论 #26790062 未加载
connorlayabout 4 years ago
I&#x27;m using Tailwind right now on a Phoenix Live View project and I am happy to report the two work quite well together.