Hey everyone!
Is it possible to create a checkbox property in the site editor schema?
I tried using "ui:widget": "checkboxes" and "ui:widget": "checkbox" but it didn’t work.
Thanks!
Hey everyone!
Is it possible to create a checkbox property in the site editor schema?
I tried using "ui:widget": "checkboxes" and "ui:widget": "checkbox" but it didn’t work.
Thanks!
Hey @Lari, how’s it going?
Have you tried using ui:widget with the value "boolean" instead of "checkbox"?
Here’s an example of how you can define the property in the schema:
1{
2 "properties": {
3 "myCheckboxProperty": {
4 "type": "boolean",
5 "ui:widget": "boolean"
6 }
7 }
8}
This will create a checkbox property in the site editor that can be true or false.
If you want to create a list of checkboxes, you can use ui:widget with the value "checkbox-group" and define the options using the items property. Here’s an example:
1{
2 "properties": {
3 "myCheckboxGroupProperty": {
4 "type": "array",
5 "items": {
6 "type": "string",
7 "enum": ["option1", "option2", "option3"]
8 },
9 "ui:widget": "checkbox-group"
10 }
11 }
12}
Just keep in mind this is only a suggestion. Give it a try and see if it works.
Cheers,
Estevão.
@Lari I think this repository might help you. I created it while studying the possibilities of working with schema, especially focusing on how to structure and render dynamic interfaces from JSON Schema.
It fits well with the question you mentioned, but the approach I used would be a custom ui:widget.
If you want to explore it further, here’s the GitHub repository: