Radio buttons

If you want to allow a user to select a value from the predefined list, you can use radio buttons or the dropdown list.

Radio buttons have a special parameter to define the available option values and their characteristics labels:

{
    "name": "layoutFrontpage",
    "label": "Frontpage layout",
    "group": "Layout",
    "value": "cols-3",
    "type": "radio",
    "options": [
        {
            "label": "1 column",
            "value": "cols-1",
            "disabled": false
        },
        {
            "label": "2 columns",
            "value": "cols-2",
            "disabled": false
        },
        {
            "label": "3 columns",
            "value": "cols-3",
            "disabled": false
        }
    ]
}

The above code will generate a radio buttons list with three options:

Radio buttons

You can disable some options using the disabled field for each option.

Create your first website with Publii

Join thousands of creators who chose independence. Create content locally and publish lightning-fast, secure websites on your own terms.

Download Publii

Free and open source. Windows, macOS and Linux.

Read the getting started guide