kirki icon indicating copy to clipboard operation
kirki copied to clipboard

How to use CSS variables in Typography control?

Open BeholdPL opened this issue 3 years ago • 4 comments

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!

BeholdPL avatar Dec 04 '21 22:12 BeholdPL

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'
	],
]

JiveDig avatar Dec 22 '21 17:12 JiveDig

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

rahulv3a avatar Dec 23 '21 11:12 rahulv3a

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

mapsteps avatar Dec 28 '21 11:12 mapsteps

The issue persists with v4. Please reopen this or #2019.

rahulv3a avatar Dec 31 '21 08:12 rahulv3a