Holofoils
React UI Component
Inspired by the work of simeydotme and Paco Coursey.
Follow the directions below to start using holofoil cards in your own React or NEXT.js project. Customize the cards using your own images, component props, and custom styling. Checkout the gallery of examples below and continue reading to see the code.
Pink Floyd Playbutton
Bitcoin
React.js
Steps
- Create a file called,
HolofoilTemplate.jsx
in the /components folder. - Copy the code below and paste it into the new component file. Note, if using VS Code, press Shift+Alt+F for Windows (Cmd+k+f for Mac) to quickly fix any formatting issues.
- Add a main, foreground image to the public folder. Add the absolute url string to the
foregroundImage
prop of the HolofoilTemplate.jsx component. There is a code comment in the desctructured props pointing to the correct place to put the url. - In the same folder as the component, create a second file called,
HolofoilTemplate.module.css
- Copy the code below and paste it into the new component file.
- Add a background image to the public folder. Note: A good background image typically consists of a random or repeating white pattern on a black background.
- Add the relative url pointing to the background image, to the
--pattern
CSS variable (found within the.foil
class). There is a code comment in the CSS pointing to the correct place to put the url. - Import and add the
<HolofoilTemplate />
component to a page. Hover over the holofoil and see how it works!
Future Enhancements
- Set the background image in props instead of manually in CSS.
- Stack multiple layers of foreground images and apply the “foil” effect only to specific layers (specified with a prop).
- Fix the CSS properties causing clunky pitch (x-axis) and yaw (y-axis) rotation animations in the Mozilla browser.