> 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.

# color

APISummary
## 介绍

`color` 属性指定文本的颜色，也支持通过 gradient 设置文本渐变色效果。

## 使用示例

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

**Entry:** `src/color`
**Bundle:** `dist/color.lynx.bundle`

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

const Color = () => {
  const scrollViewStyle = {
    height: "100%",
  };

  const fixedAreaStyle = {
    width: "100%",
    height: "100%",
    flexDirection: "column" as const,
  };

  return (
    <scroll-view className="root" scroll-orientation="vertical" style={scrollViewStyle}>
      <view className="fixed_area" style={fixedAreaStyle}>
        <text className="container text2 font_style">Hello World</text>
        <text className="container text3 font_style">Hello World</text>
        <text className="container text4 font_style">Hello World</text>
        <text className="container text5 font_style">Hello World</text>
        <text className="container text6 font_style">Hello World</text>
        <text className="container text7 font_style">Hello World</text>
        <text className="container text8 font_style">Hello World</text>
        <text className="container text9 font_style">Hello 😄 😄 World</text>
      </view>
    </scroll-view>
  );
};

root.render(<Color />);

```

v0.11.0



## 语法

```css
/* <named-color> values */
color: red;
color: orange;
color: tan;

/* <hex-color> values */
color: #090;
color: #009900;
color: #090a;
color: #009900aa;

/* <rgb()> values */
color: rgb(34, 12, 64, 0.6);
color: rgba(34, 12, 64, 0.6);
color: rgb(34 12 64 / 0.6);
color: rgba(34 12 64 / 0.3);
color: rgb(34 12 64 / 60%);
color: rgba(34.6 12 64 / 30%);

/* <hsl()> values */
color: hsl(30, 100%, 50%, 0.6);
color: hsla(30, 100%, 50%, 0.6);
color: hsl(30 100% 50% / 0.6);
color: hsla(30 100% 50% / 0.6);
color: hsl(30 100% 50% / 60%);
color: hsla(30.2 100% 50% / 60%);
```

### 取值

- [`<color>`](/next/zh/api/css/data-type/color.md)

- [`<gradient>`](/next/zh/api/css/data-type/gradient.md)

## 形式定义

| 初始值 | 透明色 |
| 适用元素 | text |
| 是否支持继承 | no |
| 是否支持动画 | yes |


## 形式语法

```
<color> | <gradient>
```

## 注意事项

为 `gradient` 类型时，只有 `text` 元件有效。

## 兼容性

**Compatibility Table**

**Query:** `css.properties.color`

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/22-color.json) · [MDN](https://developer.mozilla.org/zh-CN/docs/Web/CSS/color)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| color | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |

**`color`**

**Specifications:**

