-
-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
css: Support arguments in CSS components #88
Comments
There is some flexibility in styles at the moment: https://templ.guide/syntax-and-usage/css-style-management/#css-expressions However, I think what you are asking for is for Currently this is invalid:
|
Allowing CSS expressions to take parameters would be extremely helpful in creating components which maximize re-use/flexibility. As a matter of fact, I found this discussion after trying code using the exact syntax @joerdav shows above and working my way back from the error to the cssExpressionParser that currently returns an error when parameters are included. Would the maintainers be open to such a feature? |
I think it's a valuable feature, seems ergonomic for css functions to support this. I think we just haven't got round to it yes as it's not high up on the priority list :) |
For me most use cases would be covered if css components If having different interpolation meaning between templ and css components would be a problem, maybe one could introduce some prefix such as Example usage:
should render to something like <style type="text/css">
.className_f179{width:100px;height:100px}
</style>
<div class="className_f179"></div> And having parameterized css components it would also be useful to
which should render as <div style="width:100px;height:100px"></div> |
@joerdav just implemented CSS arguments. There's a few good improvements in the main branch for the next release. |
I am attempting build dynamic pie charts using CSS where the percentage would be controlled by a CSS variable calculated on the server. I'm not sure if this can currently be achieved in templ because style attributes do not allow for templ expressions.
The text was updated successfully, but these errors were encountered: