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.

Panda CSS: build time and type-safe CSS-in-JS

71 pointsby bpierreover 1 year ago

17 comments

christophilusover 1 year ago
This looks a lot better than I expected.<p>One thing that bugs me about this (and Tailwind) is the number of dependencies they pull in. Panda has 152 nodes (239, if you count their dev-dependencies)[0].<p>Tailwind has 98 (594 if you count their dev-dependencies).<p>I know they&#x27;re only dev-dependencies, but still... I&#x27;ve got all of that code running on my machine, just to process CSS. I really don&#x27;t love it.<p>[0] <a href="https:&#x2F;&#x2F;npmgraph.js.org&#x2F;?q=%40pandacss%2Fdev" rel="nofollow">https:&#x2F;&#x2F;npmgraph.js.org&#x2F;?q=%40pandacss%2Fdev</a>
评论 #39271805 未加载
评论 #39270526 未加载
评论 #39270465 未加载
bsimpsonover 1 year ago
I sometimes feel like the one weirdo using jsxstyle (originally by Pete Hunt of React 1.0), but it&#x27;s been great for me. It&#x27;s a really simple concept - exposing CSS keys as props:<p><pre><code> &lt;Block backgroundColor = &#x27;red&#x27; hoverBackgroundColor = &#x27;blue&#x27; marginH = { 4 } marginV = { 12 } padding = { 16 } </code></pre> Works in both React and Preact. It&#x27;s designed to support generating styles at build time, but I&#x27;ve never bothered. For the sorts of things I work on, being able to quickly bang out a component is more important than golfing the bundle size or maintaining a design system.<p>jsxstyle feels like I can sculpt in code. It&#x27;s really satisfying to hammer out some props and see a component come to life, especially when you&#x27;ve got hot module replacement working.<p>Based on a quick perusal of linked page, Panda seems like perhaps a more mature version of jsxstyle, but also more fidgety. As an army of one, I&#x27;m happy to optimize for iteration speed, but if I needed to maintain a system, maybe I&#x27;d consider switching to Panda.<p><a href="https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;jsxstyle" rel="nofollow">https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;jsxstyle</a>
评论 #39270281 未加载
评论 #39271601 未加载
评论 #39270908 未加载
评论 #39276926 未加载
评论 #39272616 未加载
trafnarover 1 year ago
Panda seems really nice. As someone who does a lot of &quot;creative&quot; CSS work, writing styles quickly is important to me. I find writing styles as Javascript objects kinda cumbersome. I wish there was a way to use Imba&#x27;s CSS system within a React or other Javascript app. <a href="https:&#x2F;&#x2F;imba.io&#x2F;docs&#x2F;css&#x2F;syntax" rel="nofollow">https:&#x2F;&#x2F;imba.io&#x2F;docs&#x2F;css&#x2F;syntax</a><p>Imba allows you to write CSS anywhere in a component definition using CSS-like syntax (rather than Javascript object syntax).<p>The syntax for adding a quick inline style is so simple:<p><pre><code> &lt;div [width:20px]&gt; </code></pre> You can even do hover states in an inline style:<p><pre><code> &lt;div [color:red @hover:blue]&gt; </code></pre> And interpolation is easy too:<p><pre><code> &lt;div [width:{someValue}px]&gt; </code></pre> Putting a CSS block at any level of your tag hierarchy scopes it to that tag.<p><pre><code> &lt;div.foo&gt; &lt;div.bar&gt; css color:red # this applies to div.bar em color:blue # this applies to div.bar em &quot;hello&quot; &lt;em&gt; &quot;world&quot; </code></pre> CSS blocks declared in a component definition but outside of the markup, apply to the whole tag. CSS declared in a file, outside of a component definition, apply to all components defined in that file. There is also a global keyword to apply styles globally.<p><i>and</i> there&#x27;s a whole range of other useful features, a favorite of mind is the shorthand syntax for things like this:<p><pre><code> c:red # same as color:red d:vtc # same as display:flex flex-direction:column justify-content:center x:10px rotate:30deg # same as transform:translateX(10px), rotate(30deg)</code></pre>
评论 #39271175 未加载
chrisco255over 1 year ago
One of the lead devs on Panda also did Chakra (the React UI component lib). For me, Panda has been great, it&#x27;s a very nice library to work with, with compiled CSS you get best of both worlds. Type safety and expressiveness of typescript and a clean way to define CSS styles for your components. I believe it works with any JS lib too. There&#x27;s also a port for the shadcn UI library for Panda: <a href="https:&#x2F;&#x2F;shadow-panda.dev&#x2F;" rel="nofollow">https:&#x2F;&#x2F;shadow-panda.dev&#x2F;</a>
评论 #39269986 未加载
MH15over 1 year ago
React has so many solutions for this- I wonder, is there anything that works similarly to Vue scoped styles? I always struggled with styling React but it&#x27;s like a completely solved problem in Vue imo. You&#x27;re welcome to use Tailwind of course but the scoped styles per-component work so well I rarely find myself missing it.<p>Then again I&#x27;m one of those few engineers who actually enjoys CSS so my opinion may not be representative.
评论 #39367835 未加载
评论 #39271209 未加载
评论 #39271239 未加载
madjam002over 1 year ago
This looks very similar to Vanilla Extract, the API of Panda is exactly the same DX I had using it with React, but I still ended up jumping on the Tailwind bandwagon because I find it just gives me a slight extra boost in productivity and speed, especially when prototyping.
iansinnottover 1 year ago
There&#x27;s definitely a subjective element to authoring CSS, so I&#x27;m glad people have options.<p>That being said, one of the things Tailwind got right is that it&#x27;s even faster to type out than normal CSS _or_ JS objects.<p>When you know what you want from Tailwind you write it and see it very quickly. Subjectively, there would have to be some very strong benefits to get me to go back to writing plain CSS rather than a bunch of class names.
评论 #39270652 未加载
_heimdallover 1 year ago
What&#x27;s so wrong with CSS?<p>I get that react didn&#x27;t really have a clean answer for styling, but that&#x27;s more a reason to not use react than a reason to invent a new DSL for styles on the web.
评论 #39270714 未加载
hit8runover 1 year ago
I lean towards simple stylesheets. Plain. Classic. No preprocessor required. No build. Something like Tachyons, Bootstrap, W3CSS, Foundation you name it. One less architectural component to maintain, update, upgrade, migrate etc.
adaboeseover 1 year ago
For anyone who is looking for UI library that&#x27;s compatible with Panda, I highly recommend <a href="https:&#x2F;&#x2F;park-ui.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;park-ui.com&#x2F;</a> By far the most polished and actively developed. I am building a second project using it.
PUSH_AXover 1 year ago
We continue to over engineer solutions around a key&#x2F;value struct to make a div blue.<p>Modern frontend is increasingly depressing. Don&#x27;t get me wrong, there are lots of great things that solve real engineering problems, then there are things that really don&#x27;t solve a real problem.
评论 #39277169 未加载
dtheveninover 1 year ago
The site is trying to load a script that is failing: <a href="https:&#x2F;&#x2F;plausible.io&#x2F;js&#x2F;script.js" rel="nofollow">https:&#x2F;&#x2F;plausible.io&#x2F;js&#x2F;script.js</a> Maybe it’s related… training contents (page Learn) do not seem to work.
评论 #39272353 未加载
hisingover 1 year ago
Honest question: What problem(s) does this solve that not already existing solutions can?
评论 #39272483 未加载
floppiploppover 1 year ago
ah, another attempt of how to make something simple, easy and elegant like css and turn it into a convoluted mess that will evolve into maintenance hell real quick. I can see the good intentions, and it will work initially, but I wouldn&#x27;t want to be involved in something mature that uses this (or other similar) tooling.
评论 #39272706 未加载
评论 #39273158 未加载
jongjongover 1 year ago
More complexity which adds nothing of value. Hurray for billable hours.
krawczstefover 1 year ago
does this have anything to do with the pandas python library?
评论 #39270913 未加载
tamimioover 1 year ago
The front end went into shit when we started shoving html+js in one file, now it will be worse having all three in one.. I don’t understand why is it too hard to keep these three files separated?! Look at the example code, total junk!
评论 #39272305 未加载