Modus UI

Text Pressure

Web (React)

A responsive variable-font typography effect that reacts fluidly to the cursor's proximity.

A highly interactive variable-font typography component. It dynamically adjusts the weight, width, and italic properties of individual characters based on their distance to the user's mouse cursor.

Installation

CLI

npx @modus-ui/cli add text-pressure

Manual

  1. Copy the code from the component tab.
  2. Create a file at components/ui/text-pressure.tsx.
  3. Paste the code.

Usage

tsx
import { TextPressure } from "@/components/ui/text-pressure";

export default function Example() {
  return (
    <div className="h-64 w-full">
      <TextPressure text="Modus" width={true} weight={true} italic={true} />
    </div>
  );
}

Props

PropTypeDefaultDescription
textstring"Pressure"The text to render.
fontFamilystring"Roboto Flex"Variable font family to use.
fontUrlstring"https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,wdth,wght@8..144,25..151,100..1000&display=swap"Stylesheet URL that loads the variable font.
widthbooleantrueVaries the font width with cursor distance.
weightbooleantrueVaries the font weight with cursor distance.
italicbooleantrueVaries the italic axis with cursor distance.
alphabooleanfalseVaries letter opacity with cursor distance.
flexbooleantrueSpreads the letters across the container.
strokebooleanfalseDraws an outline around the letters.
scalebooleanfalseStretches the text vertically to fill the container.
textColorstring"hsl(var(--foreground))"Text colour.
strokeColorstring"hsl(var(--foreground))"Outline colour when stroke is on.
strokeWidthnumber2Outline width in pixels.
minFontSizenumber24Minimum font size in pixels.

Comments

  • No comments yet.