Skip to content

slice Custom Element

<o-slice> is a standard and vanilla web-component for rendering a radial slices, arcs or pies. By default there are up to 60 slices elements per orbit.

Look and feel

Changing slice colors

To change o-slice color use CSS custom var --o-slice-color and --o-hover-slice-color in a o-slice style.

<div class="bigbang"> <div class="gravity-spot"> <div class="orbit-5"> <o-slice class="cyan"></o-slice> <o-slice class="purple"></o-slice> <o-slice class="cyan"></o-slice> <o-slice class="purple"></o-slice> <o-slice class="cyan"></o-slice> <o-slice class="purple"></o-slice> <o-slice class="cyan"></o-slice> <o-slice class="purple"></o-slice> <o-slice class="cyan"></o-slice> <o-slice class="purple"></o-slice> <o-slice class="cyan"></o-slice> <o-slice class="purple"></o-slice> </div> </div> </div>

o-slice.cyan {
--o-slice-color: var(--o-cyan-light);
--o-hover-slice-color: var(--o-cyan)
}
o-slice.purple {
--o-slice-color: var(--o-purple-light);
--o-hover-slice-color: var(--o-purple)
}
o-slice:hover{
cursor: pointer
}
o-slice {
--o-gap: 1; /* This will be added as default soon*/
}

<div class="bigbang">
<div class="gravity-spot">
<div class="orbit-5">
<o-slice class="cyan"></o-slice>
<o-slice class="purple"></o-slice>
<o-slice class="cyan"></o-slice>
<o-slice class="purple"></o-slice>
<o-slice class="cyan"></o-slice>
<o-slice class="purple"></o-slice>
<o-slice class="cyan"></o-slice>
<o-slice class="purple"></o-slice>
<o-slice class="cyan"></o-slice>
<o-slice class="purple"></o-slice>
<o-slice class="cyan"></o-slice>
<o-slice class="purple"></o-slice>
</div>
</div>
</div>

Changing endings

o-slice has one special attribute: shape to define different endings. Currently, you can choose between circle, arrow, slash, backslash and zigzag shapes. Default none.

<div class="wrapper"> <div class="bigbang"> <div class="gravity-spot"> <div class="orbit-3"> <o-slice class="grow-1x purple-light" shape="circle"></o-slice> <o-slice class="grow-1x purple" shape="circle"></o-slice> <o-slice class="grow-1x purple-dark" shape="circle"></o-slice> </div> </div> </div> </div> <div class="wrapper"> <div class="bigbang"> <div class="gravity-spot"> <div class="orbit-3"> <o-slice class="grow-1x purple-light" shape="arrow"></o-slice> <o-slice class="grow-1x purple" shape="arrow"></o-slice> <o-slice class="grow-1x purple-dark" shape="arrow"></o-slice> </div> </div> </div> </div> <div class="wrapper"> <div class="bigbang"> <div class="gravity-spot"> <div class="orbit-3"> <o-slice class="grow-1x purple-light" shape="zigzag"></o-slice> <o-slice class="grow-1x purple" shape="zigzag"></o-slice> <o-slice class="grow-1x purple-dark" shape="zigzag"></o-slice> </div> </div> </div> </div> <div class="wrapper"> <div class="bigbang"> <div class="gravity-spot"> <div class="orbit-3"> <o-slice class="grow-1x purple-light" shape="slash"></o-slice> <o-slice class="grow-1x purple" shape="slash"></o-slice> <o-slice class="grow-1x purple-dark" shape="slash"></o-slice> </div> </div> </div> </div> <div class="wrapper"> <div class="bigbang"> <div class="gravity-spot"> <div class="orbit-3"> <o-slice class="grow-1x purple-light" shape="backslash"></o-slice> <o-slice class="grow-1x purple" shape="backslash"></o-slice> <o-slice class="grow-1x purple-dark" shape="backslash"></o-slice> </div> </div> </div> </div>

.wrapper {
border: 1px dotted var(--o-purple);
height: 100px;
width: 100px;
float: left;
overflow: hidden;
margin: 5px;
}
.gravity-spot {
--o-force: 300px
}
o-slice.purple-light {
--o-slice-color: var(--o-purple-light);
--o-hover-slice-color: var(--o-orange)
}
o-slice.purple {
--o-slice-color: var(--o-purple);
--o-hover-slice-color: var(--o-orange)
}
o-slice.purple-dark {
--o-slice-color: var(--o-purple-dark);
--o-hover-slice-color: var(--o-orange)
}
o-slice:hover{
cursor: pointer
}
o-slice {
--o-gap: 1; /* This will be added as default soon*/
}

