> ## Documentation Index
> Fetch the complete documentation index at: https://docs.y.uno/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Test in the sandbox first: base URL https://api-sandbox.y.uno (Test Mode in the Dashboard). Production is https://api.y.uno (Live Mode).
> Every API request needs the public-api-key and private-secret-key headers. Get them in the Dashboard at https://dashboard.y.uno/developers (Developers > Credentials); sandbox and production keys are different.
> Send an X-Idempotency-Key (a UUID) when creating payments, refunds and cancels, so retries do not create duplicates.
> Start with the Quickstart (https://docs.y.uno/docs/quickstart.md) and the agent guide (https://docs.y.uno/agents.md). To search these docs from a coding agent, connect the docs MCP server at https://docs.y.uno/mcp.

# 样式

> 自定义 SDK 内置视图的外观。

让 SDK 的内置视图与您的品牌保持一致。

> [!NOTE]
>
> 设置 SDK 样式有**两种方式**：
>
> * \*\*在代码中（iOS、Android 和 React Native）：\*\*在 `TransactionConfig` 上传入一个 `Appearance` 对象（见下文）。Web 没有 `appearance` 选项。有关在 Web 上通过代码设置的样式，请参阅 Web 选项卡。
> * \*\*通过 Checkout Builder：\*\*在您的 [Yuno Dashboard](https://dashboard.y.uno/) 中在服务器端配置样式，无需编写代码。
>
> 如果两者都未设置，SDK 将回退到其默认样式。

> [tab] Web
>
> Web SDK 以常规 DOM 的形式渲染到您的页面中，因此您可以使用 CSS 加上几个配置字段来设置其样式。Web 上没有 `appearance` 对象。
>
> ## 可以设置的样式
>
> | 手段 | 位置 | 改变的内容 |
> | - | - | - |
> | Checkout Builder | Yuno Dashboard | 内置视图的颜色、字体和按钮形状。SDK 在每次挂载时应用这些设置，无需编写代码。 |
> | 带有 `sdk-payments-` 前缀的 CSS 类 | 您的样式表 | SDK 在您页面上渲染的每个元素都带有一个使用该前缀的类。请在您自己的 CSS 中定位它们。 |
> | `card.styles` | `TransactionConfig` | 注入到卡号、有效期和 CVV iframe 内部的 CSS 字符串，您的页面 CSS 无法作用于这些 iframe。 |
> | `card.fonts` | `TransactionConfig` | 在银行卡 iframe 内部加载的字体。 |
> | `card.texts` | `TransactionConfig` | 银行卡表单字段的自定义标签。 |
> | `inputDesignType` | `TransactionConfig`（仅限支付） | 输入框的标签布局：`float-label`（默认）、`float-label-static` 或 `label-placeholder`。 |
> | 钱包按钮选项 | 每个钱包视图的 `mount()`，或配置上的 `externalButtons` | Apple Pay、Google Pay、PayPal、Samsung Pay 和 Revolut Pay 按钮的类型、颜色、形状、尺寸和语言区域。 |
> | `options.styles` | `secureFields.create()` | 每个 Secure Fields iframe 内部的 CSS。 |
> | `options.externalFonts` | `secureFields.create()` | 在每个 Secure Fields iframe 内部加载的字体。 |
>
> ## CSS 类
>
> SDK 在您页面上渲染的每个元素都带有一个使用 `sdk-payments-` 前缀的类。在您的样式表中定位它们，以自定义颜色、间距、边框和其他视觉属性。常用的类包括：
>
> | 类模式 | 设置样式的对象 |
> | - | - |
> | `sdk-payments-payment-list__*` | 支付方式列表容器和行 |
> | `sdk-payments-fieldset__*` | 表单字段容器和框 |
> | `sdk-payments-input__*` | 输入字段和标签 |
> | `sdk-payments-button__*` | 按钮 |
> | `sdk-payments-card__*` | 银行卡表单元素 |
>
> ```css theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> /* Example: customize the payment method list and inputs */
> .sdk-payments-payment-list__radio {
>     border-radius: 8px;
>     margin-bottom: 8px;
> }
>
> .sdk-payments-input__label {
>     color: #333;
>     font-weight: 500;
> }
>
> .sdk-payments-user-form__submit {
>     background-color: #6200ee;
>     border-radius: 24px;
> }
> ```
>
> > [!NOTE]
> >
> > CSS 类可能会在 SDK 版本之间发生变化。请在浏览器的开发者工具中检查渲染后的 DOM，以查找当前的类名。
>
> ## 设置银行卡 iframe 的样式
>
> 为符合 PCI 合规要求，卡号、有效期和 CVV 在 iframe 内部渲染。您的页面 CSS 无法作用于它们。请使用 `card.styles` 注入 CSS，并使用 `card.fonts` 在 iframe 内部加载自定义字体。
>
> ```typescript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> const transaction = sdkPayments.transaction({
>     checkoutSession: 'session-from-backend',
>     countryCode: 'CO',
>     card: {
>         styles: `
>             input {
>                 font-family: 'Inter', sans-serif;
>                 font-size: 16px;
>                 color: #111;
>             }
>             input::placeholder {
>                 color: #999;
>             }
>             input:focus {
>                 border-color: #6200ee;
>             }
>         `,
>         fonts: [
>             {
>                 familyName: 'Inter',
>                 files: [
>                     { weight: 400, url: 'https://cdn.example.com/fonts/inter-400.woff2' },
>                     { weight: 600, url: 'https://cdn.example.com/fonts/inter-600.woff2' },
>                 ],
>             },
>         ],
>     },
>     onStatus: (result) => showResult(result),
> })
> ```
>
> ### 自定义字体
>
> `card.fonts` 在银行卡 iframe 内部加载字体文件。它不会应用这些字体：请在 `card.styles` 中按名称引用字体系列，如上例所示。
>
> | 字段 | 类型 | 描述 |
> | - | - | - |
> | `familyName` | string | 您在 `card.styles` 的 `font-family` 中引用的字体系列名称。 |
> | `files` | array | 每个字重一个条目。 |
> | `files[].weight` | number | 该文件的字重，例如 `400` 或 `600`。 |
> | `files[].url` | string | 字体文件的 URL，例如一个 `.woff2`。 |
>
> > [!NOTE]
> >
> > iframe 从与您页面不同的源加载这些文件，因此字体托管方必须允许跨源请求（发送 `Access-Control-Allow-Origin` 标头）。如果某个文件加载失败，该字段将回退到您 `font-family` 字体栈中的下一个字体。
>
> ## 输入框设计类型
>
> `inputDesignType` 字段控制标签和占位符在表单输入框上的显示方式：
>
> | 值 | 行为 |
> | - | - |
> | `float-label`（默认） | 输入框获得焦点或已填写时，标签浮动在输入框上方。 |
> | `float-label-static` | 标签始终位于输入框上方。 |
> | `label-placeholder` | 标签以占位符文本的形式显示在输入框内。 |
>
> ```typescript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> const transaction = sdkPayments.transaction({
>     checkoutSession: 'session-from-backend',
>     countryCode: 'CO',
>     inputDesignType: 'float-label-static',
>     onStatus: (result) => showResult(result),
> })
> ```
>
> ## 钱包按钮选项
>
> 通过 `mount()` 选项或配置上的 `externalButtons` 自定义快捷钱包按钮：
>
> ```typescript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> const views = transaction.getPaymentMethodsViews({
>     types: ['applePay', 'googlePay'],
>     onPaymentSelected: (pm) => { /* ... */ },
> })
>
> views.applePay?.mount({
>     elementSelector: '#apple-pay',
>     buttonType: 'buy',       // 'plain', 'buy', 'book', 'donate', etc.
>     buttonStyle: 'black',    // 'black', 'white', 'white-outline'
> })
>
> views.googlePay?.mount({
>     elementSelector: '#google-pay',
>     buttonColor: 'black',    // 'black', 'white'
>     buttonType: 'pay',       // 'pay', 'buy', 'book', 'donate', etc.
> })
> ```
>
> ## Secure Fields 样式
>
> 对于 [Secure Fields](https://docs.y.uno/zh-hans/docs/yuno-sdk/features/secure-fields.md)，请在创建每个字段时，在其 `options` 中传入 `styles` 和 `externalFonts`：
>
> ```typescript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> const cardNumber = secureFields.create({
>     name: 'pan',
>     options: {
>         placeholder: 'Card number',
>         styles: `
>             input {
>                 font-family: 'Inter', sans-serif;
>                 font-size: 16px;
>                 border: 1px solid #ccc;
>                 border-radius: 4px;
>                 padding: 12px;
>             }
>         `,
>         externalFonts: [
>             {
>                 family_name: 'Inter',
>                 files: [{ weight: 400, url: 'https://cdn.example.com/fonts/inter-400.woff2' }],
>             },
>         ],
>     },
> })
>
> cardNumber.mount('#pan')
> ```
>
> 每个字段都是独立的 iframe，因此请将 `externalFonts` 传给每个使用该字体的字段。这些条目的结构与 `card.fonts` 相同，但字体系列的键是 `family_name`（snake case），而不是 `familyName`。同样的跨源要求也适用。

> [tab] iOS
>
> 使用您要覆盖的字段构建一个 `SdkPayments.Appearance`，并将其传给 `TransactionConfig(appearance:)`。每个字段都是可选的；未设置的字段将回退到 SDK 默认值。
>
> ## Appearance 字段
>
> | 字段 | 描述 |
> | - | - |
> | `fontFamily` | SDK 全局使用的字体系列。请提供在您应用资源中注册的字体名称。 |
> | `accentColor` | 多个 SDK 元素使用的强调色。 |
> | `buttonBackgroundColor` | 主按钮的背景色。 |
> | `buttonTitleColor` | 主按钮的文字颜色。 |
> | `buttonBorderColor` | 主按钮的边框颜色。 |
> | `secondaryButtonBackgroundColor` | 次要按钮的背景色。 |
> | `secondaryButtonTitleColor` | 次要按钮的文字颜色。 |
> | `secondaryButtonBorderColor` | 次要按钮的边框颜色。 |
> | `disableButtonBackgroundColor` | 禁用按钮的背景色。 |
> | `disableButtonTitleColor` | 禁用按钮的文字颜色。 |
> | `checkboxColor` | SDK 中显示的复选框的颜色（例如保存银行卡）。 |
>
> > [!NOTE]
> >
> > 所有颜色都必须是 `UIColor`（来自 Xcode 的资源目录或您自己的资源），以保持兼容。
>
> ## 样式的解析方式
>
> 设置**任何** `Appearance` 字段都会使其成为该交易的有效样式来源：此时 Dashboard 样式将被完全忽略。每个来源的解析都是全有或全无，绝不会逐字段合并。空的 `Appearance()` 不算作自定义，因此 Dashboard 样式仍然适用。任何自定义外观（无论在代码中还是来自 Dashboard）都以浅色模式渲染。
>
> ## 用法
>
> Appearance 按交易设置：请在每个 `TransactionConfig` 上传入，而不是在 `initialize` 时传入。
>
> ```swift theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> import SdkPayments
>
> let appearance = SdkPayments.Appearance(
>     fontFamily: "Climate Crisis",
>     accentColor: .orange,
>     buttonBackgroundColor: .yellow,
>     buttonTitleColor: .black,
>     buttonBorderColor: .black,
>     secondaryButtonBackgroundColor: .yellow,
>     secondaryButtonTitleColor: .black,
>     secondaryButtonBorderColor: .black,
>     disableButtonBackgroundColor: .gray,
>     disableButtonTitleColor: .black,
>     checkboxColor: .black
> )
>
> let config = SdkPayments.TransactionConfig(
>     checkoutSession: "session-from-backend",
>     countryCode: "US",
>     appearance: appearance,
>     controller: self
> )
>
> SdkPayments.Transaction(config: config)
>     .start(paymentSelected: paymentSelected)
> ```

> [tab] Android
>
> 使用您要覆盖的字段构建一个 `Appearance`，并将其传给 `TransactionConfig(appearance = ...)`。每个字段都是可选的；未设置的字段将回退到 SDK 默认值。
>
> ## Appearance 字段
>
> | 字段 | 描述 |
> | - | - |
> | `fontFamily` | SDK 全局使用的字体系列。根据系统字体和您在 Dashboard 中配置的字体进行解析；无法解析的名称将回退到设备的默认系统字体。 |
> | `accentColor` | 用于焦点描边和光标的强调色。它不会级联到复选框或次要按钮边框，这些有各自的字段。 |
> | `buttonBackgroundColor` | 主按钮的背景色。 |
> | `buttonTitleColor` | 主按钮的文字颜色。 |
> | `buttonBorderColor` | 主按钮的边框颜色。 |
> | `secondaryButtonBackgroundColor` | 次要按钮的背景色。 |
> | `secondaryButtonTitleColor` | 次要按钮的文字颜色。 |
> | `secondaryButtonBorderColor` | 次要按钮的边框颜色。 |
> | `disableButtonBackgroundColor` | 禁用按钮的背景色。 |
> | `disableButtonTitleColor` | 禁用按钮的文字颜色。 |
> | `checkboxColor` | SDK 中显示的复选框的颜色（例如保存银行卡）。 |
>
> > [!NOTE]
> >
> > 所有颜色都是 `@ColorInt` 整数：请使用 `Color.parseColor("#FFD600")`、`ContextCompat.getColor(context, R.color.brand)` 或 `android.graphics.Color` 常量。
>
> ## 样式的解析方式
>
> 设置**任何** `Appearance` 字段都会使其成为该交易的有效样式来源：此时 Dashboard 样式将被完全忽略，每个来源的解析都是全有或全无，绝不会逐字段合并。空的 `Appearance()` 不算作自定义，因此 Dashboard 样式仍然适用。任何自定义外观（无论在代码中还是来自 Dashboard）都以浅色模式渲染。
>
> SDK 不自带字体：如果代码中没有 `fontFamily`，Dashboard 中也未配置字体，文本将使用设备的默认系统字体渲染。
>
> ## 用法
>
> Appearance 按交易设置：请在每个 `TransactionConfig` 上传入，而不是在 `initialize` 时传入。
>
> ```kotlin theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> import android.graphics.Color
> import com.yuno.payments.sdk.api.Appearance
> import com.yuno.payments.sdk.api.Transaction
> import com.yuno.payments.sdk.api.TransactionConfig
>
> val appearance = Appearance(
>     fontFamily = "Climate Crisis",
>     accentColor = Color.parseColor("#E65100"),
>     buttonBackgroundColor = Color.parseColor("#FFD600"),
>     buttonTitleColor = Color.BLACK,
>     buttonBorderColor = Color.BLACK,
>     secondaryButtonBackgroundColor = Color.parseColor("#FFD600"),
>     secondaryButtonTitleColor = Color.BLACK,
>     secondaryButtonBorderColor = Color.BLACK,
>     disableButtonBackgroundColor = Color.GRAY,
>     disableButtonTitleColor = Color.BLACK,
>     checkboxColor = Color.BLACK,
> )
>
> val transaction = Transaction(
>     TransactionConfig(
>         countryCode = "US",
>         checkoutSession = "session-from-backend",
>         appearance = appearance,
>         controller = this,
>     ),
> )
>
> transaction.start(activity = this, paymentSelected = paymentSelected)
> ```

> [tab] React Native
>
> 在 `TransactionConfig` 上传入一个 `Appearance` 对象。它的字段与 iOS 和 Android 上的相同，每个字段都是可选的，样式的解析方式与该平台的原生 SDK 相同（请参阅 iOS 和 Android 选项卡）。颜色为十六进制字符串，即 `#RRGGBB` 或 `#AARRGGBB`，会被转换为原生颜色类型。`fontFamily` 必须指定您的原生应用能够加载的字体。
>
> Appearance 按交易设置：请在每个 `TransactionConfig` 上传入，而不是在 `initialize` 时传入。
>
> ```tsx theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> const transaction = new Transaction({
>   checkoutSession: 'session-from-backend',
>   countryCode: 'US',
>   appearance: {
>     fontFamily: 'Climate Crisis',
>     accentColor: '#E65100',
>     buttonBackgroundColor: '#FFD600',
>     buttonTitleColor: '#000000',
>     buttonBorderColor: '#000000',
>     secondaryButtonBackgroundColor: '#FFD600',
>     secondaryButtonTitleColor: '#000000',
>     secondaryButtonBorderColor: '#000000',
>     disableButtonBackgroundColor: '#9E9E9E',
>     disableButtonTitleColor: '#000000',
>     checkboxColor: '#000000',
>   },
>   controller,
> });
>
> await transaction.start(paymentSelected);
> ```

## 相关内容

* [`TransactionConfig`](https://docs.y.uno/zh-hans/docs/yuno-sdk/reference/objects-you-pass#transaction-config)。传入 `appearance` 的位置。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.