All Projects → kripod → Otion

kripod / Otion

Licence: mit
Atomic CSS-in-JS with a featherweight runtime

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Otion

Css In Js
A thorough analysis of all the current CSS-in-JS solutions with SSR & TypeScript support for Next.js
Stars: ✭ 127 (-77.44%)
Mutual labels:  styling, css-in-js
Styled System
⬢ Style props for rapid UI development
Stars: ✭ 7,126 (+1165.72%)
Mutual labels:  styling, css-in-js
Further
🦄🌈🍄 algebraic style composition for functional UIs
Stars: ✭ 254 (-54.88%)
Mutual labels:  styling, css-in-js
Polished
A lightweight toolset for writing styles in JavaScript ✨
Stars: ✭ 7,074 (+1156.48%)
Mutual labels:  styling, css-in-js
Filbert Js
A lightweight(~1kb) css-in-js framework
Stars: ✭ 167 (-70.34%)
Mutual labels:  styling, css-in-js
Fela
State-Driven Styling in JavaScript
Stars: ✭ 2,097 (+272.47%)
Mutual labels:  styling, css-in-js
tsstyled
A small, fast, and simple CSS-in-JS solution for React.
Stars: ✭ 52 (-90.76%)
Mutual labels:  styling, css-in-js
Typography.js
A powerful toolkit for building websites with beautiful design
Stars: ✭ 3,697 (+556.66%)
Mutual labels:  css-in-js
Glaze
CSS-in-JS microlibrary for making design systems approachable with React
Stars: ✭ 410 (-27.18%)
Mutual labels:  css-in-js
React Awesome Reveal
React components to add reveal animations using the Intersection Observer API and CSS Animations.
Stars: ✭ 346 (-38.54%)
Mutual labels:  css-in-js
Next Shopify Storefront
🛍 A real-world Shopping Cart built with TypeScript, NextJS, React, Redux, Apollo Client, Shopify Storefront GraphQL API, ... and Material UI.
Stars: ✭ 317 (-43.69%)
Mutual labels:  css-in-js
Color2k
a color parsing and manipulation lib served in roughly 2kB
Stars: ✭ 370 (-34.28%)
Mutual labels:  css-in-js
Styled Breakpoints
Simple and powerful tool for creating breakpoints in styled components and emotion. 💅
Stars: ✭ 428 (-23.98%)
Mutual labels:  css-in-js
Css In Js Benchmarks
Stars: ✭ 360 (-36.06%)
Mutual labels:  css-in-js
Facepaint
Responsive style values for css-in-js.
Stars: ✭ 523 (-7.1%)
Mutual labels:  css-in-js
Reshadow
Markup and styles that feel right
Stars: ✭ 343 (-39.08%)
Mutual labels:  css-in-js
Awesome Css In Js
Awesome CSS in JS articles / tutorials / videos / benchmarks / comparision
Stars: ✭ 548 (-2.66%)
Mutual labels:  css-in-js
Markupkit
Declarative UI for iOS and tvOS
Stars: ✭ 508 (-9.77%)
Mutual labels:  styling
Twin.macro
🦹‍♂️ Twin blends the magic of Tailwind with the flexibility of css-in-js (emotion, styled-components, stitches and goober) at build time.
Stars: ✭ 5,137 (+812.43%)
Mutual labels:  css-in-js
Cljss
Clojure Style Sheets — CSS-in-JS for ClojureScript
Stars: ✭ 382 (-32.15%)
Mutual labels:  css-in-js

otion

Atomic CSS-in-JS with a featherweight runtime

npm Language grade: JavaScript Travis (.com)

Backstory

Design systems embrace a component-oriented mindset. Inspired by Tailwind CSS, utility classes provide reusable styles with no unwanted side-effects. However, they have to be generated upfront.

Atomicity generalizes the former concept by instantiating style rules on demand. Serving as a solid foundation for constraint-based layouts, atomic CSS-in-JS has come to fluorish at scale.

Key features

  • 🎳 Support for shorthand properties
  • 🍱 Reliable pseudo selector ordering
  • 🔐 Type safety with autocompletion
  • 🦖 Auto-prefixing and fallback values
  • 📚 Embedded JSDoc reference
  • 🐾 Negligible runtime footprint
  • 💫 Works without a framework

Getting started

Install the library with a package manager of choice, e.g.:

npm install otion

Additionally, configure frameworks as shown below:

Example

The following demo covers a wide range of use-cases.

As a core function, css returns a space-separated string of unique class names. Each property–value pair is only injected once to the library-managed style sheet.

Please refer to the core package manual for further information.

import { css, keyframes } from "otion";

// Animation keyframes are lazily initialized
const pulse = keyframes({
  from: { opacity: 1 },
  to: { opacity: 0 }
});

// Use of JSX is optional, as the solution is framework-agnostic
function Component() {
  return (
    <>
      <p className={css({ color: "blue" })}>I am blue</p>
      <p
        className={css({
          color: "blue",
          ":hover": {
            animation: `${pulse} 3s infinite alternate`
          }
        })}
      >
        I am also blue, reusing the CSS class injected by my sibling
      </p>
      <p
        className={css({
          color: "blue",
          "@media": {
            "(min-width: 768px)": {
              color: "orange"
            }
          }
        })}
      >
        I am orange if your viewport is wider than 768px
      </p>
    </>
  );
}

Is this ready for production?

The project is marked with a '0.Y.Z' version until thorough automatic tests are written for it. However, existing functionality should be safe to use.

If you decide to give otion a try, module aliasing may help migrating between CSS-in-JS libraries:

/* package.json */
{
  "devDependencies": {
    "emotion": "npm:[email protected]^X.Y.Z" // Could also be done in reverse
  }
}

Please bear in mind that while the APIs of otion and Emotion are similar, they're not totally interchangeable. For example, custom selectors and conditional group rules have no type-safe syntax in Emotion.

Contributors

Thanks goes to these wonderful people (emoji key):

🚧 💡 🤔 🚇 🤔 🤔 🤔
Jared Palmer

📖
📦 💡 💻 🤔 🐛

Samuel Hobl

🐛

Juho Vepsäläinen

📖

This project follows the all-contributors specification. Contributions of any kind welcome!

Acknowledgements

The project's name is an ode to Emotion, an extensive CSS-in-JS runtime. Similar libraries had great impact on the initial development process, including but not limited to:

  • Styled Components, with its thoroughly tested approaches
  • Styletron, for openly discussing the caveats of atomic styling
  • glamor, by its simplistic and comprehensible implementation

The logo's ocean emoji is courtesy of Twemoji.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].