kirki
kirki copied to clipboard
How to use CSS variables in Typography control?
Im using color field with CSS vars like this:
Kirki::add_field( $textdomain, [
'type' => 'color',
// things
'output' => array(
// vars front
array(
'element' => ':root',
'property' => '--background-color'
),
)
] );
and I want to do the same for typography. The point is: is it possible to set separate variable for each options - for 'font-family', 'variant' etc.?
Thanks!
Via https://github.com/kirki-framework/kirki/issues/2019 it looks like we can do this:
'output' => [
[
'element' => ':root',
'choice' => 'font-family',
'property' => '--body-font-family'
],
[
'element' => ':root',
'choice' => 'variant',
'property' => '--body-font-weight'
],
]
It works for font-family, font-size, line-height, text-transform, and letter-spacing. But NOT for variant.
So the following code won't work.
[
'element' => ':root',
'choice' => 'variant',
'property' => '--body-font-weight'
],
You'll need to manually add font-weight and font-style to the CSS generated by Kirki.
Here's how I do it https://github.com/kirki-framework/kirki/issues/2019#issuecomment-1000238228
Hello and thank you for reporting this issue.
We are closing most open GitHub issues with the release of Kirki 4 to start fresh with this major release.
If you are still running into issues after you have tested your theme with Kirki 4, please let us know so we can reopen the issue.
Please note that Kirki 3 is no longer actively supported. Moving forward, we will only provide support the very latest version of Kirki.
Thank you for your understanding.
Best, David
The issue persists with v4. Please reopen this or #2019.