インストール

3 つのステップで SurfaceOne を Angular 22 アプリケーションに追加します。

1. パッケージをインストールする

bash
npm install @surface-one/angular @surface-one/tokens

Markdown のエントリーポイントには、オプションのピア依存関係(marked、dompurify、@codemirror/* パッケージ)も必要です。これらは @surface-one/angular/markdown をインポートする場合にのみインストールしてください。

2. スタイルを読み込む

ビルドターゲットの styles 配列に、トークンとコンポーネントのスタイルシートを追加します。トークンを先に記述してください:

json
"styles": [
  "@surface-one/tokens",
  "@surface-one/angular/styles.css",
  "src/styles.css"
]

コンポーネントのスタイルは意図的にグローバルにしています。ほとんどのパーツはコンテンツ投影やポータルで描画され、エミュレートされたカプセル化が届かないためです。

3. ローカライゼーションを有効にする

コンポーネントは組み込みの文字列(「閉じる」など)を $localize でマークしているため、ポリフィルを追加します:

bash
ng add @angular/localize

コンポーネントを使う

ts
import { Component } from "@angular/core";
import { SoneButtonDirective } from "@surface-one/angular/button";
import { SoneSwitchComponent } from "@surface-one/angular/switch";

@Component({
  selector: "app-root",
  imports: [SoneButtonDirective, SoneSwitchComponent],
  template: `
    <sone-switch [(checked)]="enabled" ariaLabel="Notifications" />
    <button soneBtn variant="outline" type="button">Save</button>
  `,
})
export class App {
  enabled = true;
}

次に、テーマページでスキンとカラーモードを選びましょう。