tailwind-variants

🦄 Tailwindcss first-class variant API

MIT License

Downloads
1.5M
Stars
1.9K
Committers
18

Bot releases are visible (Hide)

tailwind-variants - v0.2.1 Latest Release

Published by jrgarciadev 7 months ago

What's Changed

New Contributors

Full Changelog: https://github.com/nextui-org/tailwind-variants/compare/v0.2.0...v0.2.1

tailwind-variants - v0.2.0

Published by jrgarciadev 8 months ago

What's Changed

New Contributors

Full Changelog: https://github.com/nextui-org/tailwind-variants/compare/v0.1.20...v0.2.0

tailwind-variants - v0.1.20

Published by jrgarciadev 10 months ago

What's Changed

Full Changelog: https://github.com/nextui-org/tailwind-variants/compare/v0.1.19...v0.1.20

tailwind-variants - v0.1.19

Published by jrgarciadev 10 months ago

What's Changed

New Contributors

Full Changelog: https://github.com/nextui-org/tailwind-variants/compare/v0.1.18...v0.1.19

tailwind-variants - v0.1.18

Published by jrgarciadev 12 months ago

What's Changed

Full Changelog: https://github.com/nextui-org/tailwind-variants/compare/v0.1.17...v0.1.18

tailwind-variants - v0.1.17

Published by jrgarciadev 12 months ago

What's Changed

New Contributors

Full Changelog: https://github.com/nextui-org/tailwind-variants/compare/v0.1.16...v0.1.17

tailwind-variants - v0.1.16

Published by jrgarciadev 12 months ago

What's Changed

Full Changelog: https://github.com/nextui-org/tailwind-variants/compare/v0.1.15...v0.1.16

tailwind-variants - v0.1.15

Published by mskelton 12 months ago

What's Changed

New Contributors

Full Changelog: https://github.com/nextui-org/tailwind-variants/compare/v0.1.14...v0.1.15

tailwind-variants - v0.1.14

Published by jrgarciadev about 1 year ago

What's Changed

Slots Variant Overrides

This is useful in a variety of situations:

  1. Component libraries that provide slot level class name functions:
    const {base,tab} = tv({...})
    
    <Tabs className={() => base()}>
      <Tab className={({ isSelected }) => tab({isSelected})}>
        Settings
      </Tab>
    </Tabs>
    
  2. Reusing styles for vary similar components.
    const {base,item} = tv({...})
    
    <Nav className={base()}>
      <NavItem className={item({isActive: activeItem === 'foo'})}>foo</NavItem>
      <NavItem className={item({isActive: activeItem === 'bar'})}>bar</NavItem>
    </Nav>
    
    

Full Changelog: https://github.com/nextui-org/tailwind-variants/compare/v0.1.13...v0.1.14

Huge thanks to @mskelton and @tianenpang 🙏🏻

tailwind-variants - v0.1.13

Published by jrgarciadev over 1 year ago

What's Changed

New Benchmark

TV without slots & tw-merge (enabled) x 452,002 ops/sec ±0.28% - 6.57% (% speed increased)
TV without slots & tw-merge (disabled) x 558,383 ops/sec ±0.60% - 17.41% (% speed increased)
TV with slots & tw-merge (enabled) x 311,351 ops/sec ±0.68% (99 runs sampled) - 8.01% (% speed increased)
TV with slots & tw-merge (disabled) x 359,928 ops/sec ±0.81% (93 runs sampled) - 8.61% (% speed increased)
TV without slots & custom tw-merge config x 429,622 ops/sec ±1.60% (95 runs sampled) - 4.42% (% speed increased)
TV with slots & custom tw-merge config x 393,804 ops/sec ±0.84% (96 runs sampled) - 4.94% (% speed increased)

Fastest is TV without slots & tw-merge (disabled)

New Contributors

Full Changelog: https://github.com/nextui-org/tailwind-variants/compare/v0.1.12...v0.1.13

tailwind-variants - v0.1.12

Published by jrgarciadev over 1 year ago

What's Changed

  • Custom tailwind merge config cache fixed
  • Performance improvements added

Benchmark

