Docs
Text Cloud

Text Cloud

Interactive text cloud component

Installation

Copy and paste the following code into your project.

npm i @frank-mayer/react-tag-cloud
components/snippet/icon-cloud.tsx
"use client"
 
import { TagCloud } from "@frank-mayer/react-tag-cloud";
 
interface TextCloudProps {
  iconSlugs: string[];
}
 
const TextCloud = ({ iconSlugs }: TextCloudProps) => (
  <TagCloud
    options={(w) => ({
      radius: 200,
      maxSpeed: "normal",
      initSpeed: "normal",
      keep: true,
    })}
    onClickOptions={{ passive: true }}
  >
    {...iconSlugs}
  </TagCloud>
);
 
 
export default TextCloud;

Props

TextCloud

NameTypeDescription
containerString or HTMLElement or ArrayContainer for constructing a tagcloud.
textsArrayList of tag text for init.
optionsObjectOptions for the tagcloud.
options.radiusNumberDefault: 100, Unit: px, Rolling radius.
options.maxSpeedOptional: 'slow', 'normal', 'fast'Default: 'normal', Rolling max speed.
options.initSpeedOptional: 'slow', 'normal', 'fast'Default: 'normal', Rolling init speed.
options.directionNumberDefault: 135 (right-bottom), Unit: clockwise deg, Rolling init direction.
options.keepBooleanDefault: true, Whether to keep rolling after mouse out area.
options.reverseDirectionBooleanDefault: false, Whether to reverse the direction when the mouse controls the direction.
options.containerClassStringDefault: tagcloud, Css class to be used for the tagcloud container.
options.itemClassStringDefault: tagcloud--item, Css class to be used for tagcloud items.
options.useContainerInlineStylesBooleanDefault: true, Add inline styles to the tagcloud container.
options.useItemInlineStylesBooleanDefault: true, Add common inline styles to the items.
options.useHTMLBooleanDefault: false, Add html tags with text.

Instance Methods

  • tagcloud.update(texts): Update tag list.
  • tagcloud.pause(): Pause the tagcloud animation.
  • tagcloud.resume(): Resume the tagcloud animation.
  • tagcloud.destroy(): Destroy the tagcloud instance.

Credits