Skip to content

Using the `css_format` Argument

TruongSa edited this page Dec 20, 2017 · 3 revisions

When css_format is set you must set selectorto make it works.

General Fields

By default all field can use css_format as a string:

'css_format' => 'font-size: {{value}}'

If device_settings is true css_format will be an array:

'css_format' => array(
    'desktop' => 'font-size: {{value}}',
    'tablet' => 'font-size: {{value}}',
    'mobile' => 'font-size: {{value}}',
)

The key is device name.

CSS Ruler

'css_format' => array(
    'top' => 'padding-top: {{value}}',
    'right' => 'padding-right: {{value}}',
    'bottom' => 'padding-bottom: {{value}}',
    'left' => 'padding-left: {{value}}',
)

If device_settings is true css_format will still look like a above no need key settings for each device.

Typography

Just use 'css_format' => 'typography', for this field.

Background

Just use 'css_format' => 'background', for this field.

HTML Class

This type use for live view only. If you want to add class outside of WP customizer to HTML element you must add it by PHP code

Just use 'css_format' => 'html_class', for this field.

NOTE: if device_settings is true the class name will be {device}--{value}, example: desktop--className

Clone this wiki locally