> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# Native Plugin

An app with a **native plugin** of its own, in `native/greeter`. It has:

- a `Greeter` module, which answers from Swift or Kotlin
- a `<native-switch>` element, drawn by UIKit's `UISwitch` and Android's `Switch`
- a `<native-sheet>` element, which shows the Angular elements inside it in UIKit's sheet and Material's `BottomSheetDialog`

Flip the switch, and Angular hears it. Tap the button, and Angular turns it off. Open the sheet, and its counter counts your taps.

The preview has no native code. So there, the module's call fails and the switch is an empty element.


## What it shows

- **`nativePlugins` in angular.json** — the plugin's folder, `native/greeter`, and the module's and the elements' classes on each platform. See [Add native code](/guide/native-plugins/index.md).
- **`NativeModuleMap`** — `greeter.ts` types the module, so `getNativeModule('Greeter')` returns a typed proxy whose call is a promise.
- **`registerNativeElement()`** — `native-switch.ts` has the runtime create the plugin's element for the tag, and types its `checked` attribute and its `change` event.
- **The plugin's own resources** — the switch is on in the plugin's color, light and dark. See [Add resources](/guide/native-plugins/index.md#add-resources).
  - iOS: a color set in `ios/Greeter.xcassets`.
  - Android: `android/res`'s `values/` and `values-night/` colors, with the color state lists in `color/` that `R.color.greeter_switch_thumb` names.
- **`HostElementUI`** — `NativeSheet.swift` and `NativeSheet.kt` move the element's children into the system's sheet, where their taps still reach Angular. See [Show an element's children in a sheet](/guide/native-plugins/hosted-children.md).

Run it with `ng build --platform ios --run` or `--platform android --run`. In the preview and in [Lynx Explorer](/guide/glossary.md#lynx-explorer), the plugin isn't there.

## Related

- [Shortcuts](/examples/shortcuts.md)
- [`LynxNativeModule` API](/api/angular-lynx/host/native-module.md)
