Twin.macro Versions Save

🦹‍♂️ Twin blends the magic of Tailwind with the flexibility of css-in-js (emotion, styled-components, solid-styled-components, stitches and goober) at build time.

3.4.1

3 months ago

3.4.0

9 months ago

New preset

Not a fan of the virtual dom? Try Twin's new SolidJS preset 🎉

Read more at #817

More updates

  • Styled components v6 support added #818
  • Escape selectors containing forward slashes #816
  • Allow grabbing values containing a decimal with theme #815

3.3.1

1 year ago

Note: Twin will now autoload a tailwind.config.ts config file if found when a tailwind.config.[.js/.cjs] doesn't exist.

// tailwind.config.ts
// generate with: `npx tailwindcss init --ts`

import type { Config } from 'tailwindcss'

export default {
  content: ['*'],
  theme: {
    extend: {},
  },
  plugins: [],
} satisfies Config
// tailwind.config.js
// generate with: `npx tailwindcss init --esm`

/** @type {import('tailwindcss').Config} */
export default {
  content: ['*'],
  theme: {
    extend: {},
  },
  plugins: [],
}
// Classic tailwind.config.js for comparison
// generate with: `npx tailwindcss init`

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ['*'],
  theme: {
    extend: {},
  },
  plugins: [],
}

3.3.0

1 year ago

🎉 This version adds support for [email protected] - enjoy!

Read the official tailwind release notes for info on all the new goodies.

Install twin and tailwind latest:

npm i -D twin.macro@latest tailwindcss@latest
pnpm i -D twin.macro@latest tailwindcss@latest
yarn add -D twin.macro@latest tailwindcss@latest

Fixed

3.1.0

1 year ago
  • 🌟 Add @apply support in plugins #770 Develop tailwindcss plugins quickly using twin-supported classes.
  • 🌟 All Next.js examples were updated to make SWC run alongside Twin
  • Add twin config types #766
  • New Jest + React Testing Library example
  • Fix the @screen inability to grab complex theme.screens values #763 - Thanks @minzojian
  • Fix pieces.some is not a function error #767

3.0.1

1 year ago

This patch contains a fix for stitches:

  • Fixed stitches animation-x classes #758

And mostly fixes for arbitrary variant usage:

  • Fixed a variant ordering bug when using multiple variants #759
  • Fixed an error when non-media at-rules were used in arbitrary variants, eg: [@page]:m-0 #759
  • Fixed comma bug where arbitrary variants aren't visited individually for the auto parent selector #757
  • Fixed encoding bug in arbitrary variants when a number is added directly after a comma #757
  • Added error message when incorrect arbitrary variant combination containing commas is used #757
  • Removed a now unneeded error that notified us to add parent selectors #759

Reminder: Update tailwind to latest also or you'll probably see a pieces.some is not a function error:

# `[email protected]` requires `tailwindcss@>=3.2.0`
npm i twin.macro@latest tailwindcss@latest

3.0.0

1 year ago

Release changes

Container queries

The new tailwind-container-queries plugin works with twin but there are some browser and version requirements:

Update notes

  • Twin config option debugPlugins was removed and rolled into another existing option: debug: true
  • Class ordering has been synced with tailwindcss
  • container has been aligned with tailwind - no longer has a custom margin value

Short Css deprecated

Twins custom "short css" has been deprecated in favour of Tailwind arbitrary properties:

tw`backgroundColor[red]` // short css (no dash next to the `[`)
tw`[backgroundColor:red]` // Updated to an arbitrary property

Emotion error: Value for 'content' without quotes

In Emotion, using before: or after: variants may trigger a console error like this:

You seem to be using a value for 'content' without quotes, try replacing it with `content: '"var(--tw-content)"'`

Update one or both of the packages below to avoid this error (version is when error was fixed):

Arbitrary variants/properties without parent selectors

In arbitrary variants/properties without parent selectors, Twin now needs to add the parent selector for you in order to create a compatible class to run through tailwindcss. If twin miscalculates where the parent selector should be added then you'll need to add the parent selector yourself.

