Skip to content

Commit 6c48d36

Browse files
committed
docs(guide): update properties section and add virtual note to api
1 parent d8386b2 commit 6c48d36

File tree

5 files changed

+131
-12
lines changed

5 files changed

+131
-12
lines changed

docs/core-concepts/fundamentals.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,26 @@ Developers can use standard events such as `click` as they normally would. Howev
5454

5555
## Properties
5656

57-
[Properties (`@Prop`)](https://stenciljs.com/docs/properties) are custom attributes exposed publically on an HTML element. They allow developers to pass data to a component to render or otherwise use.
57+
Properties are JavaScript properties that can be set on Ionic components to configure their behavior and appearance. Properties are defined in each component's [API documentation](/docs/api) page.
5858

59-
### Virtual Properties
59+
### Reactive Properties
60+
61+
Reactive properties automatically update the component when their values change. These are the most common type of property in Ionic components.
6062

61-
In Ionic components, virutal properties are a special category of properties that are used to define inputs to a component without the reactivity that typically comes with `@Prop` decorated properties in Stencil.
63+
```html
64+
<ion-button color="primary">Primary Button</ion-button>
65+
```
6266

63-
Unlike `@Prop` inputs:
67+
The `color` property is a reactive property that configures how the button appears. If you change the `color` value after the initial render, the button will update to reflect the new value.
68+
69+
### Virtual Properties
6470

65-
- Virtual properties do not trigger a re-render when updated.
66-
- They cannot be mutated to produce side effects in the component lifecycle.
67-
- They are not tracked for changes and do not participate in Stencil's reactive data flow.
71+
Virtual properties are designed for one-time configuration during component initialization. They do not trigger re-renders when updated.
6872

69-
#### When to Use Virtual Properties
73+
```html
74+
<ion-button mode="ios">iOS Style Button</ion-button> <ion-button mode="md">Material Design Button</ion-button>
75+
```
7076

71-
Virtual properties are intended for use cases where you need to pass static or read-only data into a component, like configuration options or values that won't change during the component's lifecycle. They offer a lightweight alternative when you don't need Stencil's change detection or DOM updates.
77+
The `mode` property is a virtual property that determines which platform styles to use for a component. It can be set at the component level or globally through the app configuration. In both cases, it's set once during initialization and doesn't change during the component's lifecycle.
7278

73-
Because they are not reactive, updates to virtual properties after initial load will not affect the rendered output of the component.
79+
For more information on Ionic modes, read the [Platform Styles documentation](/docs/theming/platform-styles).

plugins/docusaurus-plugin-ionic-component-api/index.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,41 @@ function formatType(attr, type) {
134134
return type.replace(/\|/g, '\uff5c');
135135
}
136136

137-
function renderProperties({ props: properties }) {
137+
function renderProperties({ props: properties, docsTags }) {
138138
if (properties.length === 0) {
139139
return 'No properties available for this component.';
140140
}
141141

142+
// Extract virtual property names from component-level docsTags
143+
const virtualPropNames = [];
144+
if (docsTags) {
145+
docsTags.forEach((tag) => {
146+
if (tag.name === 'virtualProp') {
147+
// Check if any property name exists in the virtualProp tag text
148+
// and add it to the virtualPropNames array
149+
properties.forEach((prop) => {
150+
if (tag.text.includes(prop.name)) {
151+
virtualPropNames.push(prop.name);
152+
}
153+
});
154+
}
155+
});
156+
}
157+
142158
// NOTE: replaces | with U+FF5C since MDX renders \| in tables incorrectly
143159
return `
144160
${properties
145161
.map((prop) => {
146162
const isDeprecated = prop.deprecation !== undefined;
163+
const isVirtual = virtualPropNames.includes(prop.name);
147164
148-
const docs = isDeprecated ? `${prop.docs}\n\n**_Deprecated_** — ${prop.deprecation}` : prop.docs;
165+
let docs = prop.docs;
166+
if (isVirtual) {
167+
docs = `${docs}\n\nThis is a [virtual property](/docs/core-concepts/fundamentals#virtual-properties) that is set once during initialization and will not update if you change its value after the initial render.`;
168+
}
169+
if (isDeprecated) {
170+
docs = `${docs}\n\n**_Deprecated_** — ${prop.deprecation}`;
171+
}
149172
150173
return `
151174
### ${prop.name} ${isDeprecated ? '(deprecated)' : ''}

versioned_docs/version-v5/core-concepts/fundamentals.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,35 @@ Projects such as <a href="https://capacitorjs.com/" target="_blank">Capacitor</a
3838
## Theming
3939

4040
At the core, Ionic Framework is built using <a href="https://developer.mozilla.org/en-US/docs/Web/CSS" target="_blank">CSS</a> which allows us to take advantage of the flexibility that <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables" target="_blank">CSS properties (variables)</a> provide. This makes it incredibly easy to design an app that looks great while following the web standard. We provide a set of colors so developers can have some great defaults, but we encourage overriding them to create designs that match a brand, company or a desired color palette. Everything from the background color of an application to the text color is fully customizable. More information on app theming can be found in [Theming](../theming/basics.md).
41+
42+
## Events
43+
44+
Many Ionic components use [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent) to inform developers of important state changes in the components. For example, an `ion-datetime` component will emit `ionChange` whenever the selected date has changed.
45+
46+
Developers can use standard events such as `click` as they normally would. However, many events emitted within a component's [shadow root](../reference/glossary.md#shadow) will be [retargeted](https://dom.spec.whatwg.org/#retarget) to the host element. This may result in multiple `click` handlers executing even if the user only clicked once. As a result, developers should rely on Ionic's events to be properly informed of state changes on Ionic components. Ionic's events are prefixed with `ion` to avoid collisions with standard events. Each component's documentation page has a list of available events that developers can listen for in their applications.
47+
48+
## Properties
49+
50+
Properties are JavaScript properties that can be set on Ionic components to configure their behavior and appearance. Properties are defined in each component's [API documentation](/docs/api) page.
51+
52+
### Reactive Properties
53+
54+
Reactive properties automatically update the component when their values change. These are the most common type of property in Ionic components.
55+
56+
```html
57+
<ion-button color="primary">Primary Button</ion-button>
58+
```
59+
60+
The `color` property is a reactive property that configures how the button appears. If you change the `color` value after the initial render, the button will update to reflect the new value.
61+
62+
### Virtual Properties
63+
64+
Virtual properties are designed for one-time configuration during component initialization. They do not trigger re-renders when updated.
65+
66+
```html
67+
<ion-button mode="ios">iOS Style Button</ion-button> <ion-button mode="md">Material Design Button</ion-button>
68+
```
69+
70+
The `mode` property is a virtual property that determines which platform styles to use for a component. It can be set at the component level or globally through the app configuration. In both cases, it's set once during initialization and doesn't change during the component's lifecycle.
71+
72+
For more information on Ionic modes, read the [Platform Styles documentation](/docs/theming/platform-styles).

versioned_docs/version-v6/core-concepts/fundamentals.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,35 @@ Projects such as <a href="https://capacitorjs.com/" target="_blank">Capacitor</a
4545
## Theming
4646

4747
At the core, Ionic Framework is built using <a href="https://developer.mozilla.org/en-US/docs/Web/CSS" target="_blank">CSS</a> which allows us to take advantage of the flexibility that <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables" target="_blank">CSS properties (variables)</a> provide. This makes it incredibly easy to design an app that looks great while following the web standard. We provide a set of colors so developers can have some great defaults, but we encourage overriding them to create designs that match a brand, company or a desired color palette. Everything from the background color of an application to the text color is fully customizable. More information on app theming can be found in [Theming](../theming/basics.md).
48+
49+
## Events
50+
51+
Many Ionic components use [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent) to inform developers of important state changes in the components. For example, an `ion-datetime` component will emit `ionChange` whenever the selected date has changed.
52+
53+
Developers can use standard events such as `click` as they normally would. However, many events emitted within a component's [shadow root](../reference/glossary.md#shadow) will be [retargeted](https://dom.spec.whatwg.org/#retarget) to the host element. This may result in multiple `click` handlers executing even if the user only clicked once. As a result, developers should rely on Ionic's events to be properly informed of state changes on Ionic components. Ionic's events are prefixed with `ion` to avoid collisions with standard events. Each component's documentation page has a list of available events that developers can listen for in their applications.
54+
55+
## Properties
56+
57+
Properties are JavaScript properties that can be set on Ionic components to configure their behavior and appearance. Properties are defined in each component's [API documentation](/docs/api) page.
58+
59+
### Reactive Properties
60+
61+
Reactive properties automatically update the component when their values change. These are the most common type of property in Ionic components.
62+
63+
```html
64+
<ion-button color="primary">Primary Button</ion-button>
65+
```
66+
67+
The `color` property is a reactive property that configures how the button appears. If you change the `color` value after the initial render, the button will update to reflect the new value.
68+
69+
### Virtual Properties
70+
71+
Virtual properties are designed for one-time configuration during component initialization. They do not trigger re-renders when updated.
72+
73+
```html
74+
<ion-button mode="ios">iOS Style Button</ion-button> <ion-button mode="md">Material Design Button</ion-button>
75+
```
76+
77+
The `mode` property is a virtual property that determines which platform styles to use for a component. It can be set at the component level or globally through the app configuration. In both cases, it's set once during initialization and doesn't change during the component's lifecycle.
78+
79+
For more information on Ionic modes, read the [Platform Styles documentation](/docs/theming/platform-styles).

versioned_docs/version-v7/core-concepts/fundamentals.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,29 @@ At the core, Ionic Framework is built using <a href="https://developer.mozilla.o
5151
Many Ionic components use [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent) to inform developers of important state changes in the components. For example, an `ion-datetime` component will emit `ionChange` whenever the selected date has changed.
5252

5353
Developers can use standard events such as `click` as they normally would. However, many events emitted within a component's [shadow root](../reference/glossary.md#shadow) will be [retargeted](https://dom.spec.whatwg.org/#retarget) to the host element. This may result in multiple `click` handlers executing even if the user only clicked once. As a result, developers should rely on Ionic's events to be properly informed of state changes on Ionic components. Ionic's events are prefixed with `ion` to avoid collisions with standard events. Each component's documentation page has a list of available events that developers can listen for in their applications.
54+
55+
## Properties
56+
57+
Properties are JavaScript properties that can be set on Ionic components to configure their behavior and appearance. Properties are defined in each component's [API documentation](/docs/api) page.
58+
59+
### Reactive Properties
60+
61+
Reactive properties automatically update the component when their values change. These are the most common type of property in Ionic components.
62+
63+
```html
64+
<ion-button color="primary">Primary Button</ion-button>
65+
```
66+
67+
The `color` property is a reactive property that configures how the button appears. If you change the `color` value after the initial render, the button will update to reflect the new value.
68+
69+
### Virtual Properties
70+
71+
Virtual properties are designed for one-time configuration during component initialization. They do not trigger re-renders when updated.
72+
73+
```html
74+
<ion-button mode="ios">iOS Style Button</ion-button> <ion-button mode="md">Material Design Button</ion-button>
75+
```
76+
77+
The `mode` property is a virtual property that determines which platform styles to use for a component. It can be set at the component level or globally through the app configuration. In both cases, it's set once during initialization and doesn't change during the component's lifecycle.
78+
79+
For more information on Ionic modes, read the [Platform Styles documentation](/docs/theming/platform-styles).

0 commit comments

Comments
 (0)