<div class="wrapper">
<div class="bigbang">
<div class="gravity-spot">
<div class="orbit-3">
<o-slice class="grow-1x purple-light" shape="circle"></o-slice>
<o-slice class="grow-1x purple" shape="circle"></o-slice>
<o-slice class="grow-1x purple-dark" shape="circle"></o-slice>
</div>
</div>
</div>
</div>
<div class="wrapper">
<div class="bigbang">
<div class="gravity-spot">
<div class="orbit-3">
<o-slice class="grow-1x purple-light" shape="arrow"></o-slice>
<o-slice class="grow-1x purple" shape="arrow"></o-slice>
<o-slice class="grow-1x purple-dark" shape="arrow"></o-slice>
</div>
</div>
</div>
</div>
<div class="wrapper">
<div class="bigbang">
<div class="gravity-spot">
<div class="orbit-3">
<o-slice class="grow-1x purple-light" shape="zigzag"></o-slice>
<o-slice class="grow-1x purple" shape="zigzag"></o-slice>
<o-slice class="grow-1x purple-dark" shape="zigzag"></o-slice>
</div>
</div>
</div>
</div>
<div class="wrapper">
<div class="bigbang">
<div class="gravity-spot">
<div class="orbit-3">
<o-slice class="grow-1x purple-light" shape="slash"></o-slice>
<o-slice class="grow-1x purple" shape="slash"></o-slice>
<o-slice class="grow-1x purple-dark" shape="slash"></o-slice>
</div>
</div>
</div>
</div>
<div class="wrapper">
<div class="bigbang">
<div class="gravity-spot">
<div class="orbit-3">
<o-slice class="grow-1x purple-light" shape="backslash"></o-slice>
<o-slice class="grow-1x purple" shape="backslash"></o-slice>
<o-slice class="grow-1x purple-dark" shape="backslash"></o-slice>
</div>
</div>
</div>
</div>

Adjust o-slice size

Each o-slice has one orbit space size, but it can be finely adjusted using the CSS class utility .shrink-10 to .shrink-90, allowing the vectors to shrink by a specified percentage.

<div class="bigbang"> <div class="gravity-spot"> <div class="orbit-5"> <o-slice style="--o-slice-color: var(--o-red)"></o-slice> <o-slice class="shrink-90" style="--o-slice-color: var(--o-orange)"></o-slice> <o-slice class="shrink-80" style="--o-slice-color: var(--o-yellow)"></o-slice> <o-slice class="shrink-70" style="--o-slice-color: var(--o-color)"></o-slice> <o-slice class="shrink-60" style="--o-slice-color: var(--o-green)"></o-slice> <o-slice class="shrink-50" style="--o-slice-color: var(--o-cyan)"></o-slice> <o-slice class="shrink-40" style="--o-slice-color: var(--o-blue)"></o-slice> <o-slice class="shrink-30" style="--o-slice-color: var(--o-indigo)"></o-slice> <o-slice class="shrink-20" style="--o-slice-color: var(--o-purple)"></o-slice> <o-slice class="shrink-10" style="--o-slice-color: var(--o-pink)"></o-slice> </div> </div> </div>


.orbit-5 {
border: 1px dashed var(--o-cyan);
}
o-slice {
--o-gap: 1; /* This will be added as default soon*/
}

<div class="bigbang">
<div class="gravity-spot">
<div class="orbit-5">
<o-slice style="--o-slice-color: var(--o-red)"></o-slice>
<o-slice class="shrink-90" style="--o-slice-color: var(--o-orange)"></o-slice>
<o-slice class="shrink-80" style="--o-slice-color: var(--o-yellow)"></o-slice>
<o-slice class="shrink-70" style="--o-slice-color: var(--o-color)"></o-slice>
<o-slice class="shrink-60" style="--o-slice-color: var(--o-green)"></o-slice>
<o-slice class="shrink-50" style="--o-slice-color: var(--o-cyan)"></o-slice>
<o-slice class="shrink-40" style="--o-slice-color: var(--o-blue)"></o-slice>
<o-slice class="shrink-30" style="--o-slice-color: var(--o-indigo)"></o-slice>
<o-slice class="shrink-20" style="--o-slice-color: var(--o-purple)"></o-slice>
<o-slice class="shrink-10" style="--o-slice-color: var(--o-pink)"></o-slice>
</div>
</div>
</div>

