Security News
NVD Backlog Tops 20,000 CVEs Awaiting Analysis as NIST Prepares System Updates
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Twind v1 is still in beta. Expect bugs!
Utility-first CSS without any build step right in the browser or any other environment like Node.js, deno, workers, ...
Twind does not include any core utilities — use one of the existing presets:
@twind/tailwind to get a full Tailwind v3 experience. It includes the following presets:
@twind/preset-tailwind-forms to get Tailwind v3 and Tailwind Forms.
Here are some examples of how to write your own rules or variants:
Additionally we provides several integrations:
To get you started, take a look at the examples.
npm install twind@next
import { setup } from 'twind'
// You must call setup at least once, but can call it multiple times
setup({
/* options */
})
Incase you are not using SSR to inject the pre-computed styles apply the following pattern to prevent FOUC:
<body class="!block" style="display: none">
<!-- ... -->
</body>
If any element has the autofocus
attribute, Twind will focus it after all styles are injected.
Add this line to your index.html
:
<head>
<script src="https://cdn.jsdelivr.net/npm/twind@next" crossorigin></script>
<script>
twind.setup({
/* options */
})
</script>
</head>
To add presets add their ids to the script src
attribute:
<head>
<!-- ... -->
<script
src="https://cdn.jsdelivr.net/npm/twind@next,npm/@twind/preset-tailwind@next"
crossorigin
></script>
<script>
twind.setup({
presets: [twind.presetTailwind()],
// ...
})
</script>
<!-- ... -->
</head>
If you are using the
script
tag these methods are available via thetwind
global object (egtwind.setup
).
setup(config [, sheet [, target]])
Initializes Twind and can be called as many times as you want.
import { setup } from 'twind'
// can be called as many times as you want.
const tw = setup({
/* config */
})
// -> tw === import { tw } from 'twind'
tw(...tokens)
— the current Twind instanceimport { tw } from 'twind'
tw`underline`
tw({ underline: true })
tw.theme('colors.blue.500', 'blue')
cx
import { cx } from 'twind'
// Set a className
element.className = cx`
underline
/* multi
line
comment
*/
hover:focus:!{
sm:{italic why}
lg:-{px}
-mx-1
}
// Position
!top-1 !-bottom-2
text-{xl black}
`
shortcut
TDB
css
TDB
style
TDB
extract(html, tw)
Used for static HTML processing (usually to provide SSR support for your javascript-powered web apps) — powered by consume(html, tw)
Note: Consider using inject instead.
Note: This clears the Twind instance before processing the HTML.
import { setup, extract, tw } from 'twind'
// can be in a different file — but should be called at least once
setup({
/* config */
})
function render() {
const { html, css } = extract(renderApp(), tw)
// inject as last element into the head
return html.replace('</head>', `<style data-twind>${css}</style></head>`)
}
twind
TDB
consume(html, tw)
Used for static HTML processing (usually to provide SSR support for your javascript-powered web apps)
import { setup, tw, consume, stringify } from 'twind'
// can be in a different file — but should be called at least once
setup({
/* config */
})
function render() {
const html = renderApp()
// clear all styles
tw.clear()
// generated markup
const markup = comsume(html, tw)
// create CSS
const css = stringify(tw.target)
// inject as last element into the head
return markup.replace('</head>', `<style data-twind>${css}</style></head>`)
}
FAQs
compiles tailwind like shorthand syntax into css at runtime
The npm package twind receives a total of 6,216 weekly downloads. As such, twind popularity was classified as popular.
We found that twind demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.