Steps to incorporate the latest Material Design Bottom App Bar into your project

In our company, we are currently utilizing Vue and SCSS for constructing our latest Progressive Web Application. Depending on specific conditions relating to the user's profile, we need to switch out the left drawer with a Bottom App Bar.

Although we are implementing Vue Material, our UX/UI designer has opted to incorporate the most recent version of the Bottom App Bar recently introduced by Google.

Unfortunately, the CSS styles for this particular component have not yet been released and are not included in the VueMaterial components library (which only supports the older version as of now). I am facing challenges in replicating the new bar according to the second version.

Due to restrictions, here is the link to refer to the image visually

I am struggling to comprehend how it would be possible to recreate the inset between the bar and the FAB using just CSS. My attempts involving clip-path and mask-image have not yielded satisfactory outcomes.

If anyone could provide assistance or guidance on this matter, it would be greatly appreciated.

Answer №1

There are several approaches to achieving a transparent cutout with a background image using CSS. Below are three different methods, each with its own pros and cons.

1. Box-shadow on a pseudo element

This method involves using a box-shadow on a pseudo element to create a cutout effect. While it is simple to implement, it does not support rounded corners and lacks flexibility.

body {
  height: 100vh;
  background: url(https://placeimg.com/640/480/nature) center/cover no-repeat;
}

.bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  height: 56px;
  background: transparent;
  overflow: hidden;
}

.bar::before {
  content: '';
  position: absolute;
  top: -32px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 1000px;
  width: 64px;
  height: 64px;
  box-shadow: 0px 0px 0px 5000px rebeccapurple;
}
<div class="bar"></div>

2. Loads of clip path points

This approach utilizes the clip-path property with multiple points to create a custom shape cutout. Although it requires more effort to configure, it offers a much better visual effect compared to the box-shadow technique.

body {
  height: 100vh;
  background: url(https://placeimg.com/640/480/nature) center/cover no-repeat;
}

.bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  height: 56px;
  background: rebeccapurple;
  clip-path: polygon(0 0, 
    calc(50% - 38px) 0, 
    /* Add more clip-path points for your desired shape */
    0 100%);
}
<div class="bar"></div>

3. SVG clip path

The third method involves using an SVG clip path to define a custom shape cutout. This method allows for creating any shape by modifying the path within the SVG. However, it may require additional scripting for dynamic modifications.

