BloksAtomAnimated Gradient Text

Animated Gradient Text

Description

The Animated Gradient Text component is a versatile and visually appealing text element that features an animated gradient background. It allows for customization of text content, heading level, font size, font weight, and gradient colors. The component creates a dynamic, eye-catching effect by animating multiple radial gradients, making it ideal for headlines, titles, or any text that needs to stand out.

Installation

bash
sabaccui add animatedGradientText

Usage

Here are examples of how to use the Animated Gradient Text component with different configurations:

Large Heading

Preview

Welcome to our site! (Gradient text)

Subtle Gradient Effect

Preview

Subtle gradient effect (Gradient text)

Schema

Field NameTypeDescriptionDefault Value
texttextThe text content to be displayed-
colorstextareaA list of color codes, each on a new line, used for the gradient effect-
speednumberThe animation speed of the gradient effect0
leveloptionThe HTML heading level or paragraph tag for the texth1
sizeoptionThe font size of the text-
weightoptionThe font weight of the text-

Field Details:

  • text: The main content of the component. It supports plain text input.
  • colors: A required field where you specify the colors for the gradient. Each color should be on a new line and can be in any valid CSS color format (e.g., hex, rgb, rgba).
  • speed: Controls the animation speed of the gradient. Higher values result in faster movement.
  • level: Determines the HTML tag used for the text. Options are:
    • h1
    • h2
    • h3
    • h4
    • p
  • size: Sets the font size of the text. Options are:
    • 9xl
    • 7xl
    • 5xl
    • 3xl
    • xl
    • lg
  • weight: Defines the font weight of the text. Options are:
    • Bold
    • Semibold
    • Light

Notes

  1. The component uses Vue 3 composition API and TypeScript for enhanced type safety and improved code organization.
  2. The gradient animation is implemented using requestAnimationFrame for smooth performance.
  3. The component automatically adjusts the gradient position and animation based on the specified colors and speed.
  4. The gradient effect is created using multiple radial gradients, which are dynamically generated and animated.

Best Practices:

  • Use contrasting colors in the gradient for better visibility of the text.
  • Adjust the speed carefully to ensure the animation is not distracting from the content.
  • Consider the context where the component is used; highly animated text may not be suitable for all parts of a website.
  • Test the component across different devices and screen sizes to ensure readability and performance.