Elevation styles
Mytril is simple way to manage elevation (box-shadow) in your project through pre-configured CSS classes. These classes help you quickly apply different levels of shadow effects to elements, improving the visual depth and user experience of your application.
Available elevation classes:
The elevation classes in Mytril range from elevation-0 (no shadow) to elevation-24 (maximum shadow). Each class applies a specific box-shadow value, which gives you a wide range of depth options for UI elements.
Class | Properties |
---|---|
elevation-0 | box-shadow: 0rem 0rem 0rem 0rem, 0rem 0rem 0rem 0rem, 0rem 0rem 0rem 0rem, ; |
elevation-1 | box-shadow: 0rem 0.125rem 0.0625rem -0.0625rem, 0rem 0.0625rem 0.0625rem 0rem, 0rem 0.0625rem 0.1875rem 0rem, ; |
elevation-2 | box-shadow: 0rem 0.1875rem 0.0625rem -0.125rem, 0rem 0.125rem 0.125rem 0rem, 0rem 0.0625rem 0.3125rem 0rem, ; |
elevation-3 | box-shadow: 0rem 0.1875rem 0.1875rem -0.125rem, 0rem 0.1875rem 0.25rem 0rem, 0rem 0.0625rem 0.5rem 0rem, ; |
elevation-4 | box-shadow: 0rem 0.125rem 0.25rem -0.0625rem, 0rem 0.25rem 0.3125rem 0rem, 0rem 0.0625rem 0.625rem 0rem, ; |
elevation-5 | box-shadow: 0rem 0.1875rem 0.3125rem -0.0625rem, 0rem 0.3125rem 0.5rem 0rem, 0rem 0.0625rem 0.875rem 0rem, ; |
elevation-6 | box-shadow: 0rem 0.1875rem 0.3125rem -0.0625rem, 0rem 0.375rem 0.625rem 0rem, 0rem 0.0625rem 1.125rem 0rem, ; |
elevation-7 | box-shadow: 0rem 0.25rem 0.3125rem -0.125rem, 0rem 0.4375rem 0.625rem 0.0625rem, 0rem 0.125rem 1rem 0.0625rem, ; |
elevation-8 | box-shadow: 0rem 0.3125rem 0.3125rem -0.1875rem, 0rem 0.5rem 0.625rem 0.0625rem, 0rem 0.1875rem 0.875rem 0.125rem, ; |
elevation-9 | box-shadow: 0rem 0.3125rem 0.375rem -0.1875rem, 0rem 0.5625rem 0.75rem 0.0625rem, 0rem 0.1875rem 1rem 0.125rem, ; |
elevation-10 | box-shadow: 0rem 0.375rem 0.375rem -0.1875rem, 0rem 0.625rem 0.875rem 0.0625rem, 0rem 0.25rem 1.125rem 0.1875rem, ; |
elevation-11 | box-shadow: 0rem 0.375rem 0.4375rem -0.25rem, 0rem 0.6875rem 0.9375rem 0.0625rem, 0rem 0.25rem 1.25rem 0.1875rem, ; |
elevation-12 | box-shadow: 0rem 0.4375rem 0.5rem -0.25rem, 0rem 0.75rem 1.0625rem 0.125rem, 0rem 0.3125rem 1.375rem 0.25rem, ; |
elevation-13 | box-shadow: 0rem 0.4375rem 0.5rem -0.25rem, 0rem 0.8125rem 1.1875rem 0.125rem, 0rem 0.3125rem 1.5rem 0.25rem, ; |
elevation-14 | box-shadow: 0rem 0.4375rem 0.5625rem -0.25rem, 0rem 0.875rem 1.3125rem 0.125rem, 0rem 0.3125rem 1.625rem 0.25rem, ; |
elevation-15 | box-shadow: 0rem 0.5rem 0.5625rem -0.3125rem, 0rem 0.9375rem 1.375rem 0.125rem, 0rem 0.375rem 1.75rem 0.3125rem, ; |
elevation-16 | box-shadow: 0rem 0.5rem 0.625rem -0.3125rem, 0rem 1rem 1.5rem 0.125rem, 0rem 0.375rem 1.875rem 0.3125rem, ; |
elevation-17 | box-shadow: 0rem 0.5rem 0.6875rem -0.3125rem, 0rem 1.0625rem 1.625rem 0.125rem, 0rem 0.375rem 2rem 0.3125rem, ; |
elevation-18 | box-shadow: 0rem 0.5625rem 0.6875rem -0.3125rem, 0rem 1.125rem 1.75rem 0.125rem, 0rem 0.4375rem 2.125rem 0.375rem, ; |
elevation-19 | box-shadow: 0rem 0.5625rem 0.75rem -0.375rem, 0rem 1.1875rem 1.8125rem 0.125rem, 0rem 0.4375rem 2.25rem 0.375rem, ; |
elevation-20 | box-shadow: 0rem 0.625rem 0.8125rem -0.375rem, 0rem 1.25rem 1.9375rem 0.1875rem, 0rem 0.5rem 2.375rem 0.4375rem, ; |
elevation-21 | box-shadow: 0rem 0.625rem 0.8125rem -0.375rem, 0rem 1.3125rem 2.0625rem 0.1875rem, 0rem 0.5rem 2.5rem 0.4375rem, ; |
elevation-22 | box-shadow: 0rem 0.625rem 0.875rem -0.375rem, 0rem 1.375rem 2.1875rem 0.1875rem, 0rem 0.5rem 2.625rem 0.4375rem, ; |
elevation-23 | box-shadow: 0rem 0.6875rem 0.875rem -0.4375rem, 0rem 1.4375rem 2.25rem 0.1875rem, 0rem 0.5625rem 2.75rem 0.5rem, ; |
elevation-24 | box-shadow: 0rem 0.6875rem 0.9375rem -0.4375rem, 0rem 1.5rem 2.375rem 0.1875rem, 0rem 0.5625rem 2.875rem 0.5rem, ; |
With 25 different elevation levels, it’s easy to apply varying degrees of shadow to your components, whether you’re working with lightweight UIs or complex layouts that require enhanced depth perception.
Usage example
Simply add the desired elevation class directly into your HTML elements:
<div class="custom-class elevation-2">
<h1>Mytril</h1>
</div>
In this example, the elevation-2 class applies a subtle shadow effect, giving the element a raised appearance.
Customizing elevation with Root variables:
You can also leverage Mytril’s root CSS variables to directly control the shadow in your custom classes. Mytril exposes variables like --elevation-{n}
, where {n}
represents the shadow depth from 0 to 24. This allows you to seamlessly integrate shadows into your existing custom styles:
.custom-class {
box-shadow: var(--elevation-3);
}
This flexibility makes it easy for developers to adapt the elevation system into custom components and styles, without being locked into predefined classes.
Elevation with Svelte:
Mytril’s elevation system integrates effortlessly into Svelte applications. Whether you’re building dynamic interfaces or simply looking for a quick way to add depth to elements, the provided CSS classes and variables make it straightforward to apply shadow effects.