tw-in-js / twind.macro

This package is been moved into tw-in-js/twind-jsx-preprocessor monorepo.

Home Page:https://github.com/tw-in-js/twind-jsx-preprocessor/tree/main/packages/macro

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This package is been moved into tw-in-js/twind-jsx-preprocessor:packages/macro.

Please check out the new tw-in-js/twind-jsx-preprocessor monorepo.

@twind/macro

Enables the use of the tw prop, for use with twind

import "@twind/macro"
const Button = () => <button tw="bg-blue-500" />

// ⬇⬇⬇⬇⬇⬇

import { tw } from "twind"
const Button = () => <button className={tw`bg-blue-500`} />

More complex usage is supported:

import "@twind/macro"

const Button = () => (
	<button
		tw={[
			"bg-blue-500",
			condition && "text-red-500",
			{ "border-green-500": true },
		]}
	/>
)

// ⬇⬇⬇⬇⬇⬇

import { tw } from "twind"

const Button = () => (
	<button
		className={tw([
			"bg-blue-500",
			condition && "text-red-500",
			{ "border-green-500": true },
		])}
	/>
)

Installation

  1. Add babel-plugin-macros to your babel config (if you use Create React App, it's already installed!)
  2. Run npm install @twind/macro
  3. Enjoy ☺

About

This package is been moved into tw-in-js/twind-jsx-preprocessor monorepo.

https://github.com/tw-in-js/twind-jsx-preprocessor/tree/main/packages/macro


Languages

Language:TypeScript 93.7%Language:JavaScript 6.3%