body {
  height: 100vh;
  background: url(https://placeimg.com/640/480/nature) center/cover no-repeat;
}

.bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  height: 56px;
  background: rebeccapurple;
  overflow: hidden;
  clip-path: url(#circle);
}
<svg height="0" width="0">
  <defs>
    <clipPath id="circle">
      <path d="M0,64 v-64 h100 a32,32 0,0,0 64,0 h100 v64 z" />
    </clipPath>
  </defs>
</svg>

<div class="bar"></div>

Answer №2

There are numerous possibilities, but here is a straightforward example:

$size: 45px;

div {
  background: #550000;
  float:left;
}

.bottom {
  height: 45px;
  width: 45px * 2;
}
.left, .right{
  height: 45px * 1.5;
  width: 45px * 2;
}  
.bottom {
  background: #fff;
  border-bottom-left-radius: 45px * 2;
  border-bottom-right-radius: 45px * 2;
}
.top {
  height: 45px*1.28;
  margin-top: 20px;
}
.left {
  border-top-right-radius: 20px;
  margin-top: 10px;
}
.right {
  border-top-left-radius: 20px;
  margin-top: 10px;
}

html:

<div class="left"></div>
<div class="top"><div class="bottom"></div></div>
<div class="right"></div>

Link to the code on CodePen

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it possible to customize the Menu hover effect in Element Plus and Vue?

Hello everyone, I'm a beginner with Vue, HTML, CSS, and Element Plus. I am trying to customize a Side Bar Menu with my own hover effect, but it doesn't seem to be working. Whenever I change the background color of the el-menu element, the hover e ...

Prevent the parent from adjusting to fit the child's content

Recently, I've been working on creating a horizontal menu bar and I have condensed the CSS as much as possible. However, I am facing an issue where I do not want the ul li element to adjust its size based on the content of the ul ul. Any suggestions o ...

Can a FontAwesome icon be used as a button in Bootstrap?

Hi there, I'm trying to use a fontawesome icon as a button in my code. Here is what I have so far: <!DOCTYPE html> <html lang="en"> <head> <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" ...

Fixing the body tag's margin-top property in Yii2

The issue I encountered with my Index was related to the positioning of the contents within the body tag. I was able to resolve it by adding the following code to my site.css: margin-top: 340px; Now, my index is displaying correctly! However, after apply ...

The image zoom function is malfunctioning when trying to adjust the image position

Having some trouble with a code for image zoom in/out. When I adjust the position of the image by applying margin left to either the image or the image container (#view), it affects the zoom functionality - causing the image to move to the left during zoom ...

Simple HTML and CSS tutorial: Creating a vertical menu with a left-popping submenu

Recently, I designed a vertical menu bar using a Dreamweaver template with CSS styling. Subsequently, I added a submenu feature that I intended to have pop out from the left side of the main menu links they are associated with. Despite numerous attempts an ...

What could be causing my inline-block divs to not line up correctly?

Presented below is the code snippet of my HTML: .classWrap { text-align: center; } .classInd { display: inline-block; height: 200px; width: 200px; margin: 20px; border: 2px solid #FFF202; border-radius: 10%; box-shadow: 0 0 15px 0 #FFF2 ...

What is the best way to implement CSS rules for a hidden submenu?

Can anyone help me figure out how to apply CSS rules for a hidden submenu? I've attempted to use some JavaScript, but it's not working as expected. Below is a sample of the code I'm working with. The idea is that when you click on the anchor ...

Shell script for swapping all occurrences of :*; with a comma

Below are some CSS color variables defined in hex: --state-success-text: #3c763d; --state-success-background: #dff0d8; To create a comma-separated list of these color variables, the output should look like this: state-success-text, state-success ...

What techniques can I use to change multiple sibling elements with CSS when hovering over them?

Imagine a scenario where hovering over any row within group 1 changes the color of all rows within that same group. Now, extend this concept to apply to an unlimited number of groups, denoted by N. Let's consider having 300 groups, each consisting of ...

What is the best way to align an image underneath text?

I'm currently working on this design concept: https://i.stack.imgur.com/wJm0t.png Below the title, there is a particle image with half square images positioned on the top right and bottom left corners. My goal is to center the particle image below th ...

Ensuring the accuracy of a single field within a form containing multiple fields is made possible through the utilization of

I am facing an issue with my emailValidation method. Even though I want it to run when this.$refs.editUserForm.validate('email') returns true, it always seems to return false, especially when a valid email like <a href="/cdn-cgi/l/email-protec ...

Optimized layout for screen resolutions exceeding 1000 pixels wide

As I work on making my website responsive using Dreamweaver CC, I'm encountering a problem with screen sizes larger than 1000px. In Dreamweaver, there are three options for responsive web design at the bottom: desktop 1000px and less, tablet 768px an ...

What could be causing this program to continuously add values to the message table whenever the page is refreshed?

Looking for a simple chatting system using php, mysql, html, css and javascript? Check out this code snippet. However, there seems to be an issue with the message sending functionality. Every time a user sends a message and refreshes the page, the same m ...

How can you assign values to a complex, multi-layered object?

My objective is to store distinct data in an object users: [ { 'names': [], 'addresses': [], } ], I am using checkboxes like this: <input type="checkbox" id="john" value="john" v-model="users.names"> Th ...

A method using CSS to automatically resize an image in a teaser box as text content increases, ensuring compatibility across various web

In the process of constructing a teaser element using HTML, I plan to integrate an image and a title. This is what I have in mind: <div> <img src="./image.jpg" /> <h1 contenteditable>Something</h1> </div> Wh ...

Vue.js provides an interesting object that contains observed data

My axios request looks like this: retrieveData() { Axios.get( '/vue/get-data/', { ...

A guide on making Rest Requests with VueJs 2 and Symfony 3

Trying to send a PATCH request for an event using VueJs 2, here is the code snippet: // Link and body are defined correctly this.$http.patch(linkUrl, this.baseTerms, {someKey:'any value'}).then(response => { console.log(response.body) ...

Compatibility of Vue-apexcharts with different versions

Which versions are compatible with vue-apexcharts on platforms such as "Windows", "Linux", "Mac", "Android", "iOS", and "Tablet"? ...

What is the best way to display a unique image in a div based on the size of the

Being new to web design, I have a question about creating a webpage with a large image in the center like on GitHub's Windows page. How can I work with the image inside that particular div or area based on different screen sizes? Is it possible to mak ...