Installation

1. Add the package

Web (React)

npm install @dotwear/web

# Icons only
npm install @dotwear/icons

iOS (SwiftUI)

In Xcode: File › Add Package Dependencies…, enter https://github.com/dotwear-dev/dotwear-swift, and add the Dotwear library (or DotwearIcons for icons only). With Package.swift:

dependencies: [
    .package(url: "https://github.com/dotwear-dev/dotwear-swift", from: "0.1.0"),
],
targets: [
    .target(name: "MyApp", dependencies: [
        .product(name: "Dotwear", package: "dotwear-swift"),
    ]),
]

Requirements: React 18 or later for the web; iOS 16 / macOS 13 or later and Swift 6 for SwiftUI.

2. Use it

Web (React)

import "@dotwear/web/tokens.css";
import "@dotwear/web/fonts.css";
import "@dotwear/web/components.css";
import "@dotwear/icons/palette.css";
import { DotwearButton, dwSave } from "@dotwear/web";

export function SaveButton() {
  return (
    <DotwearButton icon={dwSave} onClick={() => console.log("saved")}>
      Save
    </DotwearButton>
  );
}

iOS (SwiftUI)

struct ContentView: View {
    @State private var email = ""

    var body: some View {
        VStack(spacing: 16) {
            DotwearIcon(.save, scale: 2)
            TextField("Email", text: $email)
                .textFieldStyle(.dotwear)
            Button("Save") { save() }
                .buttonStyle(.dotwear)
        }
        .padding()
        .dotwearTheme()
    }

    func save() {}
}
  • Web: import these once, at the root of your app: tokens.css (colors and sizes as CSS variables), fonts.css (the bundled DotGothic16 pixel font), components.css (the look of the React components) and palette.css (icon palettes). The components also work without React: put the same class names on standard elements.
  • iOS: import Dotwear also gives you the icons. .dotwearTheme() at the root is optional — without it, the default theme is used.

Next