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

# 视觉表现

## 边框与背景

我们为你提供了多种样式属性用于给元件添加背景图片，圆角，边框和阴影。例如你可以通过 [`background-image`](/next/zh/api/css/properties/background-image.md) 属性为元件添加
来自网络的图片或是渐变；通过 [`border-radius`](/next/zh/api/css/properties/border-radius.md) 属性为元件添加圆角; 通过 [`box-shadow`](/next/zh/api/css/properties/box-shadow.md) 来为元件添加阴影。

下面的例子中，我们为元件添加了圆角、阴影、渐变色的背景和多种样式的边框：

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

**Entry:** `src/border_background_shadow`
**Bundle:** `dist/border_background_shadow.lynx.bundle` | Web: `dist/border_background_shadow.web.bundle`

```tsx {8-12}
import { root } from "@lynx-js/react";

function App() {
  return (
    <view
      style={{
        flexDirection: "column",
        background: "linear-gradient(to right, rgb(255,53,26), rgb(0,235,235))",
        borderRadius: "0 50% 0 0",
        boxShadow: "3px 5px 5px black",
        borderLeft: "2px rgb(0,235,235) dotted",
        borderTop: "2px rgb(255,53,26) dashed",
        marginTop: "50%",
        transform: "translate(-50%, -50%)",
        marginLeft: "50%",
        width: "150px",
        height: "150px",
      }}
    >
    </view>
  );
}

root.render(<App />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.8.0



:::info

[`border-image`](https://developer.mozilla.org/en-US/docs/Web/CSS/border-image) 相关样式正在开发中，目前暂不支持。

:::

## 颜色

通过 Lynx 样式属性，你可以为元件应用各式各样的颜色。通过将颜色设置给对应的属性，来修改元件的外观。

### 可以设置颜色的属性

#### 文本

- [`color`](/next/zh/api/css/properties/color.md)：修改用于绘制文本的颜色。
- [`-x-handle-color`](/next/zh/api/css/properties/-x-handle-color.md)：用于调整选中文本时，选中区域两段浮标的颜色。
- [`text-shadow`](/next/zh/api/css/properties/text-shadow.md)：设置文本的阴影特效的颜色。
- [`text-decoration-color`](/next/zh/api/css/properties/text-decoration.md#text-decoration-color)：文本装饰线的颜色。

#### 边框与背景

- [`background-color`](/next/zh/api/css/properties/background-color.md)：元件的背景填充色。
- [`box-shadow`](/next/zh/api/css/properties/box-shadow.md)：配置阴影区域的颜色。
- [`border-color`](/next/zh/api/css/properties/border-color.md)：设置用于绘制边框的颜色。也可以通过 [`border-top-color`](/next/zh/api/css/properties/border-top-color.md)、[`border-right-color`](/next/zh/api/css/properties/border-right-color.md)、[`border-bottom-color`](/next/zh/api/css/properties/border-bottom-color.md) 和 [`border-left-color`](/next/zh/api/css/properties/border-left-color.md) 分别设置各个方向的边框颜色。

你可以将颜色定义在 CSS 文件中设置给对应属性或是通过 `style` 属性直接设置给元件。
颜色的值可以通过一个以“#”开头的十六进制数来分别表示对应的红、绿、蓝和透明度通道的值。这个值也可以通过 `rgb()`、`hsl()` 等相关函数定义。更多关于颜色的取值可以参考 [`<color>`](/next/zh/api/css/data-type/color.md)。

## 渐变

你可以使用 [`<gradient>`](/next/zh/api/css/data-type/gradient.md) 值声明渐变的特效，并将其应用到以下属性中：

- [`color`](/next/zh/api/css/properties/color.md)：使用渐变特效绘制文本。
- [`background-image`](/next/zh/api/css/properties/background-image.md)：使用渐变特效填充元件的背景。
- [`mask-image`](/next/zh/api/css/properties/mask-image.md)：使用渐变特效创建透明度蒙版。

| ![](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/lynx-website/assets/doc/color-gradient.png)


渐变

`color`
文本 | ![](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/lynx-website/assets/doc/guide-radial-gradient.png)


`radial-gradient`
填充背景 | ![](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/lynx-website/assets/doc/guide-fading-edge.gif)


&#x20;通过

`linear-gradient`
设置

`mask-image`
实现边缘淡出效果 |


## 裁切与蒙版

在 Lynx 中，除了使用 [`overflow`](/next/zh/api/css/properties/overflow.md) 属性来控制显示内容以外。你可以通过 [`clip-path`](/next/zh/api/css/properties/clip-path.md) 和 [`mask-image`](/next/zh/api/css/properties/mask-image.md)
来生成不规则形状的可显示区域边界。

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

**Entry:** `src/clip_path_super_ellipse`
**Bundle:** `dist/clip_path_super_ellipse.lynx.bundle` | Web: `dist/clip_path_super_ellipse.web.bundle`

```tsx {14}
import { root } from "@lynx-js/react";

function App() {
  return (
    <view
      style={{
        flexDirection: "column",
        background: "radial-gradient(circle at top left, rgb(255,53,26), rgb(0,235,235))",
        marginTop: "50%",
        transform: "translate(-50%, -50%)",
        marginLeft: "50%",
        width: "150px",
        height: "150px",
        clipPath: "inset(5px super-ellipse 3 3 50px/50px)",
      }}
    >
      <text
        style={{
          fontSize: "32px",
          fontWeight: "bold",
          alignSelf: "center",
          color: "white",
          marginTop: "50%",
          transform: "translateY(-50%)",
        }}
      >
        LYNX
      </text>
    </view>
  );
}

root.render(<App />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.8.0



使用`clip-path`裁切出超椭圆


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

**Entry:** `src/mask_image_circle_gradient`
**Bundle:** `dist/mask_image_circle_gradient.lynx.bundle` | Web: `dist/mask_image_circle_gradient.web.bundle`

```tsx {14}
import { root } from "@lynx-js/react";

function App() {
  return (
    <view
      style={{
        marginTop: "50%",
        transform: "translate(-50%, -50%)",
        marginLeft: "50%",
        width: "150px",
        height: "150px",
      }}
    >
      <view
        style={{
          flexDirection: "column",
          background: "radial-gradient(circle at top left, rgb(255,53,26), rgb(0,235,235))",
          width: "100%",
          height: "100%",
          maskImage: "radial-gradient(circle 75px, black 75%, transparent)",
          position: "absolute",
        }}
      >
        <text
          style={{
            fontSize: "32px",
            fontWeight: "bold",
            alignSelf: "center",
            color: "white",
            marginTop: "50%",
            transform: "translateY(-50%)",
          }}
        >
          LYNX
        </text>
      </view>
    </view>
  );
}

root.render(<App />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.8.0



使用`mask-image`实现边缘淡出
