This UI component library is mind-blowing

Beyond Fireship
24 Feb 202408:23

Summary

TLDRThe video introduces aity UI, a React component library inspired by Shad CN UI that brings animated and interactive elements to web applications. It allows developers to easily implement effects like scrolling animations, responsive SVGs, and text generation with minimal coding. The presenter analyses some of these effects to uncover the code powering the interactivity. From path-based SVG animations to mouse tracking gradients and staggered text reveals, aity leverages modern web technologies like Tailwind, Framer Motion, and Canvas to enable developers to quickly build visually appealing UIs with rich motion designs.

Takeaways

  • 🔥 Shad CN UI is a unique UI library that stands out for its copy-and-paste approach, allowing more control over UI components by incorporating them directly into projects.
  • 📢 The video introduces Aternity UI, a library inspired by Shad CN but with additional features like animations and effects, catering to developers seeking to enhance UI with minimal effort.
  • 💻 Aternity UI is particularly beneficial for React, Tailwind, and Framer Motion users, though it can inspire developers using any framework due to its innovative components.
  • 💡 The library offers a wide range of animations and effects, such as encrypted text, laser beams, and animated plasma waves, showcasing its versatility for creative UI design.
  • 🔧 Aternity UI's approach enables developers to directly manipulate component code, offering unparalleled customization and control compared to traditional UI libraries.
  • 📚 Documentation and usage examples highlight the library's ease of use, showing how developers can quickly integrate complex animations and effects into their projects.
  • 👨‍💻 The creator's background and the development agency behind Aternity UI suggest a strong foundation in web development and custom component design.
  • 📈 The video emphasizes the concept of 'copy and paste coding' as a viable and efficient method for implementing and customizing UI components, challenging traditional development norms.
  • 👀 Advanced animations and effects, such as the MacBook scroll animation, demonstrate the library's capability to produce high-quality, interactive UI elements with minimal coding.
  • 🚀 Aternity UI's integration with Framer Motion and other libraries enables dynamic and visually appealing effects, making it a valuable resource for developers aiming to create standout UIs.

Q & A

  • What is the Shad CN UI library and what makes it unique?

    -Shad CN is a UI component library that allows developers to copy and paste components directly into their projects rather than importing them. This gives more control over customization.

  • What dependencies and assumptions does the Aternity UI library require?

    -The Aternity UI library requires React, Tailwind and Framer Motion. It also assumes you are using those in your project to take full advantage.

  • How is the scrolling MacBook animation achieved?

    -The entire MacBook is built using HTML and CSS. Each key on the keyboard is a separate div. As the user scrolls, React components and Framer Motion animate the elements.

  • How does the Gemini animation work as you scroll?

    -It uses an SVG path with a length state that updates based on scroll position. As the path length grows on scroll, it animates the SVG lines.

  • How does the Sparkles text effect work?

    -It uses a canvas instead of DOM elements for efficiency. The tsParticles library generates the sparkly dots which works across frameworks.

  • What technique is used to achieve the typing text effect?

    -The words are split into an array, then staggered over time using Framer Motion's animation utilities.

  • How does the evervolt card create dynamic text and gradients?

    -It generates random text on hover with a loop. It also tracks mouse move to create a gradient with origin at the mouse position.

  • What causes the parallax distortion effect in the hero section?

    -As you scroll, different spring animations are applied to elements like rotation and scale, tied to scroll progress. This causes a depth/3D effect.

  • What are some good resources to learn more about React and NextJS?

    -The video creator has a full course on Fireship.io for learning NextJS and React in depth.

  • What is the overall purpose of the Aternity UI library?

    -To provide developers with pre-built animated components that can be quickly copied into projects to create impressive UI effects with less effort.

Outlines

00:00

😊 Overview of Shad CN UI Library and introducing aternity UI Library

This paragraph provides an overview of the Shad CN UI library, which allows developers to easily copy and paste reusable UI components into their apps instead of using a traditional component library. It then introduces aternity UI, a similar library that also incorporates Framer Motion for animation effects. Some example animations from aternity UI are shown.

05:01

🤓 Technical breakdown of some of the advanced animations in aternity UI

This paragraph dives into the technical implementation details behind some of the more complex animations in the aternity UI library: - The Gemini animation uses a Scalable Vector Graphic (SVG) path with animated length to create the line drawing effect - The Sparkles effect uses the canvas API and ts-particles library to efficiently render many animated elements - The text generation effect simply staggers each word's entrance animation - The evervolt card uses mouse position to dynamically generate random text and update the card's background gradient - The hero parallax effect ties scroll position to manipulate elements' transform properties like rotation and translation

Mindmap

Keywords

💡Shad CN UI

