
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@sam3d/twind
Advanced tools
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 or more of the existing presets:
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
The core engine without any presets.
The npm package @sam3d/twind receives a total of 0 weekly downloads. As such, @sam3d/twind popularity was classified as not popular.
We found that @sam3d/twind demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.