On opposite way, the CSS class utility .grow-0x to .grow-12x, allowing vector to expand by a multiple of .orbit size. It is possible to use decimal fractions. For example, .grow-0.1x, .grow-10.7x, etc.

<div class="bigbang"> <div class="gravity-spot"> <div class="orbit-4"> <o-slice class="grow-0.2x" style="--o-slice-color: var(--o-red)"></o-slice> <o-slice class="grow-0.4x" style="--o-slice-color: var(--o-orange)"></o-slice> <o-slice class="grow-0.6x" style="--o-slice-color: var(--o-yellow)"></o-slice> <o-slice class="grow-1.2X" style="--o-slice-color: var(--o-green)"></o-slice> <o-slice class="grow-2x" style="--o-slice-color: var(--o-cyan)"></o-slice> <o-slice class="grow-2.5x" style="--o-slice-color: var(--o-blue)"></o-slice> <o-slice class="grow-3x" style="--o-slice-color: var(--o-indigo)"></o-slice> <o-slice class="grow-4x" style="--o-slice-color: var(--o-purple)"></o-slice> </div> </div> </div>

.satellite {
border: none;
}
.orbit-5 {
border: 1px dashed var(--o-cyan);
}

o-slice {
--o-gap: 1; /* This will be added as default soon*/
}
<div class="bigbang">
<div class="gravity-spot">
<div class="orbit-4">
<o-slice class="grow-0.2x" style="--o-slice-color: var(--o-red)"></o-slice>
<o-slice class="grow-0.4x" style="--o-slice-color: var(--o-orange)"></o-slice>
<o-slice class="grow-0.6x" style="--o-slice-color: var(--o-yellow)"></o-slice>
<o-slice class="grow-1.2X" style="--o-slice-color: var(--o-green)"></o-slice>
<o-slice class="grow-2x" style="--o-slice-color: var(--o-cyan)"></o-slice>
<o-slice class="grow-2.5x" style="--o-slice-color: var(--o-blue)"></o-slice>
<o-slice class="grow-3x" style="--o-slice-color: var(--o-indigo)"></o-slice>
<o-slice class="grow-4x" style="--o-slice-color: var(--o-purple)"></o-slice>
</div>
</div>
</div>

Adjust o-slice gaps

.gap-*: Set a gap space between o-slices ranging from 0 to 30,

<div class="bigbang"> <div class="gravity-spot"> <div class="orbit-4"> <o-slice class="gap-0"></o-slice> <o-slice class="gap-2"></o-slice> <o-slice class="gap-3"></o-slice> <o-slice class="gap-4"></o-slice> <o-slice class="gap-5"></o-slice> <o-slice class="gap-6"></o-slice> <o-slice class="gap-7"></o-slice> <o-slice class="gap-30"></o-slice> </div> </div> </div>

.satellite {
border: none;
}
.orbit-5 {
border: 1px dashed var(--o-cyan);
}

o-slice {
--o-gap: 1; /* This will be added as default soon*/
--o-slice-color: var(--o-indigo);
}
<div class="bigbang">
<div class="gravity-spot">
<div class="orbit-4">
<o-slice class="gap-0"></o-slice>
<o-slice class="gap-2"></o-slice>
<o-slice class="gap-3"></o-slice>
<o-slice class="gap-4"></o-slice>
<o-slice class="gap-5"></o-slice>
<o-slice class="gap-6"></o-slice>
<o-slice class="gap-7"></o-slice>
<o-slice class="gap-30"></o-slice>
</div>
</div>
</div>

Adjusting radial layout

Arbitrary o-slice angle.

.angle-*: Set starting point angle from 0 to 360 degrees, overrriding automatic radial arragement.

<div class="bigbang"> <div class="gravity-spot"> <div class="orbit-5 range-90"> <o-slice class=" angle-115"></o-slice> </div> </div> </div>


.orbit-5 {
border: 1px dashed var(--o-cyan);
}
o-slice {
--o-slice-color: var(--o-purple);
}