Skin settings
A settings.php next to skin.php gives the card style its own fields. They show in the Skin section while the style is chosen, and skin.php gets their values as $options.
Example: a corner radius and a toggle
<?php
// your-theme/forma/skins/work-1/settings.php
return [
'card' => [
'type' => 'group',
'label' => __( 'Card', 'my-theme' ),
'open' => true,
'fields' => [
'radius' => [
'type' => 'dimension',
'label' => __( 'Corner radius', 'my-theme' ),
'units' => [ 'px' ],
'min' => 0,
'max' => 80,
'style' => [ [ 'element' => '', 'property' => '--my-card--radius' ] ],
],
],
],
'show' => [
'type' => 'group',
'label' => __( 'Show', 'my-theme' ),
'fields' => [
'year' => [ 'type' => 'toggle', 'label' => __( 'Show the year', 'my-theme' ), 'default' => true ],
],
],
];
The radius has style, so it sets a CSS variable and the preview updates without a reload. Use the variable in style.css:
.work-card__media {
border-radius: var(--my-card--radius, 12px);
}
The toggle has no style, so skin.php reads it:
<?php if ( $options['year'] ?? true ) : ?>
<p class="work-card__year"><?php echo esc_html( $item['year'] ); ?></p>
<?php endif; ?>
Values stay flat inside a group: $options['radius'], not $options['card']['radius']. An empty value means the skin’s own default.
Field types
| Type | What it is | Its own keys |
|---|---|---|
toggle | On or off | |
select | A dropdown | options (value => label) |
number | A number | min, max, step, unit |
dimension | A CSS length such as 24px or 80vh | units, min / max (one value, or one per unit), functions (true, or a list of clamp, min, max, calc, var), keywords such as auto |
knob | One of a few values on a dial | options |
color | A color | gradient => true adds a Gradient tab |
position | One of nine places on a 3×3 picker | Its CSS property gets two values, {property}-y and {property}-x, each start, center or end |
align | Left, center or right, as start, center or end | |
text / textarea | Text | |
image | An image from the Media Library | |
separator | A line between fields | |
group | A folding group of fields | fields, open |
Keys every field takes
| Key | What it does | Example |
|---|---|---|
label | The field’s name | |
help | Text behind the “i” button | |
default | The value before anyone changes it | 'default' => true |
style | Sets CSS: each rule has a selector inside the grid ('' is the grid itself), a property, and a mask where $ is the value | [ 'element' => '.work-card__title', 'property' => '--my-card--size', 'mask' => '$px' ] |
class | Adds a class to the grid; {value} is replaced by the value, and a toggle adds it while on | 'class' => 'has-overlay' |
condition | Shows the field only while another field has a value; any config path works too | [ 'year' => true ], [ 'layout.type' => 'masonry' ] |
responsive | One value per device, with the device switcher; not for toggles, images or textareas | 'responsive' => true |
live | false reloads the preview on a change, for a value skin.php prints itself | 'live' => false |
Was this article helpful?
Thanks for your feedback!