Layout Example
All layout examples use the same schema which is an object
with two properties
, name
and birthDate
.
Horizontal layout
- Demo
- Schema
- UI Schema
- Data
schema.json
{"type": "object","properties": {"name": {"type": "string","minLength": 3,"description": "Please enter your name"},"vegetarian": {"type": "boolean"},"birthDate": {"type": "string","format": "date"},"nationality": {"type": "string","enum": ["DE","IT","JP","US","RU","Other"]},"personalData": {"type": "object","properties": {"age": {"type": "integer","description": "Please enter your age."},"height": {"type": "number"},"drivingSkill": {"type": "number","maximum": 10,"minimum": 1,"default": 7}},"required": ["age","height"]},"occupation": {"type": "string"},"postalCode": {"type": "string","maxLength": 5}},"required": ["occupation","nationality"]}
uischema.json
{"type": "HorizontalLayout","elements": [{"type": "Control","label": "Name","scope": "#/properties/name"},{"type": "Control","label": "Birth Date","scope": "#/properties/birthDate"}]}
{"name": "John Doe","vegetarian": false,"birthDate": "1985-06-02","personalData": {"age": 34},"postalCode": "12345"}
Vertical layout
- Demo
- Schema
- UI Schema
- Data
schema.json
{"type": "object","properties": {"name": {"type": "string","minLength": 3,"description": "Please enter your name"},"vegetarian": {"type": "boolean"},"birthDate": {"type": "string","format": "date"},"nationality": {"type": "string","enum": ["DE","IT","JP","US","RU","Other"]},"personalData": {"type": "object","properties": {"age": {"type": "integer","description": "Please enter your age."},"height": {"type": "number"},"drivingSkill": {"type": "number","maximum": 10,"minimum": 1,"default": 7}},"required": ["age","height"]},"occupation": {"type": "string"},"postalCode": {"type": "string","maxLength": 5}},"required": ["occupation","nationality"]}
uischema.json
{"type": "VerticalLayout","elements": [{"type": "Control","label": "Name","scope": "#/properties/name"},{"type": "Control","label": "Birth Date","scope": "#/properties/birthDate"}]}
{"name": "John Doe","vegetarian": false,"birthDate": "1985-06-02","personalData": {"age": 34},"postalCode": "12345"}
Group
A Group
is like a VerticalLayout
but features an additional label
property.
In this case it has been set to 'My Group'.
- Demo
- Schema
- UI Schema
- Data
My Group
schema.json
{"type": "object","properties": {"name": {"type": "string","minLength": 3,"description": "Please enter your name"},"vegetarian": {"type": "boolean"},"birthDate": {"type": "string","format": "date"},"nationality": {"type": "string","enum": ["DE","IT","JP","US","RU","Other"]},"personalData": {"type": "object","properties": {"age": {"type": "integer","description": "Please enter your age."},"height": {"type": "number"},"drivingSkill": {"type": "number","maximum": 10,"minimum": 1,"default": 7}},"required": ["age","height"]},"occupation": {"type": "string"},"postalCode": {"type": "string","maxLength": 5}},"required": ["occupation","nationality"]}
uischema.json
{"type": "Group","label": "My Group","elements": [{"type": "Control","label": "Name","scope": "#/properties/name"},{"type": "Control","label": "Birth Date","scope": "#/properties/birthDate"}]}
{"name": "John Doe","vegetarian": false,"birthDate": "1985-06-02","personalData": {"age": 34},"postalCode": "12345"}
Nested layouts
This example demonstrates how layouts can be nested in order to create more complex forms.
The top UI schema element is a Group
which in turn contains a HorizontalLayout
.
The elements
of the HorizontalLayout
then are again VerticalLayout
.
- Demo
- Schema
- UI Schema
- Data
My Group
schema.json
{"type": "object","properties": {"name": {"type": "string","minLength": 3,"description": "Please enter your name"},"vegetarian": {"type": "boolean"},"birthDate": {"type": "string","format": "date"},"nationality": {"type": "string","enum": ["DE","IT","JP","US","RU","Other"]},"personalData": {"type": "object","properties": {"age": {"type": "integer","description": "Please enter your age."},"height": {"type": "number"},"drivingSkill": {"type": "number","maximum": 10,"minimum": 1,"default": 7}},"required": ["age","height"]},"occupation": {"type": "string"},"postalCode": {"type": "string","maxLength": 5}},"required": ["occupation","nationality"]}
uischema.json
{"type": "Group","label": "My Group","elements": [{"type": "HorizontalLayout","elements": [{"type": "VerticalLayout","elements": [{"type": "Control","label": "Name","scope": "#/properties/name"},{"type": "Control","label": "Birth Date","scope": "#/properties/birthDate"}]},{"type": "VerticalLayout","elements": [{"type": "Control","label": "Name","scope": "#/properties/name"},{"type": "Control","label": "Birth Date","scope": "#/properties/birthDate"}]}]}]}
{"name": "John Doe","vegetarian": false,"birthDate": "1985-06-02","personalData": {"age": 34},"postalCode": "12345"}