1.3.1 • Published 22 days ago

spatial-design-system v1.3.1

Weekly downloads
-
License
-
Repository
-
Last release
22 days ago

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>
PropertyTypeDefaultDescription
visiblebooleantrueShows or hides the menu.
sizeenum (small, medium, large)mediumInfluences the compactness of the menu (paddings, font sizes, etc.)
positionnumber[]0 0 0Sets menu position.
primarystring (blue, #fff)#0091E3Alters menu color (text, background, icon background).
itemsstring (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.
variantenum (filled, transparent)filledAlters overall menu look.
logoiconimage url or asset ID (string)""Sets a menu prepend icon based on the image's url or asset ID with hashtag.
layoutstring (circle, grid)gridSets menu layout.
highlightedstring(red, #fff)#C1080CSets color of elements when clicked on
backbuttonbooleanfalseDisplays 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>
PropertyTypeDefaultDescription
primarystring(blue, #fff)#0091E3Sets the color of the button.
opacitynumber1Sets the button opacity.
visiblebooleantrueShows or hides the button.
positionnumber[]0 0 0Sets the button position.
sizeenum(small, medium, large, extra-large)mediumSets the button size.
contentstring""Sets the text content.
prependiconicon url or asset ID (string)""Adds an icon to the button. No icon by default.
textcolorstring(blue, #fff)blackAlters the color of the text content.
variantenum(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>
PropertyTypeDefaultDescription
visiblebooleantrueShows or hides the switch.
positionnumber[]0 0 0Sets the switch position.
sizeenum(small, medium, large, extra-large)mediumSets the switch size.
circlecolorstring(blue, #fff)#ffffffAlters the color of the moving circle.
toggleoncolorstring(blue, #fff)#4CAF50 (green)Sets the color of the button background when switchen on.
toggleoffcolorstring(blue, #fff)#FF5252 (red)Sets the color of the button background when switchen off.
valuebooleanfalseDefines 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>
PropertyTypeDefaultDescription
visiblebooleantrueShows or hides the checkbox.
positionnumber[]0 0 0Sets the checkbox position.
sizeenum(small, medium, large, extra-large)mediumSets the checkbox size.
primarystring(blue, #fff)#0091E3Sets the color of the checkbox background when switched off.
toggleoncolorstring(blue, #fff)#4CAF50 (green)Sets the color of the checkbox when turned on.
bordercolorstring(blue, #fff)#000000Adjusts the color of the border.
checkmarkcolorstring(blue, #fff)#000000Adjusts the color of the checkmark.
variantenum(light, dark)""Sets a predefined background, checkmark and border color. Overrides the primary color.
valuebooleanfalseDefines 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>
PropertyTypeDefaultDescription
visiblebooleantrueShows or hides the textbox.
positionnumber[]0 0 0Sets the textbox position.
sizeenum(small, medium, large, extra-large)mediumSets the textbox size.
primarystring(blue, #fff)#000000Sets the color of the textbox.
bordercolorstring(blue, #fff)blackAdjusts the color of the textbox border when clicked on.
textcolorstring(blue, #fff)blackSets the color of the text in the textbox.
labelstring""Defines the label displayed when the textbox is empty.
isactivatedbooleanfalseDefines 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>
PropertyTypeDefaultDescription
columnsnumber2Number of grid columns.
rowsnumber2Number of grid rows.
spacingnumber0Sets spacing between items.
overflowbooleanfalseIf 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.

PropertyTypeDefaultDescription
spacingnumber0Sets spacing between elements.
radiusnumber1Sets 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>
PropertyTypeDefaultDescription
widthnumber1Sets list width.
heightnumber1Sets list height.
directionstringcolumnDirection of the elements.
spacingnumber0Sets 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>
PropertyTypeDefaultDescription
hAlignenum(left, center, right)centerSets horizontal alignment.
vAlignenum(top, center, bottom)centerSets 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>
PropertyTypeDefaultDescription
factornumber1.0A 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>
PropertyTypeDefaultDescription
----

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>
PropertyTypeDefaultDescription
anglenumber0.0In degrees. Determine the limit after which the element's position changed. (with smooth animation)
distancenumber2.0Distance 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>
PropertyTypeDefaultDescription
directionenum(row, column)rowDefines the direction in which the items in the flexbox are arranged.
paddingvec20 0Sets 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.
hAlignenum(start, center, end, space-around, space-between)startAligns items along the horizontal axis. If direction is set to column, it aligns along the vertical axis.
vAlignenum(start, center, end, stretch)startAligns items along the vertical axis. If direction is set to column, it aligns along the horizontal axis.
wrapbooleanfalseWraps items into multiple rows/columns if the item position exceeds the container boundary.
gapnumber0A 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 or flex.

1.3.1

22 days ago

1.3.0

23 days ago

1.2.0

2 months ago

1.1.0

4 months ago

1.0.0

6 months ago