truss
classnames
truss | classnames | |
---|---|---|
5 | 94 | |
31 | 17,367 | |
- | - | |
6.3 | 8.4 | |
2 months ago | 7 days ago | |
TypeScript | JavaScript | |
- | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
truss
-
StyleX – Meta's Styling Library
Nice! We copied StyleX's "type-safe extensions" in Truss [1] so things like `` are allowed (setting margin is fine) while disallowing `` (anything "not margin") that would mess up the components internal impl details with a compile error.
That said, we don't actually use the feature that much, vs. higher-level logical props like ``.
I know we're supposed to use build-time CSS-in-JS these days, but afaiu they don't support the rare-but-handy "just spread together ~4-5 different object literals from ~random different conditionals + props", i.e. intermixing styles some inside the component + outside the component, which emotion handles really well.
Basically this [2]. StyleX says it does "cross-file styles"...but can it support that? I kinda assume not, but I'm not sure.
[1]: https://github.com/homebound-team/truss#xstyles--xss-extensi...
[2]: https://github.com/homebound-team/beam/blob/main/src/compone...
-
What working with Tailwind CSS every day for 2 years looks like
Fwiw to the avoid 80%-in-TW / 20%-in-SCSS-or-something-else dichotomy/complexity, we built Truss which brings TW (Tachyons) style abbreviations to the existing "something else" tool chain (Emotion in our case).
So then everything goes through a single system.
https://github.com/homebound-team/truss
> tailwind's and SCSS's VS code integration is pretty amazing
We get that too, by being just vanilla TypeScript, no editor-specific integration necessary. :-D
(I've linked to Truss in another response, so will stop now. :-))
- Why Tailwindcss over styled-components?
- Ask HN: Who is hiring? (November 2021)
-
TailwindCSS JIT with Arbitrary Values
Don't want to take away from Tailwind, it's great.
That said, self-promotion disclaimer but if you like inline/utility CSS, and also like TypeScript/React/Emotion, we've got a "Tailwinds-ish" CSS-in-JS library that we've enjoyed so far:
https://github.com/homebound-team/truss
classnames
-
Gatsby blog: Building SEO-friendly blog with BCMS code starter
The component needs the classname dependency and a search icon which I referenced to work. So install the classname package and download the search icon below.
-
The 20 most used React libraries
classnames: Makes dynamic CSS class application a breeze. Learn more
-
Beyond the Basics: Exploring TailwindCSS and Linaria in Next.js - From Installation to Performance Optimization
But of course, it is a button, so it could have multiple variants: primary and secondary(you can increase the number of customizable params, but we will limit it to 1, variant). To implement this you can use any library for combining classnames, for example, classnames, clsx. Let’s use the classic one, "classnames".
-
Is it okay to split long lists of class names across multiple lines? Why don't you?
Use classnames and you can comma delimited your class names where needed.
-
Creating an Image Upload Modal with Crop and Rotate Functionality in React
To get started with our image modal implementation, i'll assume you already have a React project set up. For UI i’m using Tailwind CSS. But you can use any UI library as your wish. For the image cropping and rotating functionality, we'll be utilizing the react-easy-crop library. This library provides a simple and intuitive way to crop and interact with images and videos within a React component. We will also use the heroicons and classnames libraries in our tutorial. To install all the libraries and their dependencies, open your terminal and navigate to your project's directory. Run the following command:
-
TailwindCSS & Template Literals
Save yourself some headache and use https://github.com/JedWatson/classnames
-
Dynamic CSS based on props: conditional className or style? (using CSS modules)
There is an NPM module called classnames that makes this a bit easier: https://www.npmjs.com/package/classnames
-
Type Safe Tailwind and SCSS Modules
To use the global Tailwind types from styles/cssClasses.d.ts, I've leveraged a lot of work from this post, so credit goes there for a lot of the complex TypeScript wizardry that makes things work. In essence, it builds upon the classnames (or clsx) to provide a helper function that gives us with the type safety we're after. This cleverness means we get type checking that works with whitespace, multiple classes (e.g., "container p-5")and arbitrary values (e.g., "border-[5px]"). The input "container p-5 invalid-class" provides the nifty error message:
-
Simplify Your Tailwind CSS Workflow with tailwind-fun
but I wouldn't recommend it, because I think the point of using tailwind is to not having to abstract class into component based style. it even better to write tailwind classes into the html directly and to use tailwind-fun sparingly and only if you needed to add logic to your classes. tailwind-fun purpose is more like of https://www.npmjs.com/package/classnames rather than any other css library
-
For tailwind users, how do you quickly make sense of what's going on in your html/jsx without semantic css class names? For instance `card`, `card--text`, `card--title` conveys a lot of information that i've felt missing so far in my tailwind journey.
Use the classnames library, that way I can group the utility classes together (one line) and break them up into multiple lines, and additionally have some of them be conditional based on variables/parameters;
What are some alternatives?
docker-node-example - An example Node / Express app that's using Docker and Docker Compose.
clsx - A tiny (239B) utility for constructing `className` strings conditionally.
headwind - An opinionated Tailwind CSS class sorter built for Visual Studio Code
tailwind-merge - Merge Tailwind CSS classes without style conflicts
class-types.macro
chakra-ui - ⚡️ Simple, Modular & Accessible UI Components for your React Applications
beam - 🪵 Beam Design System
styled-components - Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅
tailblocks - Ready-to-use Tailwind CSS blocks.
linaria - Zero-runtime CSS in JS library
TimescaleDB - An open-source time-series SQL database optimized for fast ingest and complex queries. Packaged as a PostgreSQL extension.
React CSS Modules - Seamless mapping of class names to CSS modules inside of React components.