# palette

Canonical URL: https://developers.iagenify.com/zh/sdk/ref/brand-object/palette/
Language: zh

`brand.palette.set(colors | { colors, typography }) · role(role) · colors · typography`

带角色的颜色，以及字体。设置颜色会替换全部颜色。

Status: PUT /api/brand/:id/palette · 12 colors · contrast computed

```javascript
await brand.palette.set({
  colors: [{ hex: "#6B3E26", role: "primary", name: "Roast" }, { hex: "#D9A441", role: "accent" }],
  typography: { heading: "Fraunces", body: "Inter", mono: "" },
});

brand.palette.role("primary");
// { hex: "#6B3E26", role: "primary", name: "Roast", cmyk: [...], textColor: "#FFFFFF",
//   contrast: { onWhite: { ratio, level: "AA" }, onBlack: { … } } }
```

## 角色 {#roles}

`primary`（最多一个）、`secondary`、`accent`、`neutral`、`background`、`text`、`success`、`warning` 和 `error`。

## 字体是一个名称 {#typography}

你的各个界面将使用的字体族名称。展示品牌的界面保留自己的字体：品牌的字体以名称记录，不会为渲染页面而加载。

- [Brand](/zh/sdk/ref/brand-object): 品牌包含什么，以及如何修改它。
- [logos](/zh/sdk/ref/brand-object/logos): 添加标志，选择主标志。

```python
brand.palette.set({
    "colors": [{"hex": "#6B3E26", "role": "primary", "name": "Roast"}, {"hex": "#D9A441", "role": "accent"}],
    "typography": {"heading": "Fraunces", "body": "Inter", "mono": ""},
})

brand.palette.role("primary")
# {"hex": "#6B3E26", "role": "primary", "name": "Roast", "cmyk": [...], "textColor": "#FFFFFF",
#  "contrast": {"onWhite": {"ratio": ..., "level": "AA"}, "onBlack": {...}}}
```
