# Hologram UI

> CSS transform, filters, animations and box-shadow can be used to create stunning hologram effect in Gameface.

> Documentation index: https://coherent-labs.com/llms.txt lists every page of this documentation as Markdown; the full text is in https://coherent-labs.com/llms-full.txt.

Source: https://coherent-labs.com/blog/uitutorials/hologram-ui/

## Hologram UI

ui tutorials

3/28/2024

Veneta Kochovska

This guide shows how to create a hologram effect like this one in Gameface:

It uses CSS [transform ](https://developer.mozilla.org/en-US/docs/Web/CSS/transform), [filters ](https://developer.mozilla.org/en-US/docs/Web/CSS/filter), [animations ](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_animations/Using_CSS_animations)and [box-shadow ](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow)to achieve the glowing, transparent look with the moving particles.

The skewed circles are SVGs that have transform applied to them:

```html
<svg width="200" height="200" class="ellipse">
    <ellipse cx="100" cy="100" rx="75" ry="60" style="stroke:#00a6ffcc;stroke-width:15;"
        fill-opacity="0"></ellipse>
</svg>
```

The `.ellipse` class has [rotate3d ](https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/rotate3d):

```css
.ellipse {
    transform: rotate3d(1, 0, 0, 84deg);
}
```

The shadow underneath the ellipses are div elements with `box-shadow`:

```css
.projector-circle-bottom {
    position: absolute;
    top: 439px;
    width: 150px;
    height: 120px;
    border: 2px transparent;
    border-radius: 150px;
    box-shadow: 0px 50px 100px 30px #00a6ffcc;
}
```

And they too have the `.ellipse` class which applies the transformation.

The light beams are absolutely positioned div elements that have [box-shadow ](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow)which creates the specific glow transparent effect:

To achieve pointy edges we use four vertically aligned elements that have different values for [blur and spread-radius ](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow#syntax):

```html
<div class="light-beam">
    <div class="glow-edge"></div>
    <div class="glow-middle"></div>
    <div class="glow-middle"></div>
    <div class="glow-edge"></div>
</div>
```

`glow-middle` has higher value for blur-radius giving it a bigger shadow, making the center of the light beam wider. And respectively `glow-edge` has a narrower shadow.

```css
.glow-edge {
    width: 1px;
    height: 60px;
    background-color: rgb(0, 166, 255, 0.5);
    box-shadow: 0px 0px 55px 10px rgb(0, 166, 255, 0.5);
}

.glow-middle {
    width: 1px;
    height: 60px;
    background-color: rgb(0, 166, 255);
    box-shadow: 0px 0px 80px 20px rgb(0, 166, 255, 1);
}
```

The slightly lighter light beams have separate class `.highlight` that uses different color for the box shadow:

```css
.highlight .glow-edge {
    background-color: rgb(129, 222, 255, 1);
    box-shadow: 0px 0px 100px 20px rgb(230, 249, 254, 0.7);
}
```

The image is an SVG with the logo that uses a CSS filter to change the color:

```css
.hologram-bg {
    background: url(./assets/Master_full_white.svg);
    background-repeat: no-repeat;
    background-size: contain;
    filter: invert(29%) sepia(66%) saturate(1878%) hue-rotate(175deg);
}
```

The particle effects are generated using JavaScript and animated using CSS animation. Each particle has box-shadow that adds the glow effect:

The `generateParticles(count, diameterBoundaries, coordBoundaries)` accepts 3 arguments:

- the number of particles you want to generate
- an array of lower and upper limit of the diameter
- an array of lower and upper limit of the position coordinates

Example:

```javascript
generateParticles(20, [2, 8], [150, 150]);
```

Will generate 20 particles with random size ranging from 2 to 8 pixels and will position them with top and left randomly chosen, not exceeding 150.

```css
.particle {
    background-color: rgba(208, 235, 250, 0.5);
    box-shadow: 0px 0px 20px 10px rgb(0, 166, 255, 0.5);
}
```

The size of the particles is dynamic but within a given range. The position is also random, but again - within the boundaries of a container element. Each particle is a square div with border radius equal to its width to make it a circle. The animation is a vertical movement from the starting position to the top of the parent container:

```js
function generateParticleAnimation(initialPosition, idx, animClassName) {
    const animName = `particle-anim-${idx}`;

    return `
    .${animClassName} {
        animation-duration: 6s;
        animation-name: ${animName};
        animation-iteration-count: infinite;
        animation-timing-function: linear;
    }
    @keyframes ${animName} {
        0% {
            top: ${initialPosition}px;
            opacity: 1;
        }
        50% {
            top: 10px;
            opacity: 0;
        }
        100% {
            top: ${initialPosition}px;
            opacity: 1;
        }
    }`;
}
```

## On this page