Shad CN UI is a popular UI component library for front-end web development. It provides pre-built UI components like buttons, forms, etc. that developers can easily add to their apps. The video says it is unique because instead of installing a package, you copy and paste the source code directly into your project for more control and customization.

💡code customization

The ability to customize code is a benefit of the copy-paste approach used by Shad CN UI and Aity UI. Since the full source code is copied into your project, you have more control to tweak and change the components compared to traditional installed packages.

💡Aity UI

Aity UI is the main focus of the video. It is a UI library inspired by Shad CN UI but adds motion and animations. You can copy-paste components like scrolling animations, particle effects, etc. It is aimed at React projects using Tailwind and Framer Motion.

💡Framer Motion

Framer Motion is an animation library for React. It is used by Aity UI to power its advanced animated components. The video analyzes some Aity components by showing how Framer Motion is used to drive the animations under the hood.

💡SVG animations

Scalable vector graphics (SVG) can be animated with code. The video shows how the Gemini animation uses an SVG path with Animotion to animate an SVG graphic based on scroll position. This creates the line drawing effect.

💡canvas animations

The HTML canvas element can render 2D animations and graphics efficiently. The Sparkles component uses the tsParticles library with canvas instead of DOM elements, allowing for many animated sparkle elements.

💡text effects

Aity UI includes components for advanced text effects like typing, scrambling, etc. These often split text into arrays of characters/words and animate them individually using Framer Motion's stagger functionality.

💡Parallax

Parallax is an effect where background images scroll at a different speed than foreground content, creating an illusion of depth. The hero parallax component uses scroll position and spring animations to change shape, rotation, etc. of elements.

💡lazy developers

The video says Aity UI is useful for "lazy developers" because you can simply copy-paste these advanced animations into projects without doing them from scratch. It caters to those looking for quick but powerful effects.

💡madman developer

The video playfully refers to the developer of Aity UI as "some kind of madman" implying that the complexity of the UI designs seems absurd, almost crazy. But web developers embrace complex solutions if the end result is visually appealing.

Highlights

Shad CN UI is an innovative UI library for front-end web development

Shad CN allows developers to easily copy and paste reusable UI components into their apps

Aternity UI is inspired by Shad CN but adds animations using Framer Motion

The MacBook scroll animation is built entirely using HTML and CSS

The Gemini animation uses SVG path length state and scroll position to animate the lines

The Sparkles effect uses the tsParticles library and canvas for efficient, complex animations

The text generation effect staggers each word's animation by 0.2 seconds

The evervolt card uses inefficient but impressive methods like random string generation

Parallax effects tie scroll position to spring animations to create depth

You can customize components since the source code is copied directly into your project

The creator behind Aternity UI seems to value visual appeal over efficient code

Effects like mouse position tracking show how UI tricks are implemented

Strategically layering animations creates impressive parallax 3D effects

Aternity UI is a useful source of inspiration even for non-React developers

The library contains many more impressive animated UI components to explore

Transcripts

play00:00

one of the most hyped up UI libraries in

play00:01

the front-end World recently has been

play00:03

Shad CN UI but that's not what this

play00:05

video is about it's about another

play00:07

Library inspired by it that takes things

play00:09

to a whole another level and it's a

play00:10

total gold mine for lazy developers like

play00:13

me like if you're building an app to get

play00:14

in on the latest crypto fomo you can

play00:16

easily drop in this card to get this

play00:17

cool encrypted text effect or maybe you

play00:19

want to shoot a laser beam when you

play00:21

scroll down the page or how about some

play00:22

animated plasma waves for your hero

play00:24

section that's just a small sample of

play00:26

what you can do in today's video we'll

play00:27

learn how to use aity to build off aome

play00:30

uis faster but also dive into its code

play00:32

to learn the secrets behind its magic

play00:34

before we get into it though let's talk

play00:36

about the library that inspired it Shad

play00:38

Cen web developers already have tons of

play00:40

awesome component libraries like

play00:42

material chakra bootstrap and so on and

play00:44

at first glance Shad CN looks like yet

play00:46

another component Library it's got

play00:48

buttons forms progress bars and all the

play00:50

other components you'd expect what makes

play00:52

it unique is the way you actually use it

play00:53

in a project and know it has nothing to

play00:55

do with artificial intelligence it's

play00:57

based on a Cutting Edge new innovation

play00:59

called copy and paste you see normally

play01:01

when you install a UI Library it dumps a

play01:03

bunch of code into your node modules

play01:04

folder then you import each of these

play01:06

components in your code and customize

play01:07

their appearance with props you never

play01:09

actually see their implementation

play01:10

details which can be a good thing but

play01:12

can also be a problem if you want a lot

play01:13

of control to customize their appearance

play01:15

now if we take a look at the docs and

play01:17

Shaden you'll notice that instead of

