Get started
Develop
Install SGDS, use the component library, and build interfaces with shared foundations.
| npm install @govtechsg/sgds-web-component |
| pnpm add @govtechsg/sgds-web-component |
| yarn add @govtechsg/sgds-web-component |
| bun add @govtechsg/sgds-web-component |
SGDS utility classes require Tailwind CSS v4. Follow the official Tailwind installation guide for your framework.
Import the theme tokens, foundation styles, and utility classes in your main CSS file. The order matters — theme tokens must come first.
| @import "@govtechsg/sgds-web-component/themes/day.css"; |
| @import "@govtechsg/sgds-web-component/themes/night.css"; |
| @import "@govtechsg/sgds-web-component/css/sgds.css"; |
| @import "@govtechsg/sgds-web-component/css/utility.css"; /* SGDS Tailwind v4 config file */ |
SGDS foundation styles use Inter by default. Add the Google Fonts link in your HTML head before any SGDS CSS. This loads only the four weights defined by the SGDS design tokens (300, 400, 600, 700) in both normal and italic styles.
| <head> |
| <link rel="preconnect" href="https://fonts.googleapis.com" /> |
| <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> |
| <link |
| href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,600;0,14..32,700;1,14..32,300;1,14..32,400;1,14..32,600;1,14..32,700&display=swap" |
| rel="stylesheet" |
| /> |
| </head> |
Import the library once at your app entry point. This registers all <sgds-*> custom elements globally.
React 19 and above
Step 1: Import the library once at your app entry point.
| import "@govtechsg/sgds-web-component"; |
Step 2: Use web component tags directly in any component.
| const App = () => { |
| return ( |
| <form> |
| <sgds-input label="Full name" name="fullName"></sgds-input> |
| <sgds-button type="submit" ariaLabel="Submit">Submit</sgds-button> |
| </form> |
| ); |
| }; |
| export default App; |
React 18 and below
Step 1: Use the React wrapper components for proper event handling.
| import { SgdsButton, SgdsInput } from "@govtechsg/sgds-web-component/react"; |
Step 2: Use the wrapper components in JSX.
| import { SgdsButton, SgdsInput } from "@govtechsg/sgds-web-component/react"; |
| const App = () => { |
| return ( |
| <form> |
| <SgdsInput label="Full name" name="fullName" /> |
| <SgdsButton type="submit">Submit</SgdsButton> |
| </form> |
| ); |
| }; |
| export default App; |
TypeScript support
Step 1: Add a type declaration file at your project root to enable IntelliSense for all component props and typed event handlers.
| import "@govtechsg/sgds-web-component/types/react"; |
Step 2: Ensure the file is included by your tsconfig.json.
| { |
| "include": ["types.d.ts", "**/*.ts", "**/*.tsx"] |
| } |
Step 1: Tell Vue to treat sgds-* tags as custom elements.
| import { defineConfig } from "vite"; |
| import vue from "@vitejs/plugin-vue"; |
| export default defineConfig({ |
| plugins: [ |
| vue({ |
| template: { |
| compilerOptions: { |
| isCustomElement: (tag) => tag.startsWith("sgds-"), |
| }, |
| }, |
| }), |
| ], |
| }); |
Step 2: Import the library in your app entry.
| import "@govtechsg/sgds-web-component"; |
Step 1: Add CUSTOM_ELEMENTS_SCHEMA to your standalone component.
| import { Component, CUSTOM_ELEMENTS_SCHEMA } from "@angular/core"; |
| @Component({ |
| selector: "app-root", |
| templateUrl: "./app.component.html", |
| schemas: [CUSTOM_ELEMENTS_SCHEMA] // Step 1 |
| }) |
| export class AppComponent {} |
Step 2: Import the library in your root component to register all custom elements globally.
| import { Component, CUSTOM_ELEMENTS_SCHEMA } from "@angular/core"; |
| import "@govtechsg/sgds-web-component"; // Step 2 |
| @Component({ |
| selector: "app-root", |
| templateUrl: "./app.component.html", |
| schemas: [CUSTOM_ELEMENTS_SCHEMA] |
| }) |
| export class AppComponent {} |
Setup
Step 1: Create a client-side library loader.
| "use client"; |
| import { useEffect } from "react"; |
| export default function SgdsLoader() { |
| useEffect(() => { |
| import("@govtechsg/sgds-web-component"); |
| }, []); |
| return null; |
| } |
Step 2: Import the loader in your root layout.
| import SgdsLoader from "./sgds"; |
| export default function RootLayout({ children }: { children: React.ReactNode }) { |
| return ( |
| <html lang="en"> |
| <head> |
| <SgdsLoader /> |
| </head> |
| <body>{children}</body> |
| </html> |
| ); |
| } |
TypeScript support
Step 1: Add a type declaration file at your project root to enable IntelliSense for all component props and typed event handlers.
| import "@govtechsg/sgds-web-component/types/react"; |
Step 2: Ensure the file is included by your tsconfig.json.
| { |
| "include": ["types.d.ts", "**/*.ts", "**/*.tsx"] |
| } |
Cannot find your frontend framework integration?
Use templates, blocks, and components when you need to move from product intent to working UI quickly.
Components
Use SGDS components for interaction patterns such as buttons, tabs, forms, cards, and tables.
Apply SGDS utility classes for spacing, layout, typography, colour, and responsive behaviour instead of custom CSS.
Accelerate development with AI-assisted workflows and agent skills that understand SGDS components, utilities, and patterns.