spatial-design-system v1.3.1
AR Design System
A set of reusable components and styles for AR and VR applications. Primary focus is on the web but general guidelines are applicable also to mobile technologies and goggles.
Publishing to npm (for repo owners only)
First update package version in package.json
. If you're unsure, read about semantic versioning.
Recommended: before publishing, double-check the files in package.json
that will be published to npm registries. For instance, these listed files will be part of package:
{
"files": [
"/components",
"/primitives",
"/utils",
"/.gitignore"
],
}
You can test the package before publishing to registries.
If everything is correct, navigate to project root and publish (NOTE: you must be logged in npm account.):
npm publish
Primitives
Menu
Example with circle layout:
<a-ar-menu
visible="true"
color="blue"
items="[{icon: '#dollar', title: 'Buy'}]"
variant="filled"
layout="circle"
></a-ar-menu>
Property | Type | Default | Description |
---|---|---|---|
visible | boolean | true | Shows or hides the menu. |
size | enum (small, medium, large) | medium | Influences the compactness of the menu (paddings, font sizes, etc.) |
position | number[] | 0 0 0 | Sets menu position. |
primary | string (blue, #fff) | #0091E3 | Alters menu color (text, background, icon background). |
items | string (JSON) | "" | Decorates menu using title, color or icon. Format: { icon: "home.svg", title: "", color: "red" } . Icon is a URL or asset ID with hashtag. Default color is white. |
variant | enum (filled, transparent) | filled | Alters overall menu look. |
logoicon | image url or asset ID (string) | "" | Sets a menu prepend icon based on the image's url or asset ID with hashtag. |
layout | string (circle, grid) | grid | Sets menu layout. |
highlighted | string(red, #fff) | #C1080C | Sets color of elements when clicked on |
backbutton | boolean | false | Displays back button in the middle of the menu |
Row, column
One dimensional layout elements. Both use list component.
Examples:
<a-ar-row>
<a-box color="red"></a-box>
<a-box color="blue"></a-box>
<a-box color="yellow"></a-box>
</a-ar-row>
<a-ar-column>
<a-box color="red"></a-box>
<a-box color="blue"></a-box>
<a-box color="yellow"></a-box>
</a-ar-column>
Button
A rectangle button with a text and an icon.
Example:
<a-ar-button
primary="red"
position="-1 1 -2"
size="medium"
content="Click me"
prependicon="/public/home.png"
textcolor="white"
variant=""
></a-ar-button>
Property | Type | Default | Description |
---|---|---|---|
primary | string(blue, #fff) | #0091E3 | Sets the color of the button. |
opacity | number | 1 | Sets the button opacity. |
visible | boolean | true | Shows or hides the button. |
position | number[] | 0 0 0 | Sets the button position. |
size | enum(small, medium, large, extra-large) | medium | Sets the button size. |
content | string | "" | Sets the text content. |
prependicon | icon url or asset ID (string) | "" | Adds an icon to the button. No icon by default. |
textcolor | string(blue, #fff) | black | Alters the color of the text content. |
variant | enum(light, dark) | "" | Sets a predefined button and text color. Overrides the primary color |
Switch
A rounded switch button with a value emit.
Example:
<a-ar-switch
id="a-ar-switch-1"
position="0.2 1 -2"
size="medium"
circlecolor="white"
toggleoncolor="#4CAF50"
toggleoffcolor="#FF5252"
value="false"
></a-ar-switch>
Property | Type | Default | Description |
---|---|---|---|
visible | boolean | true | Shows or hides the switch. |
position | number[] | 0 0 0 | Sets the switch position. |
size | enum(small, medium, large, extra-large) | medium | Sets the switch size. |
circlecolor | string(blue, #fff) | #ffffff | Alters the color of the moving circle. |
toggleoncolor | string(blue, #fff) | #4CAF50 (green) | Sets the color of the button background when switchen on. |
toggleoffcolor | string(blue, #fff) | #FF5252 (red) | Sets the color of the button background when switchen off. |
value | boolean | false | Defines the initial value of the switch. |
Checkbox
A squared checkbox with a value emit.
Example:
<a-ar-checkbox
id="a-ar-checkbox-1"
position="1 1 -2"
size="medium"
primary=""
toggleoncolor=""
bordercolor="#000000"
checkmarkcolor="#000000"
value="false"
></a-ar-checkbox>
Property | Type | Default | Description |
---|---|---|---|
visible | boolean | true | Shows or hides the checkbox. |
position | number[] | 0 0 0 | Sets the checkbox position. |
size | enum(small, medium, large, extra-large) | medium | Sets the checkbox size. |
primary | string(blue, #fff) | #0091E3 | Sets the color of the checkbox background when switched off. |
toggleoncolor | string(blue, #fff) | #4CAF50 (green) | Sets the color of the checkbox when turned on. |
bordercolor | string(blue, #fff) | #000000 | Adjusts the color of the border. |
checkmarkcolor | string(blue, #fff) | #000000 | Adjusts the color of the checkmark. |
variant | enum(light, dark) | "" | Sets a predefined background, checkmark and border color. Overrides the primary color. |
value | boolean | false | Defines the initial value of the checkbox. |
Textbox
An input component activated when clicked on. Each textbox is using its own virtualKeyboard component to create a custom 3D keyboard.
Example:
<a-ar-textbox
id="ar-textbox-1"
position="2.4 1 -2"
size="medium"
bordercolor="black"
textcolor="black"
label="Name"
isactivated="false"
></a-ar-textbox>
Property | Type | Default | Description |
---|---|---|---|
visible | boolean | true | Shows or hides the textbox. |
position | number[] | 0 0 0 | Sets the textbox position. |
size | enum(small, medium, large, extra-large) | medium | Sets the textbox size. |
primary | string(blue, #fff) | #000000 | Sets the color of the textbox. |
bordercolor | string(blue, #fff) | black | Adjusts the color of the textbox border when clicked on. |
textcolor | string(blue, #fff) | black | Sets the color of the text in the textbox. |
label | string | "" | Defines the label displayed when the textbox is empty. |
isactivated | boolean | false | Defines wheather the textbox is initially activated or not. |
Components
Grid
Creates a classic two dimensional layout. Grid item's width can be increased, when item's width
is explicitly set. It works as a grow factor.
Example:
<a-entity
geometry="primitive: plane; width: 2; height: 2;"
grid="rows: 2; columns: 2; spacing: 0.2;"
>
<a-box color="red" width="2"></a-box>
<a-box color="blue"></a-box>
<a-box color="yellow"></a-box>
<a-box color="green" width="2"></a-box>
</a-entity>
Property | Type | Default | Description |
---|---|---|---|
columns | number | 2 | Number of grid columns. |
rows | number | 2 | Number of grid rows. |
spacing | number | 0 | Sets spacing between items. |
overflow | boolean | false | If set to true, item's width will overflow grid's row. |
Circle
Creates a circle (pie) layout.
Example:
<a-entity circle>
<a-entity material="color: blue">
<a-entity text="value: Hello World;"></a-entity>
</a-entity>
<a-entity material="color: red"></a-entity>
<a-entity material="color: yellow"></a-entity>
<a-entity material="color: green"></a-entity>
</a-entity>
Children of circle must be plain entities because they are converted to parts of the circle.
Property | Type | Default | Description |
---|---|---|---|
spacing | number | 0 | Sets spacing between elements. |
radius | number | 1 | Sets circle's radius. |
List
Grid-based layout, creates a one dimensional layout - row or column.
Example:
<a-entity
list="direction: row; width: 3; height: 1;"
>
<a-box color="red"></a-box>
<a-box color="blue"></a-box>
<a-box color="yellow"></a-box>
</a-entity>
Property | Type | Default | Description |
---|---|---|---|
width | number | 1 | Sets list width. |
height | number | 1 | Sets list height. |
direction | string | column | Direction of the elements. |
spacing | number | 0 | Sets spacing between elements. |
Auto Position
Aligns the element inside its parent node.
<a-plane
width="5"
height="5"
position="0 0 -5"
color="orange"
>
<a-box color="green" auto-position></a-box>
</a-plane>
Property | Type | Default | Description |
---|---|---|---|
hAlign | enum(left, center, right) | center | Sets horizontal alignment. |
vAlign | enum(top, center, bottom) | center | Sets vertical alignment. |
Auto Scale
Scales the element so it has always the appropriate size in the scene based on the distance between the camera.
<a-box color="red" auto-scale="factor: 0.8"></a-box>
Property | Type | Default | Description |
---|---|---|---|
factor | number | 1.0 | A scaling factor to control the rate at which the entity scales. |
Billboard
Creates the billboard effect so element's always watching towards camera (user).
<a-plane
color="black"
text="value: Hello, World!; width: 2; align: center;"
billboard
auto-scale
></a-plane>
Property | Type | Default | Description |
---|---|---|---|
- | - | - | - |
Follow Camera
Element follows the user (camera) so it doesn't matter where the camera's located/watching, the element will be always in camera's FOV. Use controls to see the effect.
<a-sphere color="blue" follow-camera="angle: 20"></a-sphere>
Property | Type | Default | Description |
---|---|---|---|
angle | number | 0.0 | In degrees. Determine the limit after which the element's position changed. (with smooth animation) |
distance | number | 2.0 | Distance offset sets initial element's z-coordinate. |
Flexbox
Creates a one-dimensional layout, similar to CSS Flexbox.
<a-box
color="#018A6C"
position="0 1.6 -3"
width="2"
height="2"
flexbox="
direction: row;
padding: 0 0;
hAlign: space-around;
vAlign: center;
wrap: false;
gap: 0;
"
>
<a-plane color="#03FCC6"></a-plane>
<a-plane color="#03FCC6"></a-plane>
<a-plane color="#03FCC6"></a-plane>
<a-plane color="#03FCC6"></a-plane>
</a-box>
Property | Type | Default | Description |
---|---|---|---|
direction | enum(row, column) | row | Defines the direction in which the items in the flexbox are arranged. |
padding | vec2 | 0 0 | Sets the space inside the item cell. The first value is the space in the horizontal axis and the second in the vertical axis. The values are percentages and must be between 0 and 100 (not included). For example, padding: 50 50 creates a space in the cell occupying 50% in both axes. |
hAlign | enum(start, center, end, space-around, space-between) | start | Aligns items along the horizontal axis. If direction is set to column , it aligns along the vertical axis. |
vAlign | enum(start, center, end, stretch) | start | Aligns items along the vertical axis. If direction is set to column , it aligns along the horizontal axis. |
wrap | boolean | false | Wraps items into multiple rows/columns if the item position exceeds the container boundary. |
gap | number | 0 | A unitless number that sets a gap between rows/columns. It has no effect unless wrap is used. |
Implementation notes:
The container must be either a box or a plane.
By default, items always fit within the width/height of the container unless the
wrap
property is set.Flexbox doesn't support properties like
flex-grow
,flex-shrink
,flex-basis
orflex
.