> For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt.

# -x-auto-font-size

APISummary
## 介绍

`-x-auto-font-size` 属性设置是否开启文本自适应调整字号大小功能，最小的文本字号，最大的文本字号，字号调整的粒度值，除一个参数其余可省略。

## 使用示例

**下面是一个示例: css-api**

**Entry:** `src/-x-auto-font-size`
**Bundle:** `dist/-x-auto-font-size.lynx.bundle`

```tsx
import { root } from "@lynx-js/react";
import "./index.scss";

const XAutoFontSize = () => {
  const containerStyle = {
    display: "linear" as const,
    backgroundColor: "white",
  };

  const baseTextStyle = {
    backgroundColor: "gray",
    fontSize: "20px",
    overflow: "hidden",
  };

  const autoFontStyle = {
    ...baseTextStyle,
    XAutoFontSize: "true",
  };

  const autoFontWithSizeStyle = {
    ...baseTextStyle,
    XAutoFontSize: "true 10px",
  };

  const autoFontWithRangeStyle = {
    ...baseTextStyle,
    XAutoFontSize: "true 10px 50px",
  };

  const autoFontWithStepStyle = {
    ...baseTextStyle,
    XAutoFontSize: "true 10px 50px 3px",
  };

  const presetSizesStyle = {
    ...baseTextStyle,
    XAutoFontSize: "true",
    XAutoFontSizePresetSizes: "10px 16px 25px",
  };

  const sampleText = "This is a test text for auto-sizing font This is a test text for auto-sizing font";

  return (
    <view className="intro" style={containerStyle}>
      <text text-maxline="1" style={autoFontStyle}>
        {sampleText}
      </text>

      <text text-maxline="1" style={autoFontWithSizeStyle}>
        {sampleText}
      </text>

      <text text-maxline="1" style={autoFontWithRangeStyle}>
        {sampleText}
      </text>

      <text text-maxline="1" style={autoFontWithStepStyle}>
        {sampleText}
      </text>

      <text text-maxline="1" style={presetSizesStyle}>
        {sampleText}
      </text>
    </view>
  );
};

root.render(<XAutoFontSize />);

```

v0.11.0



## 语法

```css
-x-auto-font-size: 'true';
-x-auto-font-size: 'true 10px';
-x-auto-font-size: 'true 10px 30px';
-x-auto-font-size: 'true 10px 30px 2px';
```

### 取值

- 第一个参数，表示是否开启文本自适应调整字号大小功能，true 表示开启，false 表示关闭

- 第二个参数，表示最小的文本字号，取值为 [`<length>`](/next/zh/api/css/data-type/length.md)，此参数可省略

- 第三个参数，表示最大的文本字号，取值为 [`<length>`](/next/zh/api/css/data-type/length.md)，此参数在存在前两个参数时可省略

- 第四个参数，表示字号调整的粒度值，取值为 [`<length>`](/next/zh/api/css/data-type/length.md)，此参数在存在前三个参数时可省略，默认值为 1px

## 形式定义

| 初始值 | false |
| 适用元素 | text |
| 是否支持继承 | no |
| 是否支持动画 | no |


## 形式语法

```
-x-auto-font-size = true (<length>){0,3} | false
```

## 与 Web 的区别

- Lynx 特有的属性。

## 兼容性

**Compatibility Table**

**Query:** `css.properties.-x-auto-font-size`

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/197--x-auto-font-size.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| -x-auto-font-size | Yes (1.0) | No | Yes (1.0) | Yes (3.2) | Yes (3.2) | No |

**`-x-auto-font-size`**

**Specifications:**

