shopify-polaris-web-components by tamiror6/shopify-app-skills
npx skills add https://github.com/tamiror6/shopify-app-skills --skill shopify-polaris-web-components使用此技能,通过 Polaris Web Components 为 Shopify App Home 界面构建 UI。
s-* 自定义元素创建 UI重要提示:App Home 使用 Polaris Web Components(s-* 元素),而非 Polaris React(@shopify/polaris)。这是两种不同的技术。
| 功能特性 | Polaris React | Polaris Web Components |
|---|---|---|
| 适用场景 | 嵌入式管理应用 | App Home 界面 |
| 导入方式 | @shopify/polaris |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 无需导入(原生元素) |
| 语法 | <Button> | <s-button> |
| 框架 | React 组件 | 自定义 HTML 元素 |
<s-page heading="Dashboard">
<s-section heading="Overview">
<!-- 内容 -->
</s-section>
<s-section heading="Settings">
<!-- 更多内容 -->
</s-section>
</s-page>
<!-- 垂直堆叠(默认) -->
<s-stack direction="block" gap="large">
<s-text>项目 1</s-text>
<s-text>项目 2</s-text>
</s-stack>
<!-- 水平堆叠 -->
<s-stack direction="inline" gap="medium" alignItems="center">
<s-button>取消</s-button>
<s-button variant="primary">保存</s-button>
</s-stack>
<!-- 带对齐方式的堆叠 -->
<s-stack
direction="inline"
justifyContent="space-between"
alignItems="center"
>
<s-text variant="headingMd">标题</s-text>
<s-button>操作</s-button>
</s-stack>
使用 s-section 对带有可选标题的内容进行分组:
<!-- 带标题的 Section -->
<s-section heading="聊天小部件设置">
<s-stack direction="block" gap="medium">
<s-text>配置您的小部件外观。</s-text>
<!-- 表单字段 -->
</s-stack>
</s-section>
<!-- 不带标题的 Section -->
<s-section>
<s-text>简单内容块</s-text>
</s-section>
使用 s-box 实现内边距、边框和间距 - 不用于卡片:
<!-- 带内边距的 Box -->
<s-box padding="large">
<s-text>带内边距的内容</s-text>
</s-box>
<!-- 带边框的 Box -->
<s-box
padding="medium"
borderWidth="base"
borderRadius="base"
>
<s-text>带边框的内容</s-text>
</s-box>
<!-- 用于间距的 Box -->
<s-box paddingBlockStart="large">
<s-text>带顶部外边距的内容</s-text>
</s-box>
规则:使用 s-section 作为卡片式容器,s-box 仅用于布局/间距。
<!-- 主要操作 -->
<s-button variant="primary" type="submit">
保存设置
</s-button>
<!-- 默认按钮 -->
<s-button>取消</s-button>
<!-- 危险操作 -->
<s-button variant="primary" tone="critical">
删除
</s-button>
<!-- 禁用状态 -->
<s-button disabled>不可用</s-button>
<!-- 带点击处理器(在 JS 中) -->
<s-button id="save-btn">保存</s-button>
<script>
document.getElementById('save-btn').addEventListener('click', handleSave);
</script>
<!-- 标题 -->
<s-text variant="headingLg">大标题</s-text>
<s-text variant="headingMd">中标题</s-text>
<s-text variant="headingSm">小标题</s-text>
<!-- 正文文本 -->
<s-text>默认正文文本</s-text>
<s-text variant="bodySm">小号正文文本</s-text>
<!-- 色调 -->
<s-text tone="subdued">柔和文本</s-text>
<s-text tone="critical">错误文本</s-text>
<s-text tone="success">成功文本</s-text>
<!-- 信息横幅 -->
<s-banner>
<p>这是一条信息性消息。</p>
</s-banner>
<!-- 严重错误横幅 -->
<s-banner tone="critical">
<p>出错了。请重试。</p>
</s-banner>
<!-- 成功横幅 -->
<s-banner tone="success">
<p>设置保存成功!</p>
</s-banner>
<!-- 可关闭横幅 -->
<s-banner tone="warning" onDismiss="handleDismiss">
<p>您的试用期还剩 3 天。</p>
</s-banner>
<s-link href="/settings">前往设置</s-link>
<s-link href="https://shopify.dev" external>
文档
</s-link>
<!-- 文本字段 -->
<s-text-field
label="店铺名称"
value="我的店铺"
helpText="这将显示在您的小部件中"
></s-text-field>
<!-- 选择框 -->
<s-select label="语言">
<option value="en">英语</option>
<option value="es">西班牙语</option>
</s-select>
<!-- 复选框 -->
<s-checkbox label="启用通知" checked></s-checkbox>
<s-page heading="Settings">
<s-stack direction="block" gap="large">
<s-section heading="General">
<s-stack direction="block" gap="medium">
<s-text-field
label="Welcome message"
value="Hello! How can we help?"
></s-text-field>
<s-checkbox label="Enable auto-reply"></s-checkbox>
</s-stack>
</s-section>
<s-section heading="Appearance">
<s-stack direction="block" gap="medium">
<s-select label="Theme">
<option value="light">Light</option>
<option value="dark">Dark</option>
</s-select>
</s-stack>
</s-section>
<s-box paddingBlockStart="large">
<s-stack direction="inline" gap="medium" justifyContent="flex-end">
<s-button>Cancel</s-button>
<s-button variant="primary">Save</s-button>
</s-stack>
</s-box>
</s-stack>
</s-page>
<s-section>
<s-stack direction="block" gap="medium" alignItems="center">
<s-text variant="headingMd">尚无活动</s-text>
<s-text tone="subdued">
创建您的第一个活动以开始使用。
</s-text>
<s-button variant="primary">创建活动</s-button>
</s-stack>
</s-section>
<s-section heading="Campaigns">
<s-stack direction="block" gap="none">
<s-box padding="medium" borderBlockEnd="base">
<s-stack direction="inline" justifyContent="space-between" alignItems="center">
<s-stack direction="block" gap="extraSmall">
<s-text variant="headingSm">Welcome Series</s-text>
<s-text tone="subdued">Active • 1,234 sent</s-text>
</s-stack>
<s-button>Edit</s-button>
</s-stack>
</s-box>
<s-box padding="medium" borderBlockEnd="base">
<s-stack direction="inline" justifyContent="space-between" alignItems="center">
<s-stack direction="block" gap="extraSmall">
<s-text variant="headingSm">Abandoned Cart</s-text>
<s-text tone="subdued">Paused • 567 sent</s-text>
</s-stack>
<s-button>Edit</s-button>
</s-stack>
</s-box>
</s-stack>
</s-section>
在您的 tsconfig.json 中添加 s-* 组件的类型:
{
"compilerOptions": {
"types": ["@shopify/polaris-types"]
}
}
仅在以下情况下使用纯 div 和内联样式:
每周安装量
104
代码仓库
GitHub 星标数
33
首次出现
2026年2月7日
安全审计
已安装于
codex97
opencode97
gemini-cli95
github-copilot95
kimi-cli92
amp92
Use this skill when building UI for Shopify App Home surfaces using Polaris Web Components.
s-* custom elementsImportant : App Home uses Polaris Web Components (s-* elements), NOT Polaris React (@shopify/polaris). These are different technologies.
| Feature | Polaris React | Polaris Web Components |
|---|---|---|
| Use for | Embedded admin apps | App Home surfaces |
| Import | @shopify/polaris | No import (native elements) |
| Syntax | <Button> | <s-button> |
| Framework | React components | Custom HTML elements |
<s-page heading="Dashboard">
<s-section heading="Overview">
<!-- Content -->
</s-section>
<s-section heading="Settings">
<!-- More content -->
</s-section>
</s-page>
<!-- Vertical stack (default) -->
<s-stack direction="block" gap="large">
<s-text>Item 1</s-text>
<s-text>Item 2</s-text>
</s-stack>
<!-- Horizontal stack -->
<s-stack direction="inline" gap="medium" alignItems="center">
<s-button>Cancel</s-button>
<s-button variant="primary">Save</s-button>
</s-stack>
<!-- Stack with justification -->
<s-stack
direction="inline"
justifyContent="space-between"
alignItems="center"
>
<s-text variant="headingMd">Title</s-text>
<s-button>Action</s-button>
</s-stack>
Use s-section for grouped content with optional heading:
<!-- Section with heading -->
<s-section heading="Chat Widget Settings">
<s-stack direction="block" gap="medium">
<s-text>Configure your widget appearance.</s-text>
<!-- Form fields -->
</s-stack>
</s-section>
<!-- Section without heading -->
<s-section>
<s-text>Simple content block</s-text>
</s-section>
Use s-box for padding, borders, and spacing - NOT for cards:
<!-- Box with padding -->
<s-box padding="large">
<s-text>Padded content</s-text>
</s-box>
<!-- Box with border -->
<s-box
padding="medium"
borderWidth="base"
borderRadius="base"
>
<s-text>Bordered content</s-text>
</s-box>
<!-- Box for spacing -->
<s-box paddingBlockStart="large">
<s-text>Content with top margin</s-text>
</s-box>
Rule : Use s-section for card-like containers, s-box for layout/spacing only.
<!-- Primary action -->
<s-button variant="primary" type="submit">
Save Settings
</s-button>
<!-- Default button -->
<s-button>Cancel</s-button>
<!-- Destructive -->
<s-button variant="primary" tone="critical">
Delete
</s-button>
<!-- Disabled -->
<s-button disabled>Unavailable</s-button>
<!-- With click handler (in JS) -->
<s-button id="save-btn">Save</s-button>
<script>
document.getElementById('save-btn').addEventListener('click', handleSave);
</script>
<!-- Headings -->
<s-text variant="headingLg">Large Heading</s-text>
<s-text variant="headingMd">Medium Heading</s-text>
<s-text variant="headingSm">Small Heading</s-text>
<!-- Body text -->
<s-text>Default body text</s-text>
<s-text variant="bodySm">Small body text</s-text>
<!-- Tones -->
<s-text tone="subdued">Muted text</s-text>
<s-text tone="critical">Error text</s-text>
<s-text tone="success">Success text</s-text>
<!-- Info banner -->
<s-banner>
<p>This is an informational message.</p>
</s-banner>
<!-- Critical banner -->
<s-banner tone="critical">
<p>Something went wrong. Please try again.</p>
</s-banner>
<!-- Success banner -->
<s-banner tone="success">
<p>Settings saved successfully!</p>
</s-banner>
<!-- Dismissible banner -->
<s-banner tone="warning" onDismiss="handleDismiss">
<p>Your trial ends in 3 days.</p>
</s-banner>
<s-link href="/settings">Go to Settings</s-link>
<s-link href="https://shopify.dev" external>
Documentation
</s-link>
<!-- Text field -->
<s-text-field
label="Store name"
value="My Store"
helpText="This appears in your widget"
></s-text-field>
<!-- Select -->
<s-select label="Language">
<option value="en">English</option>
<option value="es">Spanish</option>
</s-select>
<!-- Checkbox -->
<s-checkbox label="Enable notifications" checked></s-checkbox>
<s-page heading="Settings">
<s-stack direction="block" gap="large">
<s-section heading="General">
<s-stack direction="block" gap="medium">
<s-text-field
label="Welcome message"
value="Hello! How can we help?"
></s-text-field>
<s-checkbox label="Enable auto-reply"></s-checkbox>
</s-stack>
</s-section>
<s-section heading="Appearance">
<s-stack direction="block" gap="medium">
<s-select label="Theme">
<option value="light">Light</option>
<option value="dark">Dark</option>
</s-select>
</s-stack>
</s-section>
<s-box paddingBlockStart="large">
<s-stack direction="inline" gap="medium" justifyContent="flex-end">
<s-button>Cancel</s-button>
<s-button variant="primary">Save</s-button>
</s-stack>
</s-box>
</s-stack>
</s-page>
<s-section>
<s-stack direction="block" gap="medium" alignItems="center">
<s-text variant="headingMd">No campaigns yet</s-text>
<s-text tone="subdued">
Create your first campaign to get started.
</s-text>
<s-button variant="primary">Create Campaign</s-button>
</s-stack>
</s-section>
<s-section heading="Campaigns">
<s-stack direction="block" gap="none">
<s-box padding="medium" borderBlockEnd="base">
<s-stack direction="inline" justifyContent="space-between" alignItems="center">
<s-stack direction="block" gap="extraSmall">
<s-text variant="headingSm">Welcome Series</s-text>
<s-text tone="subdued">Active • 1,234 sent</s-text>
</s-stack>
<s-button>Edit</s-button>
</s-stack>
</s-box>
<s-box padding="medium" borderBlockEnd="base">
<s-stack direction="inline" justifyContent="space-between" alignItems="center">
<s-stack direction="block" gap="extraSmall">
<s-text variant="headingSm">Abandoned Cart</s-text>
<s-text tone="subdued">Paused • 567 sent</s-text>
</s-stack>
<s-button>Edit</s-button>
</s-stack>
</s-box>
</s-stack>
</s-section>
Add types for s-* components in your tsconfig.json:
{
"compilerOptions": {
"types": ["@shopify/polaris-types"]
}
}
Only use plain div and inline styles when:
Weekly Installs
104
Repository
GitHub Stars
33
First Seen
Feb 7, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex97
opencode97
gemini-cli95
github-copilot95
kimi-cli92
amp92
TanStack Table 中文指南:React 无头表格库,实现排序过滤分页
500 周安装
Python uv包管理工具使用指南:替代pip和poetry的现代依赖管理方案
224 周安装
Android ViewModel 状态管理指南:使用 StateFlow 与 SharedFlow 实现 UI 状态与事件处理
224 周安装
Shape Up产品管理方法:告别估算陷阱,实现高效交付的产品开发框架
103 周安装
TLDR Stats - Claude AI 令牌使用监控与成本节省分析仪表盘工具
225 周安装
Agentica SDK 中文指南:Python AI 智能体开发框架,支持多智能体编排与工具集成
225 周安装
Continuous Claude系统概览:AI助手工作原理、记忆层与钩子机制详解
228 周安装