diff --git a/docs/api/checkbox.md b/docs/api/checkbox.md index 93e5fedeeed..490a0606d49 100644 --- a/docs/api/checkbox.md +++ b/docs/api/checkbox.md @@ -1,11 +1,6 @@ --- title: "ion-checkbox" -hide_table_of_contents: true -demoUrl: "/docs/demos/api/checkbox/index.html" -demoSourceUrl: "https://github.com/ionic-team/ionic-docs/tree/main/static/demos/api/checkbox/index.html" --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; import Props from '@site/static/auto-generated/checkbox/props.md'; import Events from '@site/static/auto-generated/checkbox/events.md'; @@ -24,17 +19,26 @@ import APITOCInline from '@components/page/api/APITOCInline'; -

Contents

- +Checkboxes allow the selection of multiple options from a set of options. They appear as checked (ticked) when activated. Clicking on a checkbox will toggle the `checked` property. They can also be checked programmatically by setting the `checked` property. +## Basic +import Basic from '@site/static/usage/checkbox/basic/index.md'; -Checkboxes allow the selection of multiple options from a set of options. They appear as checked (ticked) when activated. Clicking on a checkbox will toggle the `checked` property. They can also be checked programmatically by setting the `checked` property. + + +## Indeterminate Checkboxes + +import Indeterminate from '@site/static/usage/checkbox/indeterminate/index.md'; + + + +## Theming + +import Theming from '@site/static/usage/checkbox/theming/index.md'; + + ## Interfaces @@ -61,269 +65,6 @@ interface CheckboxCustomEvent extends CustomEvent { -## Usage - - - - - -```html - - - - - - - - - - - - - - - - - - - - {{entry.val}} - - - -``` - -```typescript -import { Component } from '@angular/core'; - -@Component({ - selector: 'app-page-home', - templateUrl: 'home.page.html', - styleUrls: ['home.page.scss'] -}) -export class HomePage { - public form = [ - { val: 'Pepperoni', isChecked: true }, - { val: 'Sausage', isChecked: false }, - { val: 'Mushroom', isChecked: false } - ]; -} -``` - - - - - - - -```html - - - - - - - - - - - - - - - - - - - - Pepperoni - - - - - Sausage - - - - - Mushrooms - - - -``` - - - - - - - -```tsx -import React, { useState } from 'react'; -import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar, IonCheckbox, IonList, IonItem, IonLabel, IonItemDivider } from '@ionic/react'; - -const checkboxList = [ - { val: 'Pepperoni', isChecked: true }, - { val: 'Sausage', isChecked: false }, - { val: 'Mushroom', isChecked: false } -]; - -export const CheckboxExamples: React.FC = () => { - - const [checked, setChecked] = useState(false); - - return ( - - - - CheckboxExamples - - - - - Default Checkbox - - Checked: {JSON.stringify(checked)} - setChecked(e.detail.checked)} /> - - - Disabled Checkbox - - - Checkbox Colors - - - - - - - - Checkboxes in a List - - {checkboxList.map(({ val, isChecked }, i) => ( - - {val} - - - ))} - - - - ); -}; -``` - - - - - - -```tsx -import { Component, h } from '@stencil/core'; - -@Component({ - tag: 'checkbox-example', - styleUrl: 'checkbox-example.css' -}) -export class CheckboxExample { - private form = [ - { val: 'Pepperoni', isChecked: true }, - { val: 'Sausage', isChecked: false }, - { val: 'Mushroom', isChecked: false } - ]; - - render() { - return [ - // Default Checkbox - , - - // Disabled Checkbox - , - - // Checked Checkbox - , - - // Checkbox Colors - , - , - , - , - , - - // Checkboxes in a List - - {this.form.map(entry => - - {entry.val} - - - )} - - ]; - } -} -``` - - - - - - - -```html - - - -``` - - - - - ## Properties @@ -340,4 +81,4 @@ export default defineComponent({ ## Slots - \ No newline at end of file + diff --git a/src/components/global/Playground/index.tsx b/src/components/global/Playground/index.tsx index ca4128b9929..c1c36bef703 100644 --- a/src/components/global/Playground/index.tsx +++ b/src/components/global/Playground/index.tsx @@ -169,7 +169,7 @@ export default function Playground({ * load, so a loading screen is shown by default. * Once the source of the iframe loads we can * hide the loading screen and show the inner content. - * + * * We call this as a local function because useEffect * callbacks cannot return a Promise, as async functions do. */ diff --git a/static/usage/checkbox/basic/angular.md b/static/usage/checkbox/basic/angular.md new file mode 100644 index 00000000000..29c262a3522 --- /dev/null +++ b/static/usage/checkbox/basic/angular.md @@ -0,0 +1,6 @@ +```html + + + I agree to the terms and conditions + +``` diff --git a/static/usage/checkbox/basic/demo.html b/static/usage/checkbox/basic/demo.html new file mode 100644 index 00000000000..d95a66ee2fd --- /dev/null +++ b/static/usage/checkbox/basic/demo.html @@ -0,0 +1,24 @@ + + + + + + Checkbox + + + + + + + + +
+ + + I agree to the terms and conditions + +
+
+
+ + diff --git a/static/usage/checkbox/basic/index.md b/static/usage/checkbox/basic/index.md new file mode 100644 index 00000000000..8e6d70bb205 --- /dev/null +++ b/static/usage/checkbox/basic/index.md @@ -0,0 +1,16 @@ +import Playground from '@site/src/components/global/Playground'; + +import javascript from './javascript.md'; +import react from './react.md'; +import vue from './vue.md'; +import angular from './angular.md'; + + diff --git a/static/usage/checkbox/basic/javascript.md b/static/usage/checkbox/basic/javascript.md new file mode 100644 index 00000000000..29c262a3522 --- /dev/null +++ b/static/usage/checkbox/basic/javascript.md @@ -0,0 +1,6 @@ +```html + + + I agree to the terms and conditions + +``` diff --git a/static/usage/checkbox/basic/react.md b/static/usage/checkbox/basic/react.md new file mode 100644 index 00000000000..64dda9457bb --- /dev/null +++ b/static/usage/checkbox/basic/react.md @@ -0,0 +1,18 @@ +```tsx +import React from 'react'; +import { + IonCheckbox, + IonItem, + IonLabel +} from '@ionic/react'; + +function Example() { + return ( + + + I agree to the terms and conditions + + ); +} +export default Example; +``` \ No newline at end of file diff --git a/static/usage/checkbox/basic/vue.md b/static/usage/checkbox/basic/vue.md new file mode 100644 index 00000000000..53cb1d16ccf --- /dev/null +++ b/static/usage/checkbox/basic/vue.md @@ -0,0 +1,25 @@ +```html + + + +``` diff --git a/static/usage/checkbox/indeterminate/angular.md b/static/usage/checkbox/indeterminate/angular.md new file mode 100644 index 00000000000..841851a904a --- /dev/null +++ b/static/usage/checkbox/indeterminate/angular.md @@ -0,0 +1,6 @@ +```html + + + Indeterminate checkbox + +``` diff --git a/static/usage/checkbox/indeterminate/demo.html b/static/usage/checkbox/indeterminate/demo.html new file mode 100644 index 00000000000..014f67d5210 --- /dev/null +++ b/static/usage/checkbox/indeterminate/demo.html @@ -0,0 +1,24 @@ + + + + + + Checkbox + + + + + + + + +
+ + + Indeterminate checkbox + +
+
+
+ + diff --git a/static/usage/checkbox/indeterminate/index.md b/static/usage/checkbox/indeterminate/index.md new file mode 100644 index 00000000000..01eb5a9da8a --- /dev/null +++ b/static/usage/checkbox/indeterminate/index.md @@ -0,0 +1,16 @@ +import Playground from '@site/src/components/global/Playground'; + +import javascript from './javascript.md'; +import react from './react.md'; +import vue from './vue.md'; +import angular from './angular.md'; + + diff --git a/static/usage/checkbox/indeterminate/javascript.md b/static/usage/checkbox/indeterminate/javascript.md new file mode 100644 index 00000000000..9a216a7d8b0 --- /dev/null +++ b/static/usage/checkbox/indeterminate/javascript.md @@ -0,0 +1,6 @@ +```html + + + Indeterminate checkbox + +``` diff --git a/static/usage/checkbox/indeterminate/react.md b/static/usage/checkbox/indeterminate/react.md new file mode 100644 index 00000000000..9e08f102560 --- /dev/null +++ b/static/usage/checkbox/indeterminate/react.md @@ -0,0 +1,18 @@ +```tsx +import React from 'react'; +import { + IonCheckbox, + IonItem, + IonLabel +} from '@ionic/react'; + +function Example() { + return ( + + + Indeterminate checkbox + + ); +} +export default Example; +``` \ No newline at end of file diff --git a/static/usage/checkbox/indeterminate/vue.md b/static/usage/checkbox/indeterminate/vue.md new file mode 100644 index 00000000000..0ad2ddbf62b --- /dev/null +++ b/static/usage/checkbox/indeterminate/vue.md @@ -0,0 +1,25 @@ +```html + + + +``` diff --git a/static/usage/checkbox/theming/angular/example_component_css.md b/static/usage/checkbox/theming/angular/example_component_css.md new file mode 100644 index 00000000000..c8fbfdb86d8 --- /dev/null +++ b/static/usage/checkbox/theming/angular/example_component_css.md @@ -0,0 +1,11 @@ +```css +ion-checkbox { + --size: 32px; + --background-checked: #6815ec; +} + +ion-checkbox::part(container) { + border-radius: 6px; + border: 2px solid #6815ec; +} +``` \ No newline at end of file diff --git a/static/usage/checkbox/theming/angular/example_component_html.md b/static/usage/checkbox/theming/angular/example_component_html.md new file mode 100644 index 00000000000..a54828724aa --- /dev/null +++ b/static/usage/checkbox/theming/angular/example_component_html.md @@ -0,0 +1,6 @@ +```html + + + Themed checkbox + +``` \ No newline at end of file diff --git a/static/usage/checkbox/theming/demo.html b/static/usage/checkbox/theming/demo.html new file mode 100644 index 00000000000..224dedb9800 --- /dev/null +++ b/static/usage/checkbox/theming/demo.html @@ -0,0 +1,35 @@ + + + + + + Checkbox + + + + + + + + + +
+ + + Themed checkbox + +
+
+
+ + diff --git a/static/usage/checkbox/theming/index.md b/static/usage/checkbox/theming/index.md new file mode 100644 index 00000000000..1fea21694a3 --- /dev/null +++ b/static/usage/checkbox/theming/index.md @@ -0,0 +1,31 @@ +import Playground from '@site/src/components/global/Playground'; + +import javascript from './javascript.md'; + +import react_main_tsx from './react/main_tsx.md'; +import react_main_css from './react/main_css.md'; + +import vue from './vue.md'; + +import angular_example_component_html from './angular/example_component_html.md'; +import angular_example_component_css from './angular/example_component_css.md'; + + diff --git a/static/usage/checkbox/theming/javascript.md b/static/usage/checkbox/theming/javascript.md new file mode 100644 index 00000000000..5ee2949135b --- /dev/null +++ b/static/usage/checkbox/theming/javascript.md @@ -0,0 +1,18 @@ +```html + + + Themed checkbox + + + +``` diff --git a/static/usage/checkbox/theming/react/main_css.md b/static/usage/checkbox/theming/react/main_css.md new file mode 100644 index 00000000000..c8fbfdb86d8 --- /dev/null +++ b/static/usage/checkbox/theming/react/main_css.md @@ -0,0 +1,11 @@ +```css +ion-checkbox { + --size: 32px; + --background-checked: #6815ec; +} + +ion-checkbox::part(container) { + border-radius: 6px; + border: 2px solid #6815ec; +} +``` \ No newline at end of file diff --git a/static/usage/checkbox/theming/react/main_tsx.md b/static/usage/checkbox/theming/react/main_tsx.md new file mode 100644 index 00000000000..28784175181 --- /dev/null +++ b/static/usage/checkbox/theming/react/main_tsx.md @@ -0,0 +1,20 @@ +```tsx +import React from 'react'; +import { + IonCheckbox, + IonItem, + IonLabel +} from '@ionic/react'; + +import './main.css'; + +function Example() { + return ( + + + Themed checkbox + + ); +} +export default Example; +``` \ No newline at end of file diff --git a/static/usage/checkbox/theming/vue.md b/static/usage/checkbox/theming/vue.md new file mode 100644 index 00000000000..3bb88c82577 --- /dev/null +++ b/static/usage/checkbox/theming/vue.md @@ -0,0 +1,37 @@ +```html + + + + + +```