Hover 3D Card | jaspr_daisyui_components
jaspr_daisyui_components
pub.dev ↗

Hover 3D Card

Hover 3D is a wrapper component that adds a 3D hover effect to its content. When we hover over the component, it tilts and rotates based on the mouse position, creating an interactive 3D effect.

Class name Type Description
hover-3d Component Hover 3D wrapper component

hover-3d works by placing 8 hover zones on top of the content. Each zone detects mouse movement and applies a slight rotation to the content based on the mouse position within that zone. The combined effect of all 8 zones creates a smooth and responsive 3D tilt effect as the user moves their mouse over the component.

Only use non-interactive content inside the hover-3d wrapper. If you want to make the entire card clickable, use a link for the whole hover-3d component instead of putting interactive elements like buttons or links inside it.

3D image hover effect

Hover to see the 3D effect
Tailwind CSS 3D card
<div class="hover-3d">
  <!-- content -->
  <figure class="max-w-100 rounded-2xl">
    <img src="https://img.daisyui.com/images/stock/creditcard.webp" alt="3D card" />
  </figure>
  <!-- 8 empty divs needed for the 3D effect -->
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
</div>
Hover3d(
  [
    figure(
      [
        img(src: 'https://img.daisyui.com/images/stock/creditcard.webp', alt: '3D card'),
      ],
      classes: 'max-w-100 rounded-2xl',
    ),
    div(const []),
    div(const []),
    div(const []),
    div(const []),
    div(const []),
    div(const []),
    div(const []),
    div(const []),
  ],
);

3D card hover effect

The whole card can be a link
BANK OF LATVERIA
❁
0210 8820 1150 0222
CARD HOLDER
VICTOR VON D.
EXPIRES
29/08
<a href="#" class="hover-3d my-12 mx-2 cursor-pointer">
  <!-- content -->
  <div class="card w-96 bg-black text-white bg-[radial-gradient(circle_at_bottom_left,#ffffff04_35%,transparent_36%),radial-gradient(circle_at_top_right,#ffffff04_35%,transparent_36%)] bg-size-[4.95em_4.95em]">
    <div class="card-body">
      <div class="flex justify-between mb-10">
        <div class="font-bold">BANK OF LATVERIA</div>
        <div class="text-5xl opacity-10">❁</div>
      </div>
      <div class="text-lg mb-4 opacity-40">0210 8820 1150 0222</div>
      <div class="flex justify-between">
        <div>
          <div class="text-xs opacity-20">CARD HOLDER</div>
          <div>VICTOR VON D.</div>
        </div>
        <div>
          <div class="text-xs opacity-20">EXPIRES</div>
          <div>29/08</div>
        </div>
      </div>
    </div>
  </div>
  <!-- 8 empty divs needed for the 3D effect -->
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
</a>
a(
  [
    Card(
      [
        CardBody(
          [
            div(
              [
                div([Component.text('BANK OF LATVERIA')], classes: 'font-bold'),
                div([Component.text('❁')], classes: 'text-5xl opacity-10'),
              ],
              classes: 'flex justify-between mb-10',
            ),
            div([Component.text('0210 8820 1150 0222')], classes: 'text-lg mb-4 opacity-40'),
            div(
              [
                div(
                  [
                    div([Component.text('CARD HOLDER')], classes: 'text-xs opacity-20'),
                    div([Component.text('VICTOR VON D.')]),
                  ],
                ),
                div(
                  [
                    div([Component.text('EXPIRES')], classes: 'text-xs opacity-20'),
                    div([Component.text('29/08')]),
                  ],
                ),
              ],
              classes: 'flex justify-between',
            ),
          ],
        ),
      ],
      classes: 'w-96 bg-black text-white bg-[radial-gradient(circle_at_bottom_left,#ffffff04_35%,transparent_36%),radial-gradient(circle_at_top_right,#ffffff04_35%,transparent_36%)] bg-size-[4.95em_4.95em]',
    ),
    div(const []),
    div(const []),
    div(const []),
    div(const []),
    div(const []),
    div(const []),
    div(const []),
    div(const []),
  ],
  classes: 'hover-3d my-12 mx-2 cursor-pointer',
  href: '#',
);