This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
材料颜色
从 JavaScript 读取 Material 3 颜色调色板(包括 Material 3 动态颜色)。
Expo UI Jetpack Compose 暴露了 Jetpack Compose 使用的 Material 3 配色方案,这样你就可以选择一个配色来源,并让每个组件在 <Host> 主题下保持一致。
🌐 Expo UI Jetpack Compose exposes the Material 3 color palette used by Jetpack Compose so you can pick a palette source and have every component under a <Host> theme from it consistently.
调色板来源取决于你传入的选项:
🌐 The palette source depends on the options you pass:
- 壁纸衍生: 当未提供
seedColor时,Android 12 及以上版本的默认设置。使用 Material 3 动态颜色(Material You)。 - 静态 Material 3 基线: 在未提供
seedColor时,Android 11 及以下的默认回退。 - 从颜色生成: 当你传入
seedColor时,完整的调色板会使用与 Material 3 动态颜色为基于壁纸的颜色使用的相同算法生成。适用于所有 Android API 级别,并且独立于壁纸。
安装
🌐 Installation
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
🌐 Usage
从种子颜色为 <Host> 主题化
🌐 Theming <Host> from a seed color
Host 可以直接接受 seedColor 和 colorScheme 属性。这是为 Compose 子树设置主题的推荐方法。在这个 Host 下的原生 Compose 组件将使用预设调色板进行渲染,任何在后代中调用 useMaterialColors() 而不带参数的组件都会从宿主的上下文中获取相同的调色板。
在主机中读取当前调色板
🌐 Reading the current palette inside Host
在 <Host> 内部调用 useMaterialColors() 时不使用参数,以读取主机当前的调色板。该钩子返回一个引用稳定的 MaterialColors 对象,并且在重新渲染时不会跨越本地桥。
🌐 Call useMaterialColors() without arguments inside a <Host> to read the Host's current palette. The hook returns a reference-stable MaterialColors object and does not cross the native bridge on re-renders.
使用参数计算特定调色板
🌐 Computing a specific palette with arguments
将参数传递给 useMaterialColors() 以按需计算调色板,即使在 <Host> 外也可以。colorScheme 接受 'light' 或 'dark',你可以省略它以遵循系统设置。
🌐 Pass arguments to useMaterialColors() to compute a palette on demand, even outside a <Host>. The colorScheme takes 'light' or 'dark', you can omit it to follow the system.
在 React 组件外读取颜色
🌐 Reading colors outside React components
应用接口
🌐 API
No API data file found, sorry!