Show HN: CSS Extras

mofle | 99 points

One problem I think people are going to run into here is loading CSS libraries from the components that use them.

Luckily, CSS Modules are starting to land in multiple browsers. Firefox added support behind a flag, and it might ship in 145.

So you'll be able to import the CSS from your JS modules, and apply it to the document:

    import extras from 'css-extras' with {type: 'css'};

    if (!document.adoptedStyleSheets.includes(extras)) {
      document.adoptedStyleSheets.push(extras);
    }
Or, if you use shadow DOM:

    this.shadowRoot.adoptedStyleSheets.push(extras);
spankalee | 19 hours ago

Welp, time to make a @function preprocessor. There is no reason for every single client to recalculate things which could have been completely or partially calculated at build time.

cluckindan | a day ago

Not supported by Firefox or Safari

https://caniuse.com/?search=%40function

dmix | 19 hours ago

Obvious question: are CSS functions Turing complete?

ape4 | a day ago

CSS is changing so fast. I guess we will see Doom in CSS shortly

ulrischa | 19 hours ago

I’m so confused why people are ragging on this. Why is this considered detrimental? Looks pretty good to me…

chris_wot | 19 hours ago

It is time to reject this ugly double dash prefix kebab-cased variables names. PHP looks better in comparison.

What goes in some people's mind when they come up with these ugly conventions and rules?

rrgok | 14 hours ago

It would be quite nice to see some more "killer" uses of this new feature that aren't just "we removed some duplication and... saved less than 1% of our loc".

And maybe there are some really compelling ones... I think the only really useful one I see here is `--abs`, which really should just be built-in.

gampleman | 21 hours ago

CSS is becoming the new JavaScript.

solaraQuill55 | 19 hours ago

Whoo. I’ll be the first hyper negative prototypical HN commenter.

I’m glad I don’t work on browser engines for a living. CSS is getting more complex and spaghetti-capable by the day.

> Currently only supported in Chrome 141+. The @function rule is going through the W3C standardization process and will be available in other browsers soon.

Also, pretty tired of Chrome effectively front-running standards as a not-so-subtle means of cramming them through.

christophilus | a day ago

Oooh this will not end well.. Also side question, is it really necessary to have this as an npm package ?

bilekas | 21 hours ago