Button

Runs an action when pressed. Stepped corners, a one-dot shadow, and a one-dot press-down.

Variants and sizes

Web (React)

<DotwearButton onClick={save}>Save</DotwearButton>

<DotwearButton variant="secondary" size="small" onClick={cancel}>
  Cancel
</DotwearButton>

<DotwearButton variant="danger" icon={dwTrash} onClick={remove}>
  Delete
</DotwearButton>

iOS (SwiftUI)

Button("Save") { save() }
    .buttonStyle(.dotwear)

Button("Cancel") { cancel() }
    .buttonStyle(.dotwear(.secondary, size: .small))

Button(role: .destructive) { delete() } label: {
    Label("Delete", systemImage: "trash")
}
.buttonStyle(.dotwear(.danger))

React Native

<DotwearButton onPress={save}>Save</DotwearButton>

<DotwearButton variant="secondary" size="small" onPress={cancel}>
  Cancel
</DotwearButton>

<DotwearButton variant="danger" icon={dwTrash} onPress={remove}>
  Delete
</DotwearButton>

Flutter

const DotwearButton(onPressed: save, child: Text('Save')),

const DotwearButton(
  variant: DotwearButtonVariant.secondary,
  size: DotwearButtonSize.small,
  onPressed: cancel,
  child: Text('Cancel'),
),

const DotwearButton(
  variant: DotwearButtonVariant.danger,
  icon: DotwearIcons.trash,
  onPressed: remove,
  child: Text('Delete'),
),

Loading

Web (React)

<DotwearButton icon={dwSave} loading={isSaving} disabled={isSaving} onClick={save}>
  Save
</DotwearButton>

iOS (SwiftUI)

Button("Save") { save() }
    .buttonStyle(.dotwear)
    .dotwearLoading(isSaving)
    .disabled(isSaving)

React Native

<DotwearButton icon={dwSave} loading={isSaving} disabled={isSaving} onPress={save}>
  Save
</DotwearButton>

Flutter

DotwearButton(
  icon: DotwearIcons.save,
  loading: isSaving,
  onPressed: isSaving ? null : save, // null disables it
  child: const Text('Save'),
),

Variants

VariantUse for
primaryThe most important action on the screen (default)
secondaryAny other action
dangerDestructive actions such as delete
ghostBorder only — for toolbars

States

StateAppearance
defaultOne-dot shadow below and to the right
pressedShadow removed, body shifts down by one dot
focusedOne-dot focus ring outside the border
disabledDisabled colors, no shadow
loadingThree animated dots replace the label

React API

PropDescription
variant="primary""primary" (default), "secondary", "danger", "ghost"
size="medium""small", "medium" (default), "large"
icon={dwSave}An icon before the label (decorative). Icon-only buttons need aria-label
loadingShows the loading dots and sets aria-busy. Does not disable the button; add disabled if needed
…button propsAny <button> attribute. type defaults to "button"

SwiftUI API

APIDescription
.buttonStyle(.dotwear)Primary, medium
.buttonStyle(.dotwear(_ variant:, size:))variant: .primary .secondary .danger .ghost — size: .small .medium .large
.dotwearLoading(_ isLoading: Bool = true)Shows the loading dots. Does not disable the button; add .disabled if needed

React Native API

PropDescription
variant="primary""primary" (default), "secondary", "danger", "ghost"
size="medium""small", "medium" (default), "large"
icon={dwSave}An icon before the label (decorative). Icon-only buttons need accessibilityLabel
loadingShows the loading dots and sets accessibilityState.busy. Does not disable the button; add disabled if needed
…Pressable propsonPress, disabled, accessibilityLabel, style, … The button takes its content width; stretch it with style

Flutter API

ParameterDescription
onPressedRequired. null disables the button, like Flutter's standard buttons
variant: DotwearButtonVariant.primary.primary (default), .secondary, .danger, .ghost
size: DotwearButtonSize.medium.small, .medium (default), .large
icon: DotwearIcons.saveAn icon before the label (decorative). Icon-only buttons need semanticLabel
loading: trueShows the loading dots. The label is still read. Does not disable the button
DotwearButtonStyle.of(context, …)The same look as a ButtonStyle for any standard button. Also pass clipBehavior: Clip.none

Accessibility

  • Web: it is a standard <button>, so keyboard, focus, screen readers and form submission work as usual. The focus ring appears for keyboard focus (:focus-visible).
  • iOS: it is a standard Button, so VoiceOver, Dynamic Type, Full Keyboard Access and Voice Control work as usual.
  • React Native: a standard Pressable with accessibilityRole="button". The touch target is at least 44 pt (iOS) / 48 dp (Android).
  • Flutter: a standard TextButton, so screen readers, keyboard focus and the 48 × 48 touch target work as usual.
  • Icon-only buttons must have an accessibility label.