Read component usage examples
get_component_usageFetch official usage examples for an Ionic component across Angular, React, Vue, and JavaScript. List available examples first or retrieve complete code with template, class, and styles for correct implementation.
Instructions
Read the official usage examples of one Ionic Framework component, as published on its documentation page. Use this before writing markup for a component to see how it is actually used in Angular, React, Vue or vanilla JavaScript — the template, the component class and the styles that belong together. Call it without an example first to see which examples the component offers. Returns the examples of the component with the frameworks each provides, or, when an example is given, its code per framework as fenced code blocks — one section per framework, and one block per file where an example spans several files. Do not use this for the component's API reference: its properties, events, methods, CSS shadow parts, CSS custom properties and slots are on the documentation page, which get_doc_page returns.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| example | No | The id of one example, e.g. "basic" or the nested "presentation/date". Defaults to listing the examples of the component instead of returning code. Optional. | |
| version | No | Optional. Ionic Framework docs version. Defaults to v9. Match the major version of @ionic/core (or @ionic/angular, @ionic/react, @ionic/vue) in the user's package.json. | |
| component | Yes | The component to read the examples of, e.g. "button". The tag is accepted too, e.g. "ion-button". | |
| framework | No | Optional. The framework to return the example for, e.g. "react". Match the framework of the user's project. Defaults to returning every framework the example provides. |