<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sanyam Singh</title>
    <description>The latest articles on DEV Community by Sanyam Singh (@codewithsam).</description>
    <link>https://dev.to/codewithsam</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F55389%2Fae1a7ac9-91b7-471e-b935-1b329bf426b9.jpeg</url>
      <title>DEV Community: Sanyam Singh</title>
      <link>https://dev.to/codewithsam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/codewithsam"/>
    <language>en</language>
    <item>
      <title>Curved Bottom App Bar With FAB In HTML/CSS</title>
      <dc:creator>Sanyam Singh</dc:creator>
      <pubDate>Sat, 06 Jun 2020 07:24:20 +0000</pubDate>
      <link>https://dev.to/codewithsam/curved-bottom-app-bar-with-fab-in-html-css-1gf2</link>
      <guid>https://dev.to/codewithsam/curved-bottom-app-bar-with-fab-in-html-css-1gf2</guid>
      <description>&lt;h2&gt;
  
  
  Inspiration
&lt;/h2&gt;

&lt;p&gt;While working on &lt;a href="https://www.youtube.com/watch?v=2uaoEDOgk_I" rel="noopener noreferrer"&gt;Flutter’s Bottom AppBar&lt;/a&gt; I was astounded to see how simple it is to build a curved bottom app bar with fab (floating action button) icon in between. So I decided to try and build it out in html, css to see how well it works. Surprisingly, using css to achieve such design wasn’t as easy as I thought it would be&lt;/p&gt;

&lt;h2&gt;
  
  
  What do we want to achieve
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Faynhkoonarh7y6f2om3f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Faynhkoonarh7y6f2om3f.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;em&gt;Bottom App Bar with Floating action button in the center&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;Lets start by adding a div at the bottom with 3 tabs. (left tab, right tab and middle tab that would hold FAB button)&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;In the above code, you can see 3 tab divs with class &lt;strong&gt;.tab--left&lt;/strong&gt;, &lt;strong&gt;.tab--right&lt;/strong&gt; and the most important one &lt;strong&gt;.tab--fab&lt;/strong&gt;. It contains a div with class .top. Keep this div in mind as we are gonna hack the s**t out of .top div&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;div class="tab tab--fab"&amp;gt;
  &amp;lt;div class="top"&amp;gt;
   &amp;lt;div class="fab"&amp;gt; + &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Achieving rounded corners in tabs
&lt;/h3&gt;

&lt;p&gt;So before talking about &lt;em&gt;tab--fab&lt;/em&gt; lets first understand how we can achieve curviness in &lt;em&gt;tab--left&lt;/em&gt; and &lt;em&gt;tab--right&lt;/em&gt;. This can be done using css property border-top-left-radius and border-top-right-radius&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

.tab--left{
  border-top-right-radius: 30px;
}
.tab--right{
  border-top-left-radius: 30px;
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Achieving curviness in your FAB tab
&lt;/h3&gt;

&lt;p&gt;There are 3 parts to build a Curved tab with FAB on top of it&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F4zku05h48xd91l6b3ryr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F4zku05h48xd91l6b3ryr.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;em&gt;tab div containing .top div and .fab button&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkx64s8dv42jw0g6dxfll.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkx64s8dv42jw0g6dxfll.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;em&gt;div.top inside .tab div&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fp0atgkch0b62dec014wd.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fp0atgkch0b62dec014wd.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;em&gt;FAB button inside .tab div&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;tab — fab: This will contain a div will a class .top and our FAB button&lt;/li&gt;
&lt;li&gt;div.top: This will be used to create curve and keep transparency&lt;/li&gt;
&lt;li&gt;div.fab: The actual rounded FAB button&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Styling our middle tab
&lt;/h3&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Please go through the comments in above code.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As I said before .top is the key as it will produce a curve using &lt;em&gt;border-bottom-left-radius&lt;/em&gt; and &lt;em&gt;border-bottom-right-radius&lt;/em&gt;. If you do not make this div transparent it will produce a solid shape as shown below, therefore transparency is important&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0fm1mrwsmhgwwjec2zsg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0fm1mrwsmhgwwjec2zsg.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;em&gt;Result of .top tab without background: transparent&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Designing FAB Button
&lt;/h3&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The above css is to build our rounded FAB button with + icon in the center.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Well, Thats it folks. You can find complete code in below codepen.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/SamVCode/embed/VweLLmj?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>html</category>
      <category>css</category>
    </item>
  </channel>
</rss>
