Comments (2)
Here's a minimal example I came up with to use variables with the styled syntax:
// *.css.ts
import { style, createVar, globalStyle } from '@vanilla-extract/css';
import { styled, css } from 'qwik-styled-ve'
export default ''
export const colorVar = createVar()
// using variables with regular vanilla-extract syntax
export const RedText = style({
vars: {
[colorVar]: "red"
},
color: `${colorVar}`
})
// using variables with styled syntax
// this is essentially required as there doesn't seem to be a way to assign a value to the variable otherwise
globalStyle(':root', {
vars: {
[colorVar]: "red"
}
})
// note the use of the css template string helper
export const RedTextWithStyled = styled.span(css`
color: ${colorVar}
`)
// component.tsx
import { component$, useStyles$ } from '@builder.io/qwik';
import style, { RedTextWithStyled } from '*.css.ts';
export default component$(() => {
useStyles$(style);
return <RedTextWithStyled>This text should be red.</RedTextWithStyled>
});
from styled-vanilla-extract.
fixed in styled-vanilla-extract (name changed, import changed, now you import from styled-vanilla-extract/qwik
)
from styled-vanilla-extract.
Related Issues (19)
- unmet peer vite@^3.2.3: found 4.0.0 HOT 3
- Autocomplete Not Working HOT 2
- Styled Vanilla Extract crashes in Qwik Nx projects HOT 3
- Contribution, Local Development, and Debugging
- Support click-to-component
- HMR not working HOT 5
- vanillaExtractPlugin not working in vite.config.ts HOT 2
- variants not working when there's an extra dot in file name. HOT 1
- When using with qwik ssg, break html generation HOT 6
- css autocompletion HOT 2
- Get "QWIK WARN Duplicate implementations of "JSXNode" found" when using `styled` function. HOT 5
- `styled` doesn't show types for style objects HOT 2
- How to use styled-vanilla-extract in a qwik package? HOT 1
- Template literals & interpolation HOT 1
- Bun Installation not working? HOT 12
- Styled compoents way doesn't seem to work correctly. HOT 3
- After modifying the content of xx.css.ts , the project needs to be rebuilt to take effect. HOT 2
- npm install vite dependency issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from styled-vanilla-extract.