@charmy.tech/react-native-stroke-text

中文文档
1.2.3发布于 2025/03/27MITTypeScriptCommonJS零依赖构建来源已验证近 30 天下载 9166

React Native Stroke/Outline Text

原始使用文档
文档目录11 节
  1. Installation
  2. Android
  3. iOS
  4. Usage
  5. Props
  6. Ellipsis
  7. Custom Font
  8. Bare React Native
  9. Expo ( expo-font )
  10. Contributing
  11. License

React Native Stroke/Outline Text

npm version

Allows you to add stylish text with stroke effects to your mobile applications. It is perfect for creating visually appealing text elements with outline effects.

Installation

npm install @charmy.tech/react-native-stroke-text
# or
yarn add @charmy.tech/react-native-stroke-text

Android

min compileSdkVersion is required to be 34

iOS

Go to your ios folder and run:

pod install

Usage

Here's a quick example to get you started with StrokeText:

import React from "react";
import { StrokeText } from "@charmy.tech/react-native-stroke-text";
import { View } from "react-native";

export default function Screen() {
  return (
    <View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
      <StrokeText
        text="Test"
        fontSize={50}
        color="#000000"
        strokeColor="#c334eb"
        strokeWidth={20}
        fontFamily="Nunito-Black"
      />
    </View>
  );
}

Props

The following table outlines the props available for the StrokeText component:

PropTypeDescription
textstringThe text content you want to display.
fontSizenumberSize of the text font, defining how large the text will be.
colorstringColor of the text, can use any valid color format.
strokeColorstringColor of the stroke (outline) around the text.
strokeWidthnumberWidth of the stroke, determining the thickness of the outline.
fontFamilystringFont family for the text, should match available project fonts.
alignstringText alignment (default: center)
numberOfLinesnumberNumber of lines (default: 0)
ellipsisbooleanEllipsis (...) (default: false)
widthnumberText width to enable ellipsis (default: undefined)

Ellipsis

<StrokeText
  text="Lorem ipsum"
    width={150} // +
    ellipsis={true} // +
    numberOfLines={1} // +
  fontSize={32}
  color="#FFFFFF"
  strokeColor="#000000"
  strokeWidth={2}
  fontFamily="Nunito-Black"
  align="center"
/>

Custom Font

Bare React Native

Create a react-native.config.js file in the root directory

module.exports = {
  project: {
    ios: {},
    android: {},
  },
  assets: ['/assets/fonts'], // or './src/assets/fonts'
};

Expo (expo-font)

import { useFonts } from "expo-font";
import { Dosis_400Regular } from "@expo-google-fonts/dosis";


const [fontsLoaded, fontError] = useFonts({
  Danfo: require("./src/assets/fonts/Danfo-Regular.ttf"),
  "Dosis-Regular": Dosis_400Regular,
});

Contributing

We welcome contributions to improve this component. Feel free to submit issues and enhancement requests.

License

Please refer to the project's license for usage rights and limitations.

版本与发布记录

@charmy.tech/react-native-stroke-text 共发布 15 个版本,首次发布于 2024/01/22;过去 12 个月发布了 0 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.2.3latest2025/03/271.6 年前
1.2.22024/06/102 年前
1.2.02024/06/032 年前
1.1.22024/06/012 年前
1.1.12024/05/032 年前
1.1.02024/04/192 年前

关于 @charmy.tech/react-native-stroke-text 的常见问题

@charmy.tech/react-native-stroke-text 是什么?

React Native Stroke/Outline Text

如何安装 @charmy.tech/react-native-stroke-text?

在项目目录运行 npm install @charmy.tech/react-native-stroke-text,或使用 pnpm add / yarn add / bun add。

@charmy.tech/react-native-stroke-text 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@charmy.tech/react-native-stroke-text 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@charmy.tech/react-native-stroke-text 可以商用吗?

@charmy.tech/react-native-stroke-text 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@charmy.tech/react-native-stroke-text 的下载量有多少?

根据 npm 官方下载统计,@charmy.tech/react-native-stroke-text 在 2026/10/10 – 2026/11/08 这 30 天内被下载 9,166 次,日均约 306 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@charmy.tech/react-native-stroke-text 还在维护吗?

最新版本 1.2.3 发布于 2025/03/27(1.6 年前);至今共发布 15 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/01/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。