Arbitrary variant escaping

Twin now replaces all spaces with underscores in arbitrary variants, so to keep any underscores in the output we can escape them:

// Bad
<div class="[.header__menu]:block">...</div>
// Good
<div class="[.header\_\_menu]:block">...</div>

General value escaping

Previously in many instances, escaping required a double backslash before the character (\\). Now we'll only need a single backslash:

tw`after:content-['\a0']`

Theme values/import and DEFAULT

When theme is used within an arbitrary value or property and there is a DEFAULT value found, the theme value will now return the default value automatically:

// tailwind.config.js
module.exports = {
  theme: { colors: { black: { DEFAULT: "redish" } } },
}
// Usage
tw`bg-[theme(colors.black)]` // Arbitrary value
tw`[background-color:theme(colors.black)]` // Arbitrary property
// ↓ ↓ ↓ ↓ ↓ ↓
({ "backgroundColor": "redish" }); // < DEFAULT key returned
({ "backgroundColor": "redish" }); // < DEFAULT key returned

The theme import now won't return the DEFAULT option automatically. We can still select the DEFAULT value by specifying it, eg: themecolors.black.DEFAULT. This makes it possible to grab whole objects from the config without automatically returning the DEFAULT value:

// tailwind.config.js
module.exports = {
  theme: { colors: { black: { DEFAULT: "redish", another: 'greenish' } } },
}

// Usage
import { theme } from 'twin.macro'
theme`colors.black`
// ↓ ↓ ↓ ↓ ↓ ↓
// Whole object returned
({
  "DEFAULT": "redish",
  "another": "greenish"
});

Daisy UI tailwind plugin

DaisyUI often styles their components based on classNames, eg: .btn.loading { ... } This means in some situations we have to add classNames to the jsx element to add their modifier styling

Some discussion here and at #760

Vite build issue

If you're noticing build issues after upgrading, try updating your Vite config with the updated build target:

optimizeDeps: {
  esbuildOptions: {
    target: "es2020",
  },
},

Support

If you’re kicking ass with twin - especially if you’re in a team - then please consider supporting this project. It will really help out with the continued development of twin - cheers! 🍻

Thanks

A huge thanks and shout out to all the rc contributors helping with features, fixes and bug testing over the past year - you folks are awesome 👋🙏

@omaemae, @ChrisEbert, @Macksi, @atxiii, @mohammadsiyou, @MatthiasDunker, @lguima, @EduardoBautista, @HaidarEzio, @ajmnz

Full Changelog: https://github.com/ben-rogerson/twin.macro/compare/2.8.2...3.0.0

3.0.0-rc.5

1 year ago

Install release candidate 5:

npm install twin.macro@rc
  • Avoid splitting within arbitrary variants during variant group unwrap 09ddd98
  • Avoid incorrect parent selector match within arbitrary variants 798638f
  • Fix shortCss check 51384af
  • Fix separator suggestion issue 1977aaa
  • Add support for tailwindConfig.separator 92e902c
  • Fix arbitrary variant/property support ed8d1e2
  • Improve jest tests #743

3.0.0-rc.4.2

1 year ago

Minor rc release with a few patches:

  • Improve arbitrary variant (+ parent selector) support 8de0ce733ec4233ac89ab00361d264987966963e
  • Avoid presets overriding the custom twin config 59713cd229cc6bd48a65ab91496e8463bb1e410a
  • Avoid incorrectly splitting class within arbitrary values b866af6f8bded90585d843aa88588a6af0c0f97b
  • Misc class suggestion/error improvements 0358486fa4f80569db99ab3a1ec5204f6c13c944 a1b438ef7b69cd540290ea8d8db65adf4a8242bd 534742815762762ec16ce67ec177f64a2ca19a0a

Big thanks to everyone who has helped with testing đź‘Ť

3.0.0-rc.4.1

1 year ago

Minor rc release with a couple small patches: