Download the PHP package wmd/craft-design-field without Composer

On this page you can find all versions of the php package wmd/craft-design-field. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package craft-design-field

Design Field for Craft CMS

One field for every design option of a block. Tone, spacing, layout, columns, alignment, card style: instead of a Button Group, a Dropdown and a Lightswitch per option per block, each block gets one compact Design panel.

Start here

New to Design Field, with no options yet? About ten minutes:

  1. Pick your CSS. The settings page opens with Start here: choose Tailwind CSS, Bootstrap 5 or Plain CSS. Design Field adds five options to every block, Section tone, Section spacing, Container, Alignment and Entrance, with that framework's classes, in the settings tables (Configuration tab), where you can rename, add or remove anything. Each starts at "Block default", so no block changes until an editor picks something.
  2. Add the field. Create a field of type Design and add it to your block entry types (or any entry type).
  3. Read it in the template. On the block's outer element:

  4. Load the stylesheet once in your layout, for the entrances (and, in Plain CSS, every starter class): {% do craft.designField.starterCss() %}. Recolour it with custom properties: :root { --df-brand: #0f766e; }.
  5. Tailwind only: Tailwind builds only the classes it finds in your files, and the starter's classes live in project config. Add @source "../config/project/**/*.yaml"; to your main CSS (path from that file), or keep the classes in a template comment.
  6. Optional, the live preview: copy examples/block-preview.twig (instructions inside) so the settings page shows each block next to its options and can make tile pictures. It shows the newest live block of each type, so a new site needs one filled-in block per type: a disabled page (e.g. "Blocks") holding one of each works, and visitors never see it.

Sites that already have option fields: see Tidy up below.

Price

Free, with every feature. If it saves you time, a review in the Plugin Store helps most; the settings page has one quiet link to it ("Like it? Leave a review →") and no banners.

Requirements

Craft CMS 5.8 or later, PHP 8.2 or later.

Concepts

Configuration

Configure it in Settings → Plugins → Design Field (Groups, Options and Profiles tables, stored in project config), or in config/design-field.php, which takes over when it defines groups or profiles:

Group settings

Key
label, instructions Shown in the panel; instructions appear as an info icon
tokens / options A token file name, or inline key => classes / key => [label, icon, swatch, image, description, ...parts]
default Default key (first option, or auto)
auto true or a label: adds an auto option; templates fall back with keyOr()
aliases old => new, so renaming a key never breaks saved entries
input buttons, select, swatches, tiles, position, slider, toggle (default: buttons when they fit, else select). toggle is a lightswitch for a group with exactly two options, the first being "off"
iconsOnly Buttons show only their icon; the label becomes the tooltip
columns Cells per row for position (default: one row)
showIf / variants Show the group only when another group has one of these keys; variants is short for showIf: {variant: [...]}
optionMeta Adds label, icon, swatch, image, description or sample to options defined elsewhere (token files, generated config)

Changing a group everywhere, or for one block

Two config keys apply on top of hand-written or generated definitions, so they survive design-field/import:

They take any group setting (input, label, default, optionMeta, variants...). Changing the input changes only how the choice looks; saved values stay.

The settings page sets the input style without editing the file, under How options look:

On/off options (exactly two choices) can also show as a Chip: a pill that is filled when on. A section's chips share one Switches row, so a carousel's Autoplay, Arrows, Loop and Mouse wheel take one line instead of four switches; the row hides when the current layout hides all of them. Quick switch Toggle → Chip turns every switch on the site into chips.

Motion tiles show animation choices (entrance, slide transition) as small tiles that play their motion on hover, on keyboard focus and once when picked; they stay still when the editor's system asks for reduced motion. Entrances: fade, fade-up, fade-down, from-left, from-right, zoom-in, zoom-out, flip-in, blur-in. Transitions (two slides): slide, crossfade, fade-through, cube, coverflow, flip, cards, creative. A choice plays the preset its key names (zoom and fadeOutIn work too), or the one it sets as 'motion' => 'crossfade' (in its options or optionMeta). The look is offered when two choices match a preset or one names its motion. The tiles only suggest the motion; the site plays the real one.

Rendered tiles draw each choice as a small card with the site's own stylesheet and brand, so Corner radius and Card style show the brand's real radius, border and shadow. A choice's classes come from its preview (in its options or optionMeta), or with 'preview' => true on the group from its token value (rounded-2xl), or for tokens with several parts from the parts you name ('preview' => ['bg', 'text'] draws a section tone with its real background and text colour, so editors see the contrast); previewBase adds classes every tile shares ('border border-border bg-surface', so a radius is visible). The look is offered when every choice has classes. Set previewStylesheet (URL, alias or env var of the site's built CSS) and previewAttributes (e.g. ['data-brand' => 'default']) in config/design-field.php; without a stylesheet the tiles fall back to buttons. They are drawn in a shadow root, so the site's reset stays out of the control panel.

Buttons have three looks: Icons (icon, name on hover), Buttons (as configured: icon and label, or an "Aa" size sample) and Labels only (plain text).

A look applies only where the option can take it (a toggle needs exactly two options). Order, last wins: config file, quick switch, option table, this block. The looks are saved to project config as inputs and win over groupOverrides / profileOverrides; the configuration check lists where they replace a style set in the file.

Sections

Blocks with many options read better with headings. Give options a section and the panel lists them under it (a heading that opens and closes; options without one come first; a section whose options the current layout all hides disappears):

The map applies to every option with the handle, including a block's own lists; a group's section key (or groupOverrides) works too. The Section column on the Looks tab sets them on the settings page, and wins. Without any section the panel is one plain list, as before.

View mode

Like Matrix, the field has a View Mode (field settings): As a panel (every option open, the default), As a summary (one line of what differs from the defaults, e.g. Section tone: Brand primary, with Edit to open the panel) or Collapsed (a closed “Design” section with the number of changes). The summary follows the editor's changes before saving; every choice is posted whichever mode is used. The field settings also link to the Design Field settings page.

A summary or collapsed panel starts open on a new element (a new entry, a block just added), when the editor picks how it looks. One profile can use another mode than the field with '_view' in its config, for example a campaign whose layout tiles should always be in view:

Option Layout (field settings): In sections (the default; each section on its own row under its heading), Sections side by side (headings kept; small sections share a row, sized by the options the current layout shows) or Inline (every option one after another, still in section order, without headings).

Presets

A preset is a named set of choices shown as a button above a block's options. Edit them in Settings → Plugins → Design Field → Presets (one row per preset; Choices is group=key, group=key; saving rejects unknown groups and keys), or in config/design-field.php, which then takes over. Clicking a preset sets its choices in the panel; the editor can still change each one afterwards, and only the choices are saved, so nothing else changes for templates or content.

A block shows its own presets first, then the * ones; its own wins when both use the same name. A preset sets only the groups the block has, and is hidden when none apply, so one * list serves every block.

Option extras: icon is a Craft icon name (the bundled Font Awesome set), an SVG path or alias, or inline SVG; swatch is any CSS colour or gradient; image is a URL; sample is a CSS font size, shown as an "Aa" button so text sizes compare at a glance. Inline options are not scanned by Tailwind: put class strings in token files, or map keys to classes in templates.

The settings page

The settings page has five tabs, saved by one Save: Looks (how options look, with a working preview of each), Preview (what editors see, next to the block itself), Presets, Usage and Configuration (the configuration check, and the Groups, Options and Profiles tables when they are not set in the config file). Besides the tables, it shows:

Templates

block.design works too when the block has the field. craft.designField.of() also reads blocks that still have the old option fields, and plain mock maps, leniently: values outside a group's options pass through unchanged, so a template sees exactly what it saw before. A group that is not configured reads as empty, so removing one never breaks a page.

To let the layout choice live in the field, read block.design.variant.key in your block dispatcher.

Adopting it on an existing site

  1. Generate the configuration from your option fields:

    Every Button Group, Dropdown, Radio Buttons and Design Tokens field becomes a group, every {type}Variant field becomes that type's layout group, and every entry type with options gets a profile, in config/design-field.generated.php. Merge it under your config file. --exclude keeps behaviour fields as normal fields; --rename resolves handle clashes. The choices are saved in the file and reused on the next run, and a run that would drop groups or profiles is refused unless --force.

  2. Switch templates to craft.designField.of(block). Nothing in the content model changes, and pages render the same.
  3. Move the content, per type or all at once:

    This adds the Design field where the old option fields are, copies their values (drafts included), confirms every value in the database, and only then removes the old fields from the layout. Their values stay in the content rows.

  4. Add conditions and pictures to the generated file:

    --templates scans each layout template (and the partials it includes) for the groups it reads, and hides the others for that layout. --images turns layout groups into picture tiles where a thumbnail exists under the web root.

craft design-field/migrate is the lower-level tool behind adopt: dry run by default, --to-type switches entries to another entry type, --map adds field-to-group pairs, --entries limits the run, --overwrite replaces choices already made. Empty old fields are reported, because an old template may have rendered them differently from its intended default.

Template check

Options and the templates that render them, checked against each other: options a block offers that no template reads (editors change them and nothing happens), template reads of options a block does not offer (always the default), layout options without a template file, and template files no layout option reaches. On the settings page under Configuration, and for CI:

It reads design.x, design.has('x'), design.get('x'), design.classes('x', …), craft.designField.of(block).x and block.design.x, follows include, embed, extends, import and from with fixed paths, and counts option names quoted in your PHP (Twig extensions, modules) as read. A read on another element (craft.designField.of(item).x) keeps the option alive everywhere; craft.designField.of(item, 'blockHeading').x counts for that block. Where your templates live:

Schema for agents and tools

The option model as data, so coding agents and tools use the right handles and keys:

The rest of the file is left as it is; run it again after changing the configuration.

MCP servers

Agents connected through an MCP server read and write a Design field as the same object it stores, {"tone": "dark", "spacing": "loose", …}:

To change options, send back the whole object you read with one key changed. A partial object resets the options it leaves out to their defaults. Unknown keys fail validation, so an agent gets an error, not a silent reset.

Usage report

On the settings page, the Tidy up tab shows the same report as one card per block: every choice of an option with how many entries picked it (unpicked ones faded), a plain-language finding, and Preview ▸ to open the block on the Preview tab. Count blocks saved in limits it to the last 12, 6 or 3 months: options nobody touched in a year are the ones to drop or hardcode.

The same report runs from the settings page (Run usage report). It shows, per block, the options editors never changed from the default (drop them from that block, or hardcode them in the template), options where every entry picked the same choice (make it the default), and layouts nobody uses. A site-wide summary lists the options no editor changed in any block. Blocks with fewer than --sample entries (default 5) are marked as hints. Drafts and revisions are not counted.

The counts also order long dropdowns (10 choices or more): editors get a search box, with the three most picked choices for that block type under Most used at the top (a block type with no picks for that option yet uses the counts across the site). The counts come from a queue job and are kept for a day; running the full report on the settings page refreshes them.

Tile pictures

Layout options show as Picture tiles when each layout has a picture. A picture comes from the config ('image' => '/design-field/blockCta/split.jpg'), or from a file at tileImages (default /design-field/{type}/{key}.jpg under the web root): a layout without a configured picture gets the file found there, and a layout list where every layout has one shows as tiles unless the config names another look.

Make tile pictures (Preview tab, next to the block picker) makes the missing ones in the browser: each layout loads in a hidden frame through blockPreviewUrl, is drawn to a 480 px JPEG (modern-screenshot, MIT, shipped with the plugin) and saved to tileImages. Nothing to install on the server. With none missing, it offers to make them all again. The pictures show a saved block of that type, as the preview does, so a block without images gets the dashed image placeholders in its tile. Set tileSkip to a CSS selector for things on the preview page that are not part of a block (a dev toolbar, an accessibility badge). Pictures are site files: commit them with the site; admin changes must be allowed to make them.

Tidy up

The Tidy up tab is for sites that already have option fields, and for trimming options nobody uses.

Choices per entry

Some choices only make sense for some entries: a "list the entries from this field" option should offer the fields the page has, not every field in the install. Before a panel is drawn, the Design field fires Design::EVENT_DEFINE_PANEL_GROUPS with the element being edited and its options; replace an option with withHidden() to leave choices out of the picker:

Only the picker changes: every option stays valid, so stored values, presets and templates are unaffected, a block that already has a hidden choice still shows it, and Block default and the default always show.

To leave a whole option out of one entry's panel, add its handle to $event->hiddenGroups (for example a "Related to this page" switch on pages where there is nothing to relate to). It keeps its stored value, and conditions that depend on it still read it. $event->keys holds the current choices, so an option that is already set can stay visible.

GraphQL

The field resolves to a JSON string of group => key, and accepts the same JSON in mutations.

Craft 6

helpers/Registry, helpers/MigrationPlan, helpers/SettingsRows, models/Group, models/Token and models/DesignValue are Craft-free and carry over with their unit tests. The field class, the services and the CP input (web/GroupInput) are the Craft-specific parts.


All versions of craft-design-field with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
craftcms/cms Version ^6.0.0-beta.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package wmd/craft-design-field contains the following files

Loading the files please wait ...