dev-resources.site
for different kinds of informations.
Animated Select component using typescript, shadcn and framer-motion
Published at
1/15/2025
Categories
webdev
javascript
frontend
frontendchallenge
Author
brokarim
Author
8 person written this
brokarim
open
The "Expand Select Animation" is a custom select component built using TypeScript and Framer Motion, with the base component provided by ShadCN. This component enhances the standard select element with a smooth, visually appealing animation that expands downward to reveal options and collapses upward to hide them.
Demo
Source Code
expand-select.tsx
import { Globe } from "lucide-react";
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { motion, AnimatePresence } from "framer-motion";
export function ExapandSelect() {
return (
<Select>
<SelectTrigger className="text-white w-[180px]flex gap-2 bg-[#1a1a1a] hover:bg-[#3e3d3d] ring-none border-none ">
<Globe />
<SelectValue placeholder="English" />
</SelectTrigger>
<AnimatePresence>
<SelectContent className="bg-[#3e3d3d] text-white border-none p-[1px]">
<motion.div
initial={{ opacity: 0, height: 0, scale: 0.95 }}
animate={{
opacity: 1,
height: "auto",
scale: 1,
transition: {
type: "spring",
stiffness: 300,
damping: 30,
},
}}
exit={{
opacity: 0,
height: 0,
scale: 0.95,
transition: {
duration: 0.2,
},
}}
style={{ transformOrigin: "center" }}
>
<SelectGroup>
<SelectItem className=" focus:bg-[#1a1a1a] focus:text-white" value="eng">
English
</SelectItem>
<SelectItem className=" focus:bg-[#1a1a1a] focus:text-white" value="france">
Français
</SelectItem>
<SelectItem className=" focus:bg-[#1a1a1a] focus:text-white" value="spain">
Español
</SelectItem>
<SelectItem className=" focus:bg-[#1a1a1a] focus:text-white" value="deutsch">
Deutsch
</SelectItem>
<SelectItem className=" focus:bg-[#1a1a1a] focus:text-white" value="china">
ä¸å›½
</SelectItem>
</SelectGroup>
</motion.div>
</SelectContent>
</AnimatePresence>
</Select>
);
}
javascript Article's
30 articles in total
JavaScript is a versatile language for web development, enabling interactive and dynamic user experiences across all major browsers.
7 Developer Tools That Will Boost Your Workflow in 2025
read article
Creating a live HTML, CSS and JS displayer
read article
Designing for developers means designing for LLMs too
read article
Unique Symbols: How to Use Symbols for Type Safety
read article
Flutter vs React Native in 2025: A Comprehensive Comparison
read article
How To Build Beautiful Terminal UIs (TUIs) in JavaScript 2: forms!
read article
[Boost]
read article
Cómo Iniciar y Crecer como Desarrollador Frontend en 2025
read article
Building bun-tastic: A Fast, High-Performance Static Site Server (OSS)
read article
My React Journey: Project
read article
How to Use JavaScript to Reduce HTML Code: A Simple Example
read article
Easy Discount Calculation: Tax, Fees & Discount Percentage Explained
read article
GraphQL Transforming API Development
read article
7 Mistakes Developers Make When Learning a New Framework (and How to Avoid Them)
read article
Why Is Everyone Unhappy With JavaScript? | State of Javascript 2024 Survey
read article
Decreasing server load by using debouncing/throttle technique in reactjs
read article
What is Next Js: A Beginner's guide to Next Js
read article
Angular Addicts #33: NgRx 19, using the Page Object Model in tests, Micro Frontends using Vite & more
read article
Debugging Adventure Day 1: What to Do When Your Code Doesn’t Work
read article
10 Must-Bookmark Open Source Projects for Developers
read article
Build a Secure Password Generator with Javascript
read article
Everything you need to know about load testing concurrent users
read article
forms in the terminal w/ JavaScript? if you love Terminal UI's check this out!
read article
340+ Websites every developer should know
read article
Learning Vue
read article
Test Scenarios vs. Test Cases: Understanding the Differences
read article
LeetCode Challenge: 290. Word Pattern - JavaScript Solution 🚀
read article
Understanding Node.js Cluster: The Core Concepts
read article
Speed Up Your Frontend Development 10x with These Mock Tools 🚀
read article
[Boost]
read article
Featured ones: