BloksAtomGradient Text

Gradient Text

Description

The Gradient Text component is a versatile text element that allows for the creation of visually appealing gradient text. It supports various heading levels, text sizes, font weights, and custom gradient color combinations. This component is ideal for creating eye-catching titles, headings, or emphasized text with a unique gradient effect.

Installation

bash
sabaccui add gradientText

Usage

Here are some examples of how to use the Gradient Text component:

Gradient Text

Preview

Welcome to our website

Custom Gradient Colors

Preview

Discover our services

Schema

Field NameTypeDescriptionDefault Value
texttextareaThe text content to be displayed with the gradient effect. This field is required and translatable.None
leveloptionThe HTML element to be used for rendering the text. Options include h1, h2, h3, h4, and p.h2
sizeoptionThe size of the text. Options include 9xl, 7xl, 5xl, 3xl, xl, lg, and sm.None
weightoptionThe font weight of the text. Options include bold, semibold, and light.None
colorstextareaA list of colors to be used in the gradient, separated by new lines.None

Notes

  1. The component uses Vue 3 with the Composition API and TypeScript.
  2. The gradient effect is achieved using CSS linear-gradient and background-clip: text.
  3. The component dynamically renders the appropriate HTML element based on the level prop.
  4. Text size and weight are controlled through Tailwind CSS classes.
  5. The gradient colors are parsed from the colors field, which expects each color on a new line.

Best Practices:

  • Use contrasting colors in the gradient to ensure readability.
  • Consider the context and hierarchy when choosing the text level and size.
  • For accessibility, ensure sufficient color contrast between the gradient text and its background.
  • Limit the use of very large text sizes (e.g., 9xl) to maintain a balanced layout.
  • Test the component with various color combinations and background colors to ensure optimal visibility.