TV without slots & tw-merge (enabled) x 424,170 ops/sec ±0.15% (95 runs sampled)
TV without slots & tw-merge (disabled) x 475,632 ops/sec ±1.07% (93 runs sampled)
TV with slots & tw-merge (enabled) x 288,266 ops/sec ±1.09% (96 runs sampled)
TV with slots & tw-merge (disabled) x 331,401 ops/sec ±0.69% (95 runs sampled)
TV without slots & custom tw-merge config x 411,441 ops/sec ±0.53% (98 runs sampled)
TV with slots & custom tw-merge config x 375,262 ops/sec ±0.20% (102 runs sampled)

Fastest is TV without slots & tw-merge (disabled)

tailwind-variants - v0.1.11

Published by jrgarciadev over 1 year ago

What's Changed

New Contributors

Full Changelog: https://github.com/nextui-org/tailwind-variants/compare/v0.1.10...v0.1.11

tailwind-variants - v0.1.10

Published by jrgarciadev over 1 year ago

What's Changed

Full Changelog: https://github.com/nextui-org/tailwind-variants/compare/v0.1.8...v0.1.10

tailwind-variants - v0.1.9

Published by jrgarciadev over 1 year ago

What's Changed

  • Fix Tailwind Merge config, partial values accepted
tailwind-variants - v0.1.7

Published by jrgarciadev over 1 year ago

What's Changed

New Contributors

Full Changelog: https://github.com/nextui-org/tailwind-variants/compare/v0.1.6...v0.1.7

tailwind-variants - v0.1.6

Published by jrgarciadev over 1 year ago

tailwind-variants - v0.1.5

Published by jrgarciadev over 1 year ago

tailwind-variants - v0.1.3

Published by jrgarciadev over 1 year ago

What's Changed

New Contributors

Full Changelog: https://github.com/nextui-org/tailwind-variants/compare/v0.1.2...v0.1.3

tailwind-variants - v0.1.2

Published by jrgarciadev over 1 year ago

What's Changed

🐛 Fixes

Credits

Huge thanks to @tianenpang 🙏🏻

Full Changelog: https://github.com/nextui-org/tailwind-variants/compare/v0.1.1...v0.1.2

tailwind-variants - v0.1.0

Published by jrgarciadev over 1 year ago

What's Changed

🚀 Features

  • On-Demand transform. by @tianenpang
  • New config api responsiveVariants. by @tianenpang
  • New parameter added compoundSlots to apply classes to multiple slots at once, this reduces the amount of repeated code by @jrgarciadev
  • tailwind-merge package upgraded to 1.10.0 by @jrgarciadev

🐛 Fixes

  • Fixed issue with failed transform when using extend. by @tianenpang
  • Fixed issue with children slots are now being returned for extended tv functions with slots #23 by @jrgarciadev

⚙️ Refactor

  • Types declaration improved by @jrgarciadev
  • Tests improved by @jrgarciadev

🔴 Breaking Changes

To be able to use Responsive Variants you need to include responsiveVariants: true or responsiveVariants:['xs', 'sm', ....allDesiredVariants'] in the configuration object. This ensures that tv functions only generate responsive variants for the specified breakpoints, significantly reducing the amount of CSS generated in the final bundle.

Example:

const button = tv({
  base: "font-semibold text-white py-1 px-3 rounded-full active:opacity-80",
  variants: {
	color: {
		primary: "bg-blue-500 hover:bg-blue-700",
		secondary: "bg-purple-500 hover:bg-purple-700",
		success: "bg-green-500 hover:bg-green-700",
	},
	size: {
		small: "py-1 px-2 text-xs",
		medium: "py-1 px-2 text-sm",
		large: "py-1.5 px-3 text-md",
	},
  },
},
+ {
+  responsiveVariants: ['sm', 'md']
+ }
);

// the function call remains unchanged.
button({
	color: {
		initial: "primary",
		sm: "success",
		md: "secondary",
	},
	size: {
		initial: "small",
		sm: "medium",
		md: "large",
	},
})}

Credits

Huge thanks to @tianenpang 🙏🏻

Stay tuned to the documentation website for examples. 🚀

Full Changelog: https://github.com/nextui-org/tailwind-variants/compare/v0.0.31...v0.1.0