Skip to content

How to get the CSS from only classes with 1.0? #436

Answered by sastan
tmikaeld asked this question in Q&A
Discussion options

You must be logged in to vote

Almost the same: https://replit.com/@sastan/twind-css-example#index.js

import { twind as setup, virtual, cx, stringify } from 'https://esm.sh/twind/@twind/core@1.x'
import presetTailwind from 'https://esm.sh/twind/@twind/preset-tailwind@1.x'

function normalize() {
  return '.normalize{color:#fff}'
}

const tw = setup({
  presets: [presetTailwind({ disablePreflight: true })],
  theme: {
    fontFamily: {
      sans: ["Helvetica", "sans-serif"],
      serif: ["Times", "serif"],
    },
  },
}, virtual());

export function twind(...classes) {
  tw.clear();

  return {
    classNames: ['normalize', ...tw(cx(...classes)).split(' ')],
    style: normalize() + stringify(tw.target)
  }
}

console.l…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@tmikaeld
Comment options

@tmikaeld
Comment options

@sastan
Comment options

Answer selected by tmikaeld
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants