Re is out: see what's new Lifetime updates on every purchase Support replies within 24 hours Secure checkout via Gumroad 8,500+ sales since 2016

↑↓ Navigate ↵ Open Esc Close

All products
Re:Maily contact form builder is now available on WordPress.org See it live

Skin settings

Updated 3 min read 17 views

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

TypeWhat it isIts own keys
toggleOn or off
selectA dropdownoptions (value => label)
numberA numbermin, max, step, unit
dimensionA CSS length such as 24px or 80vhunits, min / max (one value, or one per unit), functions (true, or a list of clamp, min, max, calc, var), keywords such as auto
knobOne of a few values on a dialoptions
colorA colorgradient => true adds a Gradient tab
positionOne of nine places on a 3×3 pickerIts CSS property gets two values, {property}-y and {property}-x, each start, center or end
alignLeft, center or right, as start, center or end
text / textareaText
imageAn image from the Media Library
separatorA line between fields
groupA folding group of fieldsfields, open

Keys every field takes

KeyWhat it doesExample
labelThe field’s name
helpText behind the “i” button
defaultThe value before anyone changes it'default' => true
styleSets 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' ]
classAdds a class to the grid; {value} is replaced by the value, and a toggle adds it while on'class' => 'has-overlay'
conditionShows the field only while another field has a value; any config path works too[ 'year' => true ], [ 'layout.type' => 'masonry' ]
responsiveOne value per device, with the device switcher; not for toggles, images or textareas'responsive' => true
livefalse reloads the preview on a change, for a value skin.php prints itself'live' => false
Was this article helpful?