Replies: 1 comment 2 replies
-
It's covered (but maybe not with enough examples) in https://templ.guide/syntax-and-usage/css-style-management#dynamic-class-names Something like this is probably what you want. templ ModalButton(buttonType string, text string, isPrimary bool, onClick string) {
<button
type={ buttonType }
class={
"px-4 py-2 text-sm font-medium rounded-md",
templ.KV("text-white bg-blue-500 hover:bg-blue-600", isPrimary),
templ.KV("text-gray-700 bg-gray-100 hover:bg-gray-200", !isPrimary)
}
if onClick != "" {
@click={ onClick }
}
>
{ text }
</button>
} I'd happily take a PR with use case examples. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello guys, maybe an easy question but I can't find the answer anywhere. How to achieve this ?
Thanks !
Marcus
Beta Was this translation helpful? Give feedback.
All reactions