Search documentation v0.8.1

3D Card

Add 3D effects to your cards

Source ↗️ Report Issue ↗️

Use the Card3D component to add depth with a 3D effect to your cards, and create more engaging user experience. They can create a modern, polished look and enhanced visual for your call to actions:

Hover on me for 3D animation.

Unlock code
How to use the Card3D component in Astro
<Card3D secondary={true}>
<p>Hover on me for 3D animation.</p>
</Card3D>
You can use any existing Card component prop with the Card3D component.

Effect Intensity

You can increase the intensity of the 3D effect using the rotateDegree prop. By default, the card is rotated by 15° on hover. Specify the rotateDegree prop to change the intensity of the effect:

Rotation degree set to 45°

Unlock code
How to increase rotation amount
<Card3D secondary={true} rotateDegree={45}>
<p>Rotation degree set to 45°</p>
</Card3D>

Configuring Glow

When the card is hovered, a glow effect will follow the cursor. This can be turned off by setting the glow prop to false, or its size can be modified by setting the glowSize prop:

Glow turned off

Glow set to 75px

Unlock code
No glow
<Card3D secondary={true} glow={false}>
<p>Glow turned off</p>
</Card3D>
Unlock code
Glow set to 75px
<Card3D secondary={true} glowSize="75px">
<p>Glow set to 75px</p>
</Card3D>

Glow Colors

The colors of the glow can also be configured using the startColor and stopColor props. Note that you want to set the colors to semi transparent using the alpha channel (eg using RGBA colors), otherwise the effect will mask the underlying content:

Glow without semi-transparent colors

Unlock code
How to customize glow colors
<Card3D
secondary={true}
startColor="var(--w-color-primary-50)"
stopColor="var(--w-color-primary-70)"
>
<p>Glow without semi-transparent colors</p>
</Card3D>

API

Unlock code
Component API reference
type Card3DProps = {
rotateDegree?: number
glow?: boolean
glowSize?: string
startColor?: string
stopColor?: string
} & CardProps
Please see the documentation of the Card component for the CardProps type.
PropDefaultPurpose
rotateDegree 15 Sets the rotation amount on hover.
glow true Shows a glow effect on hover.
glowSize - Sets the radious of the glow.
startColor rgba(255, 255, 255, .10) Sets the starting (inner) color of the glow.
stopColor rgba(0, 0, 0, 0) Sets the ending (outer) color of the glow.

Request improvement for this page