Interview Prep
Interview questions, roadmaps and practice sets
Tutorials
Free tutorials on 30+ topics
Blog
Career guides, skills and interview tips
Free PDFs
Notes, cheat sheets and question banks
Certificates
Free skill tests and course certificates
Tools & Whiteboard
Free tools you can use right in the browser
Practice Tests
Mock tests, MCQs and quick Q&A
Free LMS
Learn on the Uncodemy LMS
Choose the best training program according to your career.
Improve the performance of your business with our innovative Industrial Training Program.
Read More →
Our instructor-led training classes are designed to make you an expert.
Read More →
Real-life case studies are a great way to demonstrate your practical knowledge.
Read More →
Explore blogs, latest technologies and industry updates with practical examples.
Read More →Browse all available training programs and choose the right one for your career.
Read More →Know more about who we are and what we stand for.
Discover our mission to equip individuals with essential IT skills and industry expertise.
Read More →
Free tutorials, interview questions, tools and calculators to help you learn.
Explore →Learn, practice and plan your career — bilkul free.
Book a free video counselling session and pick the right course for you.
Read More →A floating action button (FAB) is a single round or rounded-square button that floats above the content for the screen's most important action, such as "compose" or "add". Used for the right action it saves users a search; used for the wrong one, it covers content and adds clutter.

The FAB pattern was popularised by Google's Material Design for Android and is now common on the web too: Gmail's compose button, a "new chat" button in messaging apps, or an "add expense" button in a finance app. Its job is simple. It makes one primary action reachable from anywhere on the screen, usually with a thumb.
| Aspect | Guideline |
|---|---|
| Size (Material Design 3) | The standard FAB is 56 × 56 dp, with smaller and larger variants (40 dp and 96 dp in the original M3 spec). Google revised the size set in its 2025 "Expressive" update, so check m3.material.io for the current list. An extended FAB adds a text label and is wider. |
| Placement | Usually bottom-right, about 16 dp from the screen edges; above any bottom navigation bar |
| Icon | One clear icon (plus, pencil); add a label (extended FAB) if the icon alone is ambiguous |
| Number | One FAB per screen |
| Contrast | Strong colour contrast against both the page and content scrolling underneath |
| Touch target | At least 24 × 24 CSS px to meet WCAG 2.2 (success criterion 2.5.8); 44–48 px is a common, more comfortable minimum |
| Motion | Hiding on scroll-down and showing on scroll-up is fine; respect reduced-motion settings |
Use a real <button> (or a link if it navigates), so it works with keyboard and screen readers. An icon-only button needs an accessible name.
<button class="fab" type="button" aria-label="Create new note">
<svg aria-hidden="true" width="24" height="24" viewBox="0 0 24 24">
<path d="M11 5h2v14h-2zM5 11h14v2H5z"/>
</svg>
</button>
.fab {
position: fixed;
right: calc(16px + env(safe-area-inset-right));
bottom: calc(16px + env(safe-area-inset-bottom));
width: 56px;
height: 56px;
border: none;
border-radius: 16px;
background: #6750a4;
color: #fff;
fill: currentColor;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25);
display: grid;
place-items: center;
cursor: pointer;
transition: transform 0.2s ease;
z-index: 10;
}
.fab:focus-visible { outline: 3px solid #1d1b20; outline-offset: 3px; }
.fab.is-hidden { transform: translateY(96px); }
@media (prefers-reduced-motion: reduce) {
.fab { transition: none; }
}
/* keep the last items of the page reachable */
main { padding-bottom: 88px; }
The env(safe-area-inset-*) values keep the button clear of the iPhone home indicator. They only take effect when the page's viewport meta tag includes viewport-fit=cover; otherwise they are 0 and the 16 px margin still applies.
const fab = document.querySelector(".fab");
let lastY = window.scrollY;
window.addEventListener("scroll", () => {
const y = window.scrollY;
fab.classList.toggle("is-hidden", y > lastY && y > 200);
lastY = y;
}, { passive: true });
fab.addEventListener("click", () => {
// open the editor, a dialog, or navigate
});
The button hides only after the user has scrolled past the first 200 px and is moving down, and comes back as soon as they scroll up. If the FAB opens a dialog, move keyboard focus into the dialog and return it to the FAB when the dialog closes. For related front-end patterns, see building a responsive navbar and CSS animated progress bars.
In Compose, Scaffold has a slot for the FAB and positions it for you:
Scaffold(
floatingActionButton = {
FloatingActionButton(onClick = { /* open editor */ }) {
Icon(Icons.Filled.Add, contentDescription = "Create new note")
}
}
) { innerPadding ->
NoteList(modifier = Modifier.padding(innerPadding))
}
Use ExtendedFloatingActionButton when you want an icon plus a text label. If you are learning Android, our Android development roadmap covers Compose basics.
Mock up the FAB on both a short screen and a long scrolling screen, and check what it covers at the bottom of the list. Make it a component with variants for default, pressed and extended states. Our guide to designing web layouts in Figma explains components and variants.
Usually bottom-right, about 16 px or dp from the edges, and above any bottom navigation bar. For right-to-left languages, mirror it to bottom-left.
Generally no. One FAB signals one primary action. If you need more, reconsider whether a FAB is the right pattern.
It can be, but on wide screens a clear button in the page header or next to the content is often easier to find. FABs work best on mobile.
Uncodemy's UI/UX and front-end courses cover interaction patterns like this, from Figma mock-ups to accessible code.