play01:18

installing a package we use an npx

play01:20

command which will actually copy and

play01:22

paste the source code into your project

play01:24

and that gives you far more control over

play01:25

the code to change things as needed in

play01:27

other words it's not a component library

play01:29

but a collection of reusable components

play01:31

that you copy and paste into your app

play01:33

Shaden has dependencies of its own like

play01:35

tailwind and radex UI if you like Rix

play01:38

components which will give you that

play01:39

verell dashboard like look then Shad Cen

play01:41

is a highly efficient way to implement

play01:43

common UI components without doing

play01:45

everything on your own from scratch the

play01:46

creator of this project works for

play01:48

versell but it's not just for the react

play01:50

ecosystem there's also implementations

play01:51

in spelt and view but remember I said

play01:54

this video is not about Shad CN it's

play01:55

about a similar library that also brings

play01:57

in frame or motion to go crazy with the

play01:59

anim

play02:00

the library is called aternity UI they

play02:02

didn't pay me or sponsor this video but

play02:04

they're a web development agency that

play02:05

will also design custom components for

play02:07

you in exchange for money but all the

play02:09

base components are totally free in

play02:11

order to take advantage of them we need

play02:12

to make a couple assumptions about your

play02:14

project you're using react tailwind and

play02:16

frame or motion now even if you use a

play02:18

different framework like spelt in my

play02:19

case you should still keep this library

play02:21

on your radar because it's a good source

play02:22

of inspiration and you can always

play02:24

reverse engineer this stuff in your own

play02:25

framework but currently I'm in a vanilla

play02:27

nextjs project with Tailwind install

play02:30

what I want to do is add this cool

play02:31

MacBook scroll animation to my homepage

play02:33

when I first looked at it I thought that

play02:35

MacBook must be a PNG but get this the

play02:37

entire MacBook is HTML and CSS every key

play02:40

on the keyboard is its own div and react

play02:42

component it's crazy and the developer

play02:44

must be some kind of madman and we get

play02:46

to reap all the benefits let's begin the

play02:47

reaping process first we need to go and

play02:49

install the dependencies we've got

play02:51

framer motion which is the animation

play02:53

Library clsx which is for merging CSS

play02:56

class names Tailwind merge to merge

play02:58

classes in Tailwind without conflict and

play03:00

Tabler icons which is an icon Library

play03:02

once installed we need to create a

play03:04

utility file that exports a function to

play03:06

merge the class names together from

play03:08

there we need to update our Tailwind

play03:09

config file which also includes a

play03:11

utility function for adding Tailwind

play03:13

colors AS Global CSS variables but now

play03:16

it's time for the fun part we create a

play03:18

new component file then simply copy the

play03:20

code on the website here take it into

play03:21

our project and then paste it

play03:23

professional developers will use control

play03:24

V here to optimize speed but just be

play03:26

careful not to hurt yourself with Pro

play03:28

tips like that let's go ahead and serve

play03:30

the app locally and now we have this

play03:31

awesome animation with almost no effort

play03:33

on our part now one thing that's cool

play03:35

about this copy and paste approach is

play03:36

that we have full control over the code

play03:38

like for example if we look at the react

play03:40

code you can see we have a component for

play03:42

every key on the keyboard if we wanted

play03:43

to make this a Russian MacBook we could

play03:45

just manually change the keys to be slic

play03:47

or if we don't like the colors we could

play03:48

easily modify the tail one CSS code in

play03:51

other words we've got a great starting

play03:52

point that we can now build on it's

play03:53

really that easy but now I want to take

play03:55

a look at some of the more advanced

play03:56

animations in this library and talk

play03:58

about how they're actually done under

play03:59

the hood let's first start with this

play04:01

Gemini animation which you might

play04:02

recognize from Google's Gemini homepage

play04:05

as we scroll down the lines on this

play04:06

graphic become brighter it looks like

play04:08

this would be extremely difficult to

play04:09

pull off but it's actually easier than

play04:11

you think what you need first is a

play04:13

scalable Vector graphic in the SVG we

play04:15

have a path and that path has a length

play04:17

but notice how it's a motion path from

play04:19

the frame or motion library to make it

play04:21

invisible we can start the length at

play04:23

zero but then make the path length State

play04:25

on the react component that updates when

play04:27

the scroll position changes as the user

play04:29

Scrolls down the path length increases

play04:32

thus animating the SVG and you can see

play04:34

more examples of SVG line drawing in the

play04:36

frame R motion documentation but the

play04:38

next component I want to look at is

play04:39

Sparkles this one will add a bunch of

play04:41

sparkly dots below some text in your UI

play04:44

pretty fabulous but how does this one

play04:46

work in this one we're not using divs

play04:47

and CSS but instead using a canvas Which

play04:50

is far more efficient for highly complex

play04:52

animations with a lot of different

play04:53

elements the magic behind this component

play04:55

though comes from a different Library

play04:57

called TS particles this library is

play04:59

plain Java JavaScript and framework

play05:00

agnostic which means if you like this

play05:02

effect it should be relatively easy to

play05:04

implement in any framework next up we've

play05:06

got the text generate effect this effect

play05:08

simply types out text on the screen Like

play05:10

Oxygen gets you high in a catastrophic

play05:12

emergency we're talking giant Panic

play05:14

breaths suddenly you become euphoric

play05:17

docile you accept your fate it's all

play05:19

right here emergency water Landing 600

play05:21

mph blank faces Cal as Hindu cows the

play05:24

developer chose a quote from Fight Club

play05:26

which is further evidence that there's

play05:27

some kind of madman behind this project

play05:29

the this effect is done is pretty easy

play05:31

you first take the initial words and

play05:32

split them into an array then frame or

play05:34

motion has a utility that allows you to

play05:36

stagger animations so we simply offset

play05:38

each word by 0 2 seconds and animate

play05:40

each one in individually but now let's

play05:42

check out an example with some more

play05:44

complex text manipulation the evervolt

play05:46

card component looks pretty simple at

play05:47

first glance but when you hover over it

play05:49

you'll notice it has some text in the

play05:51

background that's constantly changing As

play05:52

you move the mouse around in addition

play05:54

the gradient in the background is

play05:56

generated based on the mouse position if

play05:58

we look at the code you can see there's

play05:59

is a function called Generate random

play06:01

string inside this function we just have

play06:02

a string of characters which is followed

play06:04

by an empty string called result then we

play06:06

have a for Loop that picks out random

play06:08

characters from the original string to

play06:09

build out a new string the loop runs

play06:11

based on the length argument to this

play06:12

function which in this demo is500 that

play06:15

seems pretty inefficient for something

play06:16

that's purely cosmetic but in JavaScript

play06:18

development this is the way if it looks

play06:20

cool the code is correct even if the

play06:22

code is not super efficient it doesn't

play06:24

really matter because the end user is

play06:25

only going to hover over it for a couple

play06:27

seconds at most now the other part of

play06:28

this component is the gradient in the

play06:30

background the component is also

play06:32

tracking the mouse move event on the div

play06:34

itself and when that event happens we're

play06:36

calling the get bounding client wct

play06:38

method which provides information about

play06:40

where that element actually is in the

play06:41

browser window it then does some math

play06:43

with the mouse position in the viewport

play06:45

and that div to figure out where the

play06:46

mouse is specifically in the div then we

play06:48

pass those values to frame or motion

play06:50

with the use motion value hook then in

play06:52

the actual jsx we have a mask image that

play06:55

displays a gradient in the background

play06:56

with an origin that starts at the mouse

play06:58

X and mouse y positions so basically

play07:00

anytime the mouse position changes we

play07:02

repaint the gradient on the screen and

play07:04

also regenerate a 1500 character random

play07:07

string and I have to say the end result

play07:08

is really cool the next effect I want to

play07:10

look at is the hero Parallax with this

play07:12

effect you'll notice that when we scroll

play07:14

down the graphics change their shape and

play07:16

rotation and eventually stick to the

play07:17

screen and start scrolling horizontally

play07:19

I made a video about Parallax in the

play07:21

past which I'll link in the description

play07:23

but the general idea is that as you

play07:25

scroll down the elements in the

play07:26

background move at a different speed

play07:27

than one would expect we're looking at a

play07:29

2d screen so we expect everything to

play07:31

move at the same speed but in real life

play07:33

in a 3D World the displacement of

play07:35

objects is different based on the

play07:36

observer's point of view things close to

play07:38

you move fast but things far away move

play07:40

slowly in this demo you can see we have

play07:42

a bunch of different spring animations

play07:43

here that control different effects like

play07:45

rotation opacity and movement along the

play07:48

X and Y AIS every single one of these

play07:50

animations though is tied to the scroll

play07:52

y progress we get that value from frame

play07:54

REM motion with a react hook in the UI

play07:57

we can then strategically add these

play07:58

different effects to different rows of

play08:00

cards to get the desired effect this

play08:02

process can be pretty painstaking but

play08:04

there are some websites out there that

play08:05

go all out with things like 3js to

play08:07

create these amazing 3D experiences on

play08:09

the web now there's a ton of other UI

play08:11

elements that we could look at in this

play08:13

library but you might as well just go

play08:14

out and try them for yourself if you

play08:15

want to learn more about nextjs and

play08:17

react check out my full course on

play08:19

fireship iio thanks for watching and I

play08:21

will see you in the next one