sgds-templates
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSGDS Page Templates
SGDS 页面模板
Ready-to-use full-page templates using SGDS components and utilities — adapted from the visual patterns of shadcn Blocks. Each template gives a beautiful starting point without writing layout code from scratch.
基于SGDS组件和工具打造的即用型全页模板——改编自shadcn Blocks的视觉模式。每个模板都提供了美观的起点,无需从零开始编写布局代码。
Prerequisites
前置要求
Every page must include the Application Shell. Read sgds-blocks → reference/application-shell.md before generating any page. The shell provides mandatory,<sgds-masthead>, and<sgds-mainnav>on every page, plus container class selection (<sgds-footer>vs.sgds-container) and sticky-header conventions. Never generate a page template without all three shell components..sgds-container-sidebar
javascript
import "@govtechsg/sgds-web-component/themes/day.css";
import "@govtechsg/sgds-web-component/css/sgds.css";
import "@govtechsg/sgds-web-component/css/utility.css";See sgds-getting-started and sgds-components for full installation.
For container width and max-width utilities used in these templates, see sgds-utilities.
每个页面都必须包含Application Shell(应用外壳)。 在生成任何页面之前,请阅读**sgds-blocks → reference/application-shell.md**。该外壳在每个页面上提供必填的、<sgds-masthead>和<sgds-mainnav>,还包含容器类选择(<sgds-footer>对比.sgds-container)和粘性页眉约定。绝对不要生成缺少这三个外壳组件的页面模板。.sgds-container-sidebar
javascript
import "@govtechsg/sgds-web-component/themes/day.css";
import "@govtechsg/sgds-web-component/css/sgds.css";
import "@govtechsg/sgds-web-component/css/utility.css";如需完整安装说明,请查看**sgds-getting-started和sgds-components**。
关于这些模板中使用的容器宽度和最大宽度工具类,请查看**sgds-utilities**。
Quick Decision Guide
快速决策指南
| What you're building | Template to use |
|---|---|
| Admin dashboard with filters & data table | Application Management |
| Public catalogue with search & filtering | Catalogue / Search & Filter |
| Internal tool, admin portal, analytics dashboard | Dashboard |
| Login / sign-in page | Login |
| Multi-field settings or data-entry form | Form Page |
| Company/agency profile, team intro, achievements | About Us |
| Product or service landing page | Landing Page |
| Blog post, news article, or case study | Blog / Content Page |
| 你要构建的内容 | 使用的模板 |
|---|---|
| 带筛选器和数据表的管理仪表盘 | 应用管理 |
| 带搜索和筛选功能的公共目录 | 目录/搜索与筛选 |
| 内部工具、管理门户、分析仪表盘 | 仪表盘 |
| 登录/登入页面 | 登录页 |
| 多字段设置或数据录入表单 | 表单页 |
| 公司/机构简介、团队介绍、成果展示 | 关于我们 |
| 产品或服务着陆页 | 着陆页 |
| 博客文章、新闻报道或案例研究 | 博客/内容页 |
→ Read reference/application-management.md
→ 阅读 reference/application-management.md
Sidebar filters + search + data table + pagination. Use for admin dashboards, application registries, management portals.
侧边栏筛选器 + 搜索 + 数据表 + 分页。适用于管理仪表盘、应用注册系统、管理门户。
→ Read reference/catalogue.md
→ 阅读 reference/catalogue.md
Search + sidebar multi-group filters + sort dropdown + results grid + empty state. Use for product catalogues, event listings, content browsing.
搜索 + 侧边栏多组筛选器 + 排序下拉菜单 + 结果网格 + 空状态。适用于产品目录、活动列表、内容浏览场景。
→ Read reference/dashboard.md
→ 阅读 reference/dashboard.md
Sidebar navigation + stat cards row + data table. Use for dashboards, admin portals, internal tools with metrics.
Note: The dashboard template uses(RC component). Load the CDN script before other SGDS imports — see sgds-components sidebar reference for the CDN tag and framework setup.sgds-sidebar
侧边栏导航 + 统计卡片行 + 数据表。适用于仪表盘、管理门户、带指标的内部工具。
注意:仪表盘模板使用(候选版本组件)。请在其他SGDS导入之前加载CDN脚本——查看**sgds-components sidebar参考文档**获取CDN标签和框架设置说明。sgds-sidebar
→ Read reference/login.md
→ 阅读 reference/login.md
Centered card with email/password form. Use for authentication, sign-in, sign-up pages.
居中卡片式邮箱/密码表单。适用于认证、登入、注册页面。
→ Read reference/form.md
→ 阅读 reference/form.md
Two-column settings layout with labelled form sections. Use for settings pages, profile pages, multi-section data entry.
带标签表单区块的双列设置布局。适用于设置页面、个人资料页、多区块数据录入场景。
→ Read reference/about-us.md
→ 阅读 reference/about-us.md
Two-column headline + image grid + logo strip + achievements stats panel. Use for agency profiles, product about pages, team introductions.
双列标题 + 图片网格 + Logo条 + 成果统计面板。适用于机构简介、产品关于页、团队介绍。
→ Read reference/landing.md
→ 阅读 reference/landing.md
Hero section + feature cards + CTA sections. Use for product launches, service introductions, campaign pages.
英雄区块 + 功能卡片 + 号召性用语区块。适用于产品发布、服务介绍、活动推广页面。
→ Read reference/blog.md
→ 阅读 reference/blog.md
Featured image + article header + body content + author card. Use for blog posts, news articles, case studies, testimonials.
特色图片 + 文章标题 + 正文内容 + 作者卡片。适用于博客文章、新闻报道、案例研究、客户证言。
Raw Content Links — Copy & Paste Ready
原始内容链接 — 可直接复制粘贴
All page templates have working implementations in the directory. Use these raw GitHub links to fetch the complete source:
stories/templates/Each reference page (e.g., reference/dashboard.md) includes the relevant raw content links for that specific template.
所有页面模板在目录下都有可运行的实现。使用以下GitHub原始链接获取完整源代码:
stories/templates/每个参考页面(如reference/dashboard.md)都包含对应模板的相关原始内容链接。
How to Extract HTML from Raw GitHub Links
如何从GitHub原始链接提取HTML
All templates have working story implementations in the directory. To extract the HTML template:
stories/templates/所有模板在目录下都有可运行的Story实现。提取HTML模板的步骤如下:
stories/templates/Step 1: Fetch the raw file
步骤1:获取原始文件
Copy the raw GitHub URL from the table above and fetch it:
bash
curl https://raw.githubusercontent.com/GovTechSG/sgds-web-component/master/stories/templates/{FOLDER}/{FILE}.jsExample:
bash
curl https://raw.githubusercontent.com/GovTechSG/sgds-web-component/master/stories/templates/AboutUs/basic.stories.js复制上表中的GitHub原始链接并获取文件:
bash
curl https://raw.githubusercontent.com/GovTechSG/sgds-web-component/master/stories/templates/{FOLDER}/{FILE}.js示例:
bash
curl https://raw.githubusercontent.com/GovTechSG/sgds-web-component/master/stories/templates/AboutUs/basic.stories.jsStep 2: Extract the HTML from the template literal
步骤2:从模板字面量中提取HTML
Story files export a function that returns an template literal. Locate the section that looks like:
Templatehtmljavascript
const Template = () => html`
<!-- YOUR HTML STARTS HERE -->
<sgds-masthead></sgds-masthead>
...
<sgds-footer></sgds-footer>
<!-- YOUR HTML ENDS HERE -->
`;Story文件会导出一个函数,返回一个模板字面量。找到如下所示的区块:
Templatehtmljavascript
const Template = () => html`
<!-- YOUR HTML STARTS HERE -->
<sgds-masthead></sgds-masthead>
...
<sgds-footer></sgds-footer>
<!-- YOUR HTML ENDS HERE -->
`;Step 3: Clean the HTML
步骤3:清理HTML
- **Remove the html`` and trailing closing backtick
html\`` wrapper** — delete the leading - Remove Lit-specific syntax — delete any interpolations; replace with placeholder text if needed
${variable} - Remove blocks — move CSS to the reference file's "Customisation notes" section if notable
<style> - Preserve all SGDS components and utility classes — keep every element and
sgds-*class exactly as-issgds: - Format the HTML — use consistent indentation (2 spaces per level)
- **移除html``和结尾的反引号
html\``包裹** — 删除开头的 - 移除Lit特定语法 — 删除所有插值;如有需要,替换为占位文本
${variable} - 移除区块 — 如果内容重要,将CSS移至参考文件的“自定义说明”部分
<style> - 保留所有SGDS组件和工具类 — 完全保留每个元素和
sgds-*类sgds: - 格式化HTML — 使用统一的缩进(每级2个空格)
Step 4: Structure the reference file
步骤4:构建参考文件
Follow the sgds-blocks pattern:
markdown
undefined遵循sgds-blocks的格式:
markdown
undefined[Template Name] Page Template
[模板名称] 页面模板
[1-2 sentence description of what this template is for]
[1-2句话描述该模板的用途]
When to use
使用场景
- Use case 1
- Use case 2
- Use case 3
- 使用场景1
- 使用场景2
- 使用场景3
Block anatomy
区块结构
```
[ASCII diagram of the layout structure]
```
```
[布局结构的ASCII示意图]
```
Complete template
完整模板
```html
[CLEANED HTML FROM STEP 3]
```
```html
[步骤3中清理后的HTML]
```
Customisation notes
自定义说明
- Update [element] to [purpose]
- Modify [component] by [how]
- [More notes...]
- 更新[元素]以实现[目的]
- 通过[方式]修改[组件]
- [更多说明...]
Raw Content Link
原始内容链接
| File | GitHub Raw URL |
|---|---|
| [Template Name] | [raw GitHub URL] |
undefined| 文件 | GitHub原始URL |
|---|---|
| [模板名称] | [GitHub原始URL] |
undefinedExample: About Us template
示例:关于我们模板
The raw file at:
https://raw.githubusercontent.com/GovTechSG/sgds-web-component/master/stories/templates/AboutUs/basic.stories.jsContains:
javascript
const Template = () => html`
<style>...</style>
<sgds-masthead></sgds-masthead>
...
`;Extract → remove <style>` → result is the HTML in reference/about-us.md.
html\`` and backtick → clean up 原始文件地址:
https://raw.githubusercontent.com/GovTechSG/sgds-web-component/master/stories/templates/AboutUs/basic.stories.js包含内容:
javascript
const Template = () => html`
<style>...</style>
<sgds-masthead></sgds-masthead>
...
`;提取 → 移除<style>` → 结果即为reference/about-us.md中的HTML内容。
html\``和反引号 → 清理Visual Hierarchy Principles (apply to all templates)
视觉层次原则(适用于所有模板)
These are the rules that make SGDS UIs look polished — the same principles shadcn/Mantine use:
1. Layer backgrounds to create depth
- Page background: (the base canvas)
sgds:bg-surface-default - Cards / panels: (lifts content off the page)
sgds:bg-surface-raised - Nested content areas: sparingly
sgds:bg-surface-overlay
2. Use semantic spacing, not raw numbers
Prefer , , over . Semantic tokens are responsive and encode intent. Always apply whitespace between sections and elements — never render blocks without spacing. See sgds-utilities-spacing for the full defaults table.
sgds:p-layout-mdsgds:gap-layout-mdsgds:p-component-mdsgds:p-43. Consistent card anatomy
Every card: padding inside (), gap between card rows (), border-radius (), subtle shadow ().
sgds:p-component-lgsgds:gap-layout-mdsgds:rounded-lgsgds:shadow-card4. Action hierarchy in forms
Primary action → . Secondary / cancel → . Destructive → .
<sgds-button variant="primary"><sgds-button variant="outline"><sgds-button variant="ghost" tone="danger">5. Subtle labels, prominent values
In stat cards and description lists: label in , value in .
sgds:text-body-subtle sgds:text-smsgds:text-default sgds:text-2xl sgds:font-semibold这些规则让SGDS界面看起来更精致——与shadcn/Mantine使用的原则一致:
1. 通过分层背景营造深度
- 页面背景:(基础画布)
sgds:bg-surface-default - 卡片/面板:(让内容从页面中凸显)
sgds:bg-surface-raised - 嵌套内容区域:谨慎使用
sgds:bg-surface-overlay
2. 使用语义化间距,而非原始数值
优先使用、、,而非。语义化令牌具有响应式特性,且能传达设计意图。务必在区块和元素之间添加空白——绝对不要无间距地渲染区块。 查看sgds-utilities-spacing获取完整默认值表格。
sgds:p-layout-mdsgds:gap-layout-mdsgds:p-component-mdsgds:p-43. 统一的卡片结构
每张卡片:内部填充()、卡片行之间的间距()、圆角()、柔和阴影()。
sgds:p-component-lgsgds:gap-layout-mdsgds:rounded-lgsgds:shadow-card4. 表单中的操作层级
主操作 → 。次要/取消操作 → 。破坏性操作 → 。
<sgds-button variant="primary"><sgds-button variant="outline"><sgds-button variant="ghost" tone="danger">5. 标签弱化,数值突出
在统计卡片和描述列表中:标签使用,数值使用。
sgds:text-body-subtle sgds:text-smsgds:text-default sgds:text-2xl sgds:font-semibold