@porsche-design-system/components-react 4.5.0 → 4.6.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/bin/pds-skill.js +259 -0
- package/esm/lib/components/button.wrapper.d.ts +2 -2
- package/esm/lib/components/link.wrapper.d.ts +2 -2
- package/package.json +4 -3
- package/skill/SKILL.md +136 -0
- package/skill/references/components/p-accordion/examples/Default.tsx +24 -0
- package/skill/references/components/p-accordion/examples/InteractiveElementsInSummary.tsx +28 -0
- package/skill/references/components/p-accordion/examples/StickySummary.tsx +24 -0
- package/skill/references/components/p-accordion/p-accordion.md +95 -0
- package/skill/references/components/p-ai-tag/examples/Default.tsx +10 -0
- package/skill/references/components/p-ai-tag/examples/WithinCheckbox.tsx +30 -0
- package/skill/references/components/p-ai-tag/examples/WithinFormLabel.tsx +37 -0
- package/skill/references/components/p-ai-tag/examples/WithinImage.tsx +13 -0
- package/skill/references/components/p-ai-tag/examples/WithinInputSearch.tsx +12 -0
- package/skill/references/components/p-ai-tag/examples/WithinRadioGroup.tsx +29 -0
- package/skill/references/components/p-ai-tag/examples/WithinTable.tsx +91 -0
- package/skill/references/components/p-ai-tag/examples/WithinText.tsx +14 -0
- package/skill/references/components/p-ai-tag/p-ai-tag.md +47 -0
- package/skill/references/components/p-banner/examples/Customization.tsx +35 -0
- package/skill/references/components/p-banner/examples/Default.tsx +24 -0
- package/skill/references/components/p-banner/p-banner.md +92 -0
- package/skill/references/components/p-button/examples/Default.tsx +12 -0
- package/skill/references/components/p-button/examples/Form.tsx +28 -0
- package/skill/references/components/p-button/examples/FormAttribute.tsx +31 -0
- package/skill/references/components/p-button/p-button.md +118 -0
- package/skill/references/components/p-button-pure/examples/CustomClickableArea.tsx +12 -0
- package/skill/references/components/p-button-pure/examples/Default.tsx +12 -0
- package/skill/references/components/p-button-pure/examples/Form.tsx +28 -0
- package/skill/references/components/p-button-pure/examples/FormAttribute.tsx +32 -0
- package/skill/references/components/p-button-pure/p-button-pure.md +118 -0
- package/skill/references/components/p-button-tile/examples/ColorScheme.tsx +15 -0
- package/skill/references/components/p-button-tile/examples/Default.tsx +18 -0
- package/skill/references/components/p-button-tile/examples/FooterSlot.tsx +29 -0
- package/skill/references/components/p-button-tile/examples/Hyphens.tsx +33 -0
- package/skill/references/components/p-button-tile/examples/UiBehaviour.tsx +41 -0
- package/skill/references/components/p-button-tile/p-button-tile.md +115 -0
- package/skill/references/components/p-canvas/examples/Default.tsx +10 -0
- package/skill/references/components/p-canvas/p-canvas.md +91 -0
- package/skill/references/components/p-carousel/examples/Default.tsx +23 -0
- package/skill/references/components/p-carousel/examples/DynamicSlides.tsx +32 -0
- package/skill/references/components/p-carousel/examples/FlexibleWidths.tsx +29 -0
- package/skill/references/components/p-carousel/examples/FocusOnCenterSlide.tsx +56 -0
- package/skill/references/components/p-carousel/examples/Intl.tsx +20 -0
- package/skill/references/components/p-carousel/examples/JumpToSlide.tsx +42 -0
- package/skill/references/components/p-carousel/p-carousel.md +142 -0
- package/skill/references/components/p-checkbox/examples/Default.tsx +10 -0
- package/skill/references/components/p-checkbox/examples/Form.tsx +45 -0
- package/skill/references/components/p-checkbox/examples/Indeterminate.tsx +13 -0
- package/skill/references/components/p-checkbox/examples/Slots.tsx +54 -0
- package/skill/references/components/p-checkbox/examples/WrappedLabel.tsx +24 -0
- package/skill/references/components/p-checkbox/p-checkbox.md +122 -0
- package/skill/references/components/p-crest/examples/CustomClickableArea.tsx +10 -0
- package/skill/references/components/p-crest/examples/Default.tsx +10 -0
- package/skill/references/components/p-crest/examples/Link.tsx +10 -0
- package/skill/references/components/p-crest/p-crest.md +65 -0
- package/skill/references/components/p-display/examples/Color.tsx +12 -0
- package/skill/references/components/p-display/examples/Default.tsx +12 -0
- package/skill/references/components/p-display/examples/Semantics.tsx +18 -0
- package/skill/references/components/p-display/examples/Size.tsx +12 -0
- package/skill/references/components/p-display/examples/SizeResponsive.tsx +12 -0
- package/skill/references/components/p-display/p-display.md +78 -0
- package/skill/references/components/p-divider/examples/Default.tsx +10 -0
- package/skill/references/components/p-divider/examples/Responsive.tsx +12 -0
- package/skill/references/components/p-divider/examples/Vertical.tsx +12 -0
- package/skill/references/components/p-divider/p-divider.md +49 -0
- package/skill/references/components/p-drilldown/examples/CustomContent.tsx +164 -0
- package/skill/references/components/p-drilldown/examples/Default.tsx +117 -0
- package/skill/references/components/p-drilldown/p-drilldown.md +168 -0
- package/skill/references/components/p-fieldset/examples/Default.tsx +12 -0
- package/skill/references/components/p-fieldset/examples/Required.tsx +13 -0
- package/skill/references/components/p-fieldset/examples/SlottedLabel.tsx +15 -0
- package/skill/references/components/p-fieldset/examples/SlottedMessage.tsx +15 -0
- package/skill/references/components/p-fieldset/p-fieldset.md +88 -0
- package/skill/references/components/p-flag/examples/Default.tsx +10 -0
- package/skill/references/components/p-flag/examples/ResponsiveSize.tsx +10 -0
- package/skill/references/components/p-flag/examples/Size.tsx +13 -0
- package/skill/references/components/p-flag/examples/SizeCssVar.tsx +10 -0
- package/skill/references/components/p-flag/p-flag.md +68 -0
- package/skill/references/components/p-flyout/examples/CustomStyling.tsx +45 -0
- package/skill/references/components/p-flyout/examples/Default.tsx +42 -0
- package/skill/references/components/p-flyout/examples/Form.tsx +54 -0
- package/skill/references/components/p-flyout/examples/StickyTop.tsx +42 -0
- package/skill/references/components/p-flyout/p-flyout.md +128 -0
- package/skill/references/components/p-heading/examples/Color.tsx +12 -0
- package/skill/references/components/p-heading/examples/Default.tsx +12 -0
- package/skill/references/components/p-heading/examples/Semantics.tsx +18 -0
- package/skill/references/components/p-heading/p-heading.md +78 -0
- package/skill/references/components/p-icon/examples/Color.tsx +13 -0
- package/skill/references/components/p-icon/examples/ColorCssVar.tsx +10 -0
- package/skill/references/components/p-icon/examples/Custom.tsx +10 -0
- package/skill/references/components/p-icon/examples/Default.tsx +10 -0
- package/skill/references/components/p-icon/examples/Overview.tsx +588 -0
- package/skill/references/components/p-icon/examples/ResponsiveSize.tsx +10 -0
- package/skill/references/components/p-icon/examples/Size.tsx +13 -0
- package/skill/references/components/p-icon/examples/SizeCssVar.tsx +10 -0
- package/skill/references/components/p-icon/p-icon.md +88 -0
- package/skill/references/components/p-inline-notification/examples/ActionButton.tsx +25 -0
- package/skill/references/components/p-inline-notification/examples/Default.tsx +10 -0
- package/skill/references/components/p-inline-notification/examples/EventHandling.tsx +25 -0
- package/skill/references/components/p-inline-notification/p-inline-notification.md +74 -0
- package/skill/references/components/p-input-date/examples/Default.tsx +10 -0
- package/skill/references/components/p-input-date/examples/Form.tsx +45 -0
- package/skill/references/components/p-input-date/examples/Slots.tsx +41 -0
- package/skill/references/components/p-input-date/p-input-date.md +142 -0
- package/skill/references/components/p-input-email/examples/Default.tsx +10 -0
- package/skill/references/components/p-input-email/examples/Form.tsx +51 -0
- package/skill/references/components/p-input-email/examples/Slots.tsx +41 -0
- package/skill/references/components/p-input-email/p-input-email.md +146 -0
- package/skill/references/components/p-input-month/examples/Default.tsx +10 -0
- package/skill/references/components/p-input-month/examples/Form.tsx +45 -0
- package/skill/references/components/p-input-month/examples/Slots.tsx +41 -0
- package/skill/references/components/p-input-month/p-input-month.md +142 -0
- package/skill/references/components/p-input-number/examples/Default.tsx +10 -0
- package/skill/references/components/p-input-number/examples/Form.tsx +51 -0
- package/skill/references/components/p-input-number/examples/Slots.tsx +41 -0
- package/skill/references/components/p-input-number/p-input-number.md +150 -0
- package/skill/references/components/p-input-password/examples/Default.tsx +10 -0
- package/skill/references/components/p-input-password/examples/Form.tsx +51 -0
- package/skill/references/components/p-input-password/examples/Slots.tsx +39 -0
- package/skill/references/components/p-input-password/examples/Toggle.tsx +10 -0
- package/skill/references/components/p-input-password/p-input-password.md +145 -0
- package/skill/references/components/p-input-search/examples/AriaCombobox.tsx +35 -0
- package/skill/references/components/p-input-search/examples/Default.tsx +10 -0
- package/skill/references/components/p-input-search/examples/Form.tsx +52 -0
- package/skill/references/components/p-input-search/examples/Slots.tsx +41 -0
- package/skill/references/components/p-input-search/p-input-search.md +182 -0
- package/skill/references/components/p-input-tel/examples/Default.tsx +10 -0
- package/skill/references/components/p-input-tel/examples/Form.tsx +45 -0
- package/skill/references/components/p-input-tel/examples/Slots.tsx +41 -0
- package/skill/references/components/p-input-tel/p-input-tel.md +145 -0
- package/skill/references/components/p-input-text/examples/Controlled.tsx +36 -0
- package/skill/references/components/p-input-text/examples/Default.tsx +10 -0
- package/skill/references/components/p-input-text/examples/Form.tsx +45 -0
- package/skill/references/components/p-input-text/examples/Slots.tsx +41 -0
- package/skill/references/components/p-input-text/p-input-text.md +150 -0
- package/skill/references/components/p-input-time/examples/Default.tsx +10 -0
- package/skill/references/components/p-input-time/examples/Form.tsx +45 -0
- package/skill/references/components/p-input-time/examples/Slots.tsx +41 -0
- package/skill/references/components/p-input-time/p-input-time.md +144 -0
- package/skill/references/components/p-input-url/examples/Default.tsx +10 -0
- package/skill/references/components/p-input-url/examples/Form.tsx +45 -0
- package/skill/references/components/p-input-url/examples/Slots.tsx +41 -0
- package/skill/references/components/p-input-url/p-input-url.md +145 -0
- package/skill/references/components/p-input-week/examples/Default.tsx +10 -0
- package/skill/references/components/p-input-week/examples/Form.tsx +45 -0
- package/skill/references/components/p-input-week/examples/Slots.tsx +41 -0
- package/skill/references/components/p-input-week/p-input-week.md +142 -0
- package/skill/references/components/p-link/examples/Default.tsx +12 -0
- package/skill/references/components/p-link/examples/FrameworkRouting.tsx +14 -0
- package/skill/references/components/p-link/examples/Icon.tsx +17 -0
- package/skill/references/components/p-link/p-link.md +101 -0
- package/skill/references/components/p-link-pure/examples/CustomClickableArea.tsx +12 -0
- package/skill/references/components/p-link-pure/examples/Default.tsx +12 -0
- package/skill/references/components/p-link-pure/examples/FrameworkRouting.tsx +14 -0
- package/skill/references/components/p-link-pure/examples/Icon.tsx +17 -0
- package/skill/references/components/p-link-pure/p-link-pure.md +110 -0
- package/skill/references/components/p-link-tile/examples/ColorScheme.tsx +15 -0
- package/skill/references/components/p-link-tile/examples/Default.tsx +18 -0
- package/skill/references/components/p-link-tile/examples/FooterSlot.tsx +29 -0
- package/skill/references/components/p-link-tile/examples/Hyphens.tsx +34 -0
- package/skill/references/components/p-link-tile/examples/UiBehaviour.tsx +41 -0
- package/skill/references/components/p-link-tile/examples/WithVideo.tsx +15 -0
- package/skill/references/components/p-link-tile/p-link-tile.md +105 -0
- package/skill/references/components/p-link-tile-product/examples/Default.tsx +22 -0
- package/skill/references/components/p-link-tile-product/examples/FrameworkRouting.tsx +25 -0
- package/skill/references/components/p-link-tile-product/p-link-tile-product.md +93 -0
- package/skill/references/components/p-modal/examples/AlertDialog.tsx +39 -0
- package/skill/references/components/p-modal/examples/CustomStyling.tsx +26 -0
- package/skill/references/components/p-modal/examples/Default.tsx +39 -0
- package/skill/references/components/p-modal/examples/Scrollable.tsx +43 -0
- package/skill/references/components/p-modal/p-modal.md +135 -0
- package/skill/references/components/p-model-signature/examples/CustomStyling.tsx +14 -0
- package/skill/references/components/p-model-signature/examples/Default.tsx +10 -0
- package/skill/references/components/p-model-signature/examples/MaskBlendMode.tsx +32 -0
- package/skill/references/components/p-model-signature/examples/MaskImage.tsx +12 -0
- package/skill/references/components/p-model-signature/examples/MaskVideo.tsx +12 -0
- package/skill/references/components/p-model-signature/examples/SafeZone.tsx +60 -0
- package/skill/references/components/p-model-signature/p-model-signature.md +62 -0
- package/skill/references/components/p-multi-select/examples/AsyncFilter.tsx +136 -0
- package/skill/references/components/p-multi-select/examples/Default.tsx +29 -0
- package/skill/references/components/p-multi-select/examples/Form.tsx +53 -0
- package/skill/references/components/p-multi-select/examples/Optgroups.tsx +42 -0
- package/skill/references/components/p-multi-select/examples/SelectedSlot.tsx +94 -0
- package/skill/references/components/p-multi-select/examples/SetValue.tsx +80 -0
- package/skill/references/components/p-multi-select/examples/Slots.tsx +48 -0
- package/skill/references/components/p-multi-select/p-multi-select.md +197 -0
- package/skill/references/components/p-pagination/examples/Default.tsx +10 -0
- package/skill/references/components/p-pagination/p-pagination.md +83 -0
- package/skill/references/components/p-pin-code/examples/CopyPaste.tsx +10 -0
- package/skill/references/components/p-pin-code/examples/Default.tsx +10 -0
- package/skill/references/components/p-pin-code/examples/Form.tsx +45 -0
- package/skill/references/components/p-pin-code/examples/Slots.tsx +39 -0
- package/skill/references/components/p-pin-code/p-pin-code.md +109 -0
- package/skill/references/components/p-popover/examples/Default.tsx +14 -0
- package/skill/references/components/p-popover/examples/SlottedButton.tsx +15 -0
- package/skill/references/components/p-popover/p-popover.md +116 -0
- package/skill/references/components/p-radio-group/examples/Default.tsx +17 -0
- package/skill/references/components/p-radio-group/examples/Form.tsx +53 -0
- package/skill/references/components/p-radio-group/examples/Slots.tsx +69 -0
- package/skill/references/components/p-radio-group/p-radio-group.md +157 -0
- package/skill/references/components/p-scroller/examples/Default.tsx +51 -0
- package/skill/references/components/p-scroller/examples/Height.tsx +26 -0
- package/skill/references/components/p-scroller/examples/ScrollToPosition.tsx +58 -0
- package/skill/references/components/p-scroller/p-scroller.md +93 -0
- package/skill/references/components/p-segmented-control/examples/Default.tsx +26 -0
- package/skill/references/components/p-segmented-control/examples/Form.tsx +52 -0
- package/skill/references/components/p-segmented-control/examples/Slots.tsx +54 -0
- package/skill/references/components/p-segmented-control/examples/WithLabels.tsx +26 -0
- package/skill/references/components/p-segmented-control/p-segmented-control.md +162 -0
- package/skill/references/components/p-select/examples/AsyncFilter.tsx +136 -0
- package/skill/references/components/p-select/examples/Default.tsx +29 -0
- package/skill/references/components/p-select/examples/Form.tsx +53 -0
- package/skill/references/components/p-select/examples/Optgroups.tsx +42 -0
- package/skill/references/components/p-select/examples/Required.tsx +48 -0
- package/skill/references/components/p-select/examples/SelectedSlot.tsx +124 -0
- package/skill/references/components/p-select/examples/SetValue.tsx +80 -0
- package/skill/references/components/p-select/examples/Slots.tsx +48 -0
- package/skill/references/components/p-select/examples/SlottedImages.tsx +35 -0
- package/skill/references/components/p-select/p-select.md +194 -0
- package/skill/references/components/p-sheet/examples/Default.tsx +31 -0
- package/skill/references/components/p-sheet/p-sheet.md +121 -0
- package/skill/references/components/p-spinner/examples/Color.tsx +13 -0
- package/skill/references/components/p-spinner/examples/ColorCssVar.tsx +10 -0
- package/skill/references/components/p-spinner/examples/Default.tsx +10 -0
- package/skill/references/components/p-spinner/examples/ResponsiveSize.tsx +10 -0
- package/skill/references/components/p-spinner/examples/Size.tsx +13 -0
- package/skill/references/components/p-spinner/examples/SizeCssVar.tsx +10 -0
- package/skill/references/components/p-spinner/p-spinner.md +96 -0
- package/skill/references/components/p-stepper-horizontal/examples/Default.tsx +23 -0
- package/skill/references/components/p-stepper-horizontal/examples/FrameworkImplementation.tsx +100 -0
- package/skill/references/components/p-stepper-horizontal/p-stepper-horizontal.md +109 -0
- package/skill/references/components/p-switch/examples/Default.tsx +19 -0
- package/skill/references/components/p-switch/p-switch.md +103 -0
- package/skill/references/components/p-table/examples/Advanced.tsx +186 -0
- package/skill/references/components/p-table/examples/CaptionProperty.tsx +37 -0
- package/skill/references/components/p-table/examples/CaptionSlot.tsx +40 -0
- package/skill/references/components/p-table/examples/Default.tsx +117 -0
- package/skill/references/components/p-table/examples/HideLabel.tsx +37 -0
- package/skill/references/components/p-table/examples/LayoutFixed.tsx +50 -0
- package/skill/references/components/p-table/examples/Sorting.tsx +86 -0
- package/skill/references/components/p-table/p-table.md +189 -0
- package/skill/references/components/p-tabs/examples/ActiveTab.tsx +26 -0
- package/skill/references/components/p-tabs/examples/Default.tsx +26 -0
- package/skill/references/components/p-tabs/examples/Gradient.tsx +111 -0
- package/skill/references/components/p-tabs/examples/Labelling.tsx +26 -0
- package/skill/references/components/p-tabs/p-tabs.md +136 -0
- package/skill/references/components/p-tabs-bar/examples/Default.tsx +27 -0
- package/skill/references/components/p-tabs-bar/examples/Gradient.tsx +78 -0
- package/skill/references/components/p-tabs-bar/examples/Labelling.tsx +27 -0
- package/skill/references/components/p-tabs-bar/examples/Links.tsx +20 -0
- package/skill/references/components/p-tabs-bar/p-tabs-bar.md +181 -0
- package/skill/references/components/p-tag/examples/Default.tsx +12 -0
- package/skill/references/components/p-tag/examples/Multiline.tsx +14 -0
- package/skill/references/components/p-tag/examples/SlottedButton.tsx +41 -0
- package/skill/references/components/p-tag/examples/SlottedLink.tsx +41 -0
- package/skill/references/components/p-tag/p-tag.md +66 -0
- package/skill/references/components/p-tag-dismissible/examples/Default.tsx +12 -0
- package/skill/references/components/p-tag-dismissible/p-tag-dismissible.md +75 -0
- package/skill/references/components/p-text/examples/Default.tsx +12 -0
- package/skill/references/components/p-text/examples/Semantics.tsx +18 -0
- package/skill/references/components/p-text/examples/Size.tsx +12 -0
- package/skill/references/components/p-text/examples/SizeResponsive.tsx +12 -0
- package/skill/references/components/p-text/p-text.md +68 -0
- package/skill/references/components/p-text-list/examples/Default.tsx +28 -0
- package/skill/references/components/p-text-list/p-text-list.md +68 -0
- package/skill/references/components/p-textarea/examples/Default.tsx +10 -0
- package/skill/references/components/p-textarea/examples/Form.tsx +45 -0
- package/skill/references/components/p-textarea/examples/Slots.tsx +39 -0
- package/skill/references/components/p-textarea/p-textarea.md +122 -0
- package/skill/references/components/p-toast/examples/Default.tsx +22 -0
- package/skill/references/components/p-toast/p-toast.md +61 -0
- package/skill/references/components/p-wordmark/examples/CustomClickableArea.tsx +10 -0
- package/skill/references/components/p-wordmark/examples/Default.tsx +10 -0
- package/skill/references/components/p-wordmark/examples/Size.tsx +10 -0
- package/skill/references/components/p-wordmark/p-wordmark.md +66 -0
- package/skill/references/icons.md +5 -0
- package/skill/references/styles/emotion.md +439 -0
- package/skill/references/styles/scss.md +402 -0
- package/skill/references/styles/tailwindcss.md +356 -0
- package/skill/references/styles/vanilla-extract.md +444 -0
- package/skill/references/stylesheets.md +331 -0
- package/skill/references/tokens.md +323 -0
- package/ssr/cjs/components/dist/styles/esm/styles-entry.cjs +1 -1
- package/ssr/cjs/components/dist/utils/esm/utils-entry.cjs +1 -1
- package/ssr/esm/components/dist/styles/esm/styles-entry.mjs +1 -1
- package/ssr/esm/components/dist/utils/esm/utils-entry.mjs +1 -1
- package/ssr/esm/lib/components/button.wrapper.d.ts +2 -2
- package/ssr/esm/lib/components/link.wrapper.d.ts +2 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PSpinner } from '@porsche-design-system/components-react';
|
|
3
|
+
|
|
4
|
+
export const Example = () => {
|
|
5
|
+
return (
|
|
6
|
+
<>
|
|
7
|
+
<PSpinner size={{'base': 'sm', 'l': '2xl'}} aria={{'aria-label': 'Loading page content'}}></PSpinner>
|
|
8
|
+
</>
|
|
9
|
+
)
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PSpinner, PText } from '@porsche-design-system/components-react';
|
|
3
|
+
|
|
4
|
+
export const Example = () => {
|
|
5
|
+
return (
|
|
6
|
+
<>
|
|
7
|
+
<PText className="text-[48px]" size="inherit">
|
|
8
|
+
<PSpinner className="me-static-sm" size="inherit" aria={{'aria-label': 'Loading page content'}}></PSpinner>
|
|
9
|
+
Some text
|
|
10
|
+
</PText>
|
|
11
|
+
</>
|
|
12
|
+
)
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PSpinner } from '@porsche-design-system/components-react';
|
|
3
|
+
|
|
4
|
+
export const Example = () => {
|
|
5
|
+
return (
|
|
6
|
+
<>
|
|
7
|
+
<PSpinner className="[--p-spinner-size:48px]" aria={{'aria-label': 'Loading page content'}}></PSpinner>
|
|
8
|
+
</>
|
|
9
|
+
)
|
|
10
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# p-spinner
|
|
2
|
+
|
|
3
|
+
The `p-spinner` component indicates an indeterminate ongoing process and should be used when users must wait for loading or processing to finish.
|
|
4
|
+
|
|
5
|
+
There are unavoidable moments when the user has to wait for more than 1 second (for example due to technical processing of information or requests). These moments should be bridged with a good user feedback in order to not leave the user uncertain about what's currently happening - also to avoid a high bounce rate and to obtain a positive impression of your website or application.
|
|
6
|
+
|
|
7
|
+
For ongoing operations between 2-10 seconds, where the loading progress cannot be determined, use a **Spinner** (looped indicator) to inform the user about an ongoing operation. Use it either stand-alone (for example as page loader) or within components, such as in Buttons to indicate progress after clicking "save".
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
### Do:
|
|
12
|
+
|
|
13
|
+
- Use when the user has to wait for more than 1 second.
|
|
14
|
+
- Use either stand-alone or within components (e.g. in Buttons to indicate progress after clicking "save“).
|
|
15
|
+
- Use vertically and horizontally centered within the referring area.
|
|
16
|
+
- Use a blocking layer for the whole screen when the user is not supposed to start another activity.
|
|
17
|
+
- Include simple text to explain why the user is waiting.
|
|
18
|
+
- Disable the component while the spinner is visible if it is triggered by an interaction.
|
|
19
|
+
|
|
20
|
+
### Don't:
|
|
21
|
+
|
|
22
|
+
- Don't use too many Spinners at the same time within a page or application.
|
|
23
|
+
- Don't use Spinners for delays of more than 10 seconds without providing a progress bar showing the estimated waiting time.
|
|
24
|
+
- Don't use threatening text such as "Don't click again" to prevent the user from clicking twice.
|
|
25
|
+
|
|
26
|
+
## Accessibility support
|
|
27
|
+
|
|
28
|
+
### ARIA enhancements
|
|
29
|
+
|
|
30
|
+
#### External **ARIA** provided by the `aria` property:
|
|
31
|
+
|
|
32
|
+
| ARIA | Usage |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| `aria-label` | Defines a string value that labels the live region. |
|
|
35
|
+
|
|
36
|
+
#### Internal **ARIA** that is managed by the component:
|
|
37
|
+
|
|
38
|
+
| ARIA | Usage |
|
|
39
|
+
| --- | --- |
|
|
40
|
+
| `role="alert"` | Provided message is announced. |
|
|
41
|
+
|
|
42
|
+
## Development considerations
|
|
43
|
+
|
|
44
|
+
### Announcing loading messages
|
|
45
|
+
|
|
46
|
+
To provide feedback to screen reader users, it is mandatory to announce the loading state of the spinner. This can be achieved in the following ways:
|
|
47
|
+
|
|
48
|
+
- Pre-rendering the component in the DOM.
|
|
49
|
+
- Providing a meaningful loading state message through the `aria` property, e.g. `aria="{ 'aria-label': 'Start/End loading content'}"`.
|
|
50
|
+
|
|
51
|
+
### Common do's and don'ts
|
|
52
|
+
|
|
53
|
+
- **Do** pre-render the spinner when loading feedback must be announced.
|
|
54
|
+
- **Do** provide a specific loading message through the `aria` prop.
|
|
55
|
+
- **Don't** mount the spinner only at the moment loading starts without a label.
|
|
56
|
+
|
|
57
|
+
## Notes
|
|
58
|
+
|
|
59
|
+
### Disable animation
|
|
60
|
+
|
|
61
|
+
For automated visual regression tests, the spinner animation can be disabled by setting a global CSS variable:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
:root {
|
|
65
|
+
--p-animation-duration: 0s !important;
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## API
|
|
70
|
+
|
|
71
|
+
### Properties
|
|
72
|
+
|
|
73
|
+
| Property | Type | Default | Description |
|
|
74
|
+
| --- | --- | --- | --- |
|
|
75
|
+
| `aria` | `SpinnerAriaAttribute` | `undefined` | Sets ARIA attributes on the spinner's live region element; use `aria-label` to provide a descriptive loading message for screen readers. |
|
|
76
|
+
| `color` | `'primary'` `'inherit'` | `'primary'` | Sets the color of the spinning indicator using PDS semantic color tokens (e.g. `primary`, `contrast-high`, `inherit`). |
|
|
77
|
+
| `size` | `'2xs'` `'xs'` `'sm'` `'md'` `'lg'` `'xl'` `'2xl'` `'3xl'` `'4xl'` `'5xl'` `'inherit'`<br>_deprecated:_ `'small'` `'medium'` `'large'`<br>`BreakpointCustomizable<SpinnerSize>` | `'sm'` | Sets the size of the spinner using the PDS typographic scale. Use `inherit` to derive the size from the parent element's font-size. Supports responsive breakpoint values. |
|
|
78
|
+
|
|
79
|
+
### CSS Variables
|
|
80
|
+
|
|
81
|
+
| CSS Variable | Default | Description |
|
|
82
|
+
| --- | --- | --- |
|
|
83
|
+
| `--p-spinner-size` | — | Defines the width and height of the spinner. Overrides the `size` property when set. |
|
|
84
|
+
| `--p-spinner-color` | — | Defines the foreground color. Overrides the `color` property when set. |
|
|
85
|
+
| `--p-spinner-track-color` | — | Defines the track/background color. Overrides the `color` property when set. |
|
|
86
|
+
|
|
87
|
+
## Examples
|
|
88
|
+
|
|
89
|
+
| Example | When to use | File |
|
|
90
|
+
| --- | --- | --- |
|
|
91
|
+
| Default | Minimal default configuration. | [./examples/Default.tsx](./examples/Default.tsx) |
|
|
92
|
+
| Size via Prop | There are predefined sizes for the component available which should cover most use cases. | [./examples/Size.tsx](./examples/Size.tsx) |
|
|
93
|
+
| Size via CSS Variable | Instead of using the `size` prop, the size can be controlled via the custom CSS variable `--p-spinner-size`, which accepts any valid CSS length value. | [./examples/SizeCssVar.tsx](./examples/SizeCssVar.tsx) |
|
|
94
|
+
| Responsive Size | The `size` property supports `BreakpointCustomizable` values, allowing you to define different sizes for each major breakpoint (`xs`, `s`, `m`, `l`, `xl`). | [./examples/ResponsiveSize.tsx](./examples/ResponsiveSize.tsx) |
|
|
95
|
+
| Color via Prop | The `color` property can be set to `inherit` to derive the spinner's color from the `currentcolor` of a parent element (e.g. a `p-text`). | [./examples/Color.tsx](./examples/Color.tsx) |
|
|
96
|
+
| Color via CSS Variable | Instead of using the `color` prop, the colors can be controlled via the custom CSS variables `--p-spinner-color` and `--p-spinner-track-color`, which accept any valid CSS color value. | [./examples/ColorCssVar.tsx](./examples/ColorCssVar.tsx) |
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PStepperHorizontal, PStepperHorizontalItem } from '@porsche-design-system/components-react';
|
|
3
|
+
|
|
4
|
+
export const Example = () => {
|
|
5
|
+
return (
|
|
6
|
+
<>
|
|
7
|
+
<PStepperHorizontal>
|
|
8
|
+
<PStepperHorizontalItem state="complete">
|
|
9
|
+
Step 1
|
|
10
|
+
</PStepperHorizontalItem>
|
|
11
|
+
<PStepperHorizontalItem state="warning">
|
|
12
|
+
Step 2
|
|
13
|
+
</PStepperHorizontalItem>
|
|
14
|
+
<PStepperHorizontalItem state="current">
|
|
15
|
+
Step 3
|
|
16
|
+
</PStepperHorizontalItem>
|
|
17
|
+
<PStepperHorizontalItem>
|
|
18
|
+
Step 4
|
|
19
|
+
</PStepperHorizontalItem>
|
|
20
|
+
</PStepperHorizontal>
|
|
21
|
+
</>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
PButton,
|
|
4
|
+
PStepperHorizontal,
|
|
5
|
+
PStepperHorizontalItem,
|
|
6
|
+
PText,
|
|
7
|
+
type StepperHorizontalItemState,
|
|
8
|
+
type StepperHorizontalUpdateEventDetail,
|
|
9
|
+
} from '@porsche-design-system/components-react';
|
|
10
|
+
import { useState } from 'react';
|
|
11
|
+
|
|
12
|
+
type StepperHorizontalItemProps = {
|
|
13
|
+
state?: StepperHorizontalItemState;
|
|
14
|
+
name: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const Example = () => {
|
|
18
|
+
const [steps, setSteps] = useState<StepperHorizontalItemProps[]>([
|
|
19
|
+
{
|
|
20
|
+
state: 'current',
|
|
21
|
+
name: 'Enter personal details',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'Confirm e-mail',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'Set password',
|
|
28
|
+
},
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
const stepContent: string[] = [
|
|
32
|
+
'A form with personal details could be displayed here.',
|
|
33
|
+
'A form with a verification code input field could be displayed here.',
|
|
34
|
+
'A form with a password input field could be displayed here.',
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
const getActiveStepIndex = (steps: StepperHorizontalItemProps[]): number =>
|
|
38
|
+
steps.findIndex((step) => step.state === 'current');
|
|
39
|
+
|
|
40
|
+
const onNextPrevStep = (direction: 'next' | 'prev'): void => {
|
|
41
|
+
const newState = [...steps];
|
|
42
|
+
const activeStepIndex = getActiveStepIndex(newState);
|
|
43
|
+
|
|
44
|
+
if (direction === 'next') {
|
|
45
|
+
newState[activeStepIndex].state = 'complete';
|
|
46
|
+
newState[activeStepIndex + 1].state = 'current';
|
|
47
|
+
} else {
|
|
48
|
+
delete newState[activeStepIndex].state;
|
|
49
|
+
newState[activeStepIndex - 1].state = 'current';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
setSteps(newState);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const onUpdate = (e: CustomEvent<StepperHorizontalUpdateEventDetail>): void => {
|
|
56
|
+
const { activeStepIndex } = e.detail;
|
|
57
|
+
|
|
58
|
+
const newState = [...steps];
|
|
59
|
+
for (let i = activeStepIndex + 1; i < newState.length; i++) {
|
|
60
|
+
// reset step state when going back via stepper horizontal item click
|
|
61
|
+
delete newState[i].state;
|
|
62
|
+
}
|
|
63
|
+
newState[activeStepIndex].state = 'current';
|
|
64
|
+
setSteps(newState);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<div className="flex flex-col gap-fluid-sm">
|
|
69
|
+
<PStepperHorizontal onUpdate={onUpdate}>
|
|
70
|
+
{steps.map(({ state, name }) => (
|
|
71
|
+
<PStepperHorizontalItem key={name} state={state}>
|
|
72
|
+
{name}
|
|
73
|
+
</PStepperHorizontalItem>
|
|
74
|
+
))}
|
|
75
|
+
</PStepperHorizontal>
|
|
76
|
+
|
|
77
|
+
{stepContent.map((content, i) => getActiveStepIndex(steps) === i && <PText key={i}>{content}</PText>)}
|
|
78
|
+
|
|
79
|
+
<div className="flex gap-fluid-sm">
|
|
80
|
+
<PButton
|
|
81
|
+
type="button"
|
|
82
|
+
icon="arrow-head-left"
|
|
83
|
+
variant="secondary"
|
|
84
|
+
onClick={() => onNextPrevStep('prev')}
|
|
85
|
+
disabled={getActiveStepIndex(steps) === 0}
|
|
86
|
+
>
|
|
87
|
+
Previous Step
|
|
88
|
+
</PButton>
|
|
89
|
+
|
|
90
|
+
<PButton
|
|
91
|
+
variant="primary"
|
|
92
|
+
disabled={getActiveStepIndex(steps) === steps.length - 1}
|
|
93
|
+
onClick={() => onNextPrevStep('next')}
|
|
94
|
+
>
|
|
95
|
+
Next Step
|
|
96
|
+
</PButton>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# p-stepper-horizontal
|
|
2
|
+
|
|
3
|
+
The `p-stepper-horizontal` component displays progress through a sequence of logical and numbered steps. It is ideal when the contents of one step depends on an earlier step. Avoid using long step names.
|
|
4
|
+
|
|
5
|
+
The component does not handle the display of your content. When using the component you have to manually take care of the content to be rendered beneath. To help with this task, if a step is clicked, the component triggers an event called `change` with the index of the clicked step.
|
|
6
|
+
|
|
7
|
+
**Note**: Maximum of 9 steps are supported.
|
|
8
|
+
|
|
9
|
+
It is a controlled component. This means it does not contain any internal state and you got full control over its behavior.
|
|
10
|
+
|
|
11
|
+
Use `p-stepper-horizontal-item`s inside the `p-stepper-horizontal` component. Each item will be rendered as a step. You have to manually manage the state of the items by setting the `state` property.
|
|
12
|
+
|
|
13
|
+
The `state` property can be set to `complete` when a step is complete, `warning` when a user has to revisit the step, `current` for the step that is in progress and `undefined`.
|
|
14
|
+
|
|
15
|
+
If the `state` property is `undefined` the step renders as stateless and disabled. This can be used to prevent the user from navigating to a step which is not yet reachable. This is to be used for future steps which cannot yet be processed at the time.
|
|
16
|
+
|
|
17
|
+
By clicking on a previous step, the `p-stepper-horizontal` emits the `update` event, which contains the index of the clicked step.
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Do:
|
|
22
|
+
|
|
23
|
+
- Use to display progress through a sequence of logical and numbered steps.
|
|
24
|
+
- Use when the content of one step depends on an earlier step.
|
|
25
|
+
- Use short and descriptive labels for each step.
|
|
26
|
+
- Make completed steps clickable so that the user can jump back to previous steps.
|
|
27
|
+
- Be aware that the component does not handle the display of your content and you will need to manually take care of the content to be rendered beneath.
|
|
28
|
+
- Consider how you can simplify the component and use between 3-5 steps for the best user experience.
|
|
29
|
+
|
|
30
|
+
### Don't:
|
|
31
|
+
|
|
32
|
+
- Don't use long step names as it can make the component difficult to use.
|
|
33
|
+
- Don't use more than 9 steps (component has a maximum of 9)
|
|
34
|
+
- Don't forget that if a set of steps can not fit on the screen the stepper becomes horizontally scrollable and navigable with arrows.
|
|
35
|
+
|
|
36
|
+
## Accessibility support
|
|
37
|
+
|
|
38
|
+
### Keyboard
|
|
39
|
+
|
|
40
|
+
| Key / state | Function |
|
|
41
|
+
| --- | --- |
|
|
42
|
+
| `Tab`, `Shift-Tab` | Moves focus to the scroll container or to next (or previous) focusable element. |
|
|
43
|
+
| `Enter`, `Space` | Activates the completed and current step-item. |
|
|
44
|
+
| `disabled` | Step-item still focusable. |
|
|
45
|
+
|
|
46
|
+
### ARIA enhancements
|
|
47
|
+
|
|
48
|
+
#### Internal **ARIA** that is managed by the component:
|
|
49
|
+
|
|
50
|
+
| ARIA | Usage |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| `role="list"` | Indicates the stepper as list element. |
|
|
53
|
+
| `role="listitem"` | Indicates the step-item as list-item element. |
|
|
54
|
+
|
|
55
|
+
## Development considerations
|
|
56
|
+
|
|
57
|
+
### Common do's and don'ts
|
|
58
|
+
|
|
59
|
+
- **Do** provide descriptive text in each step item so progress is understandable out of context.
|
|
60
|
+
- **Do** reflect the current step with the item `state` prop (`current`, `complete`, `warning`).
|
|
61
|
+
- **Don't** use generic labels like "Step 1" without describing the step purpose.
|
|
62
|
+
|
|
63
|
+
## API
|
|
64
|
+
|
|
65
|
+
### Properties
|
|
66
|
+
|
|
67
|
+
| Property | Type | Default | Description |
|
|
68
|
+
| --- | --- | --- | --- |
|
|
69
|
+
| `size` | `'small'` `'medium'`<br>`BreakpointCustomizable<StepperHorizontalSize>` | `'small'` | The font size of the step labels. |
|
|
70
|
+
|
|
71
|
+
### Events
|
|
72
|
+
|
|
73
|
+
| Event | Type | Description |
|
|
74
|
+
| --- | --- | --- |
|
|
75
|
+
| `update` | `CustomEvent<StepperHorizontalUpdateEventDetail>`<br>`{ activeStepIndex: number }` | Emitted when active step is changed. |
|
|
76
|
+
|
|
77
|
+
### Slots
|
|
78
|
+
|
|
79
|
+
| Slot | Required | Allowed tag names | Description |
|
|
80
|
+
| --- | --- | --- | --- |
|
|
81
|
+
| _(default)_ | no | — | Default slot for the `p-stepper-horizontal-item` tags. |
|
|
82
|
+
|
|
83
|
+
## Sub-components
|
|
84
|
+
|
|
85
|
+
These tags are only valid inside the parent(s) listed under each one — often this component, but some are shared and list a different parent (e.g. a tag documented here via a common ancestor). Their APIs come from the same authoritative `component-meta` as the parent above.
|
|
86
|
+
|
|
87
|
+
### `p-stepper-horizontal-item`
|
|
88
|
+
|
|
89
|
+
Allowed parent: `p-stepper-horizontal`.
|
|
90
|
+
|
|
91
|
+
#### Properties
|
|
92
|
+
|
|
93
|
+
| Property | Type | Default | Description |
|
|
94
|
+
| --- | --- | --- | --- |
|
|
95
|
+
| `disabled` | `boolean` | `false` | Disables the stepper-horizontal-item. No events will be triggered while disabled state is active. |
|
|
96
|
+
| `state` | `undefined` `'current'` `'complete'` `'warning'` | `undefined` | The current progression state of the step. Use `current` for the active step, `complete` for finished steps, `warning` for steps with issues. Leave unset for future steps. |
|
|
97
|
+
|
|
98
|
+
#### Slots
|
|
99
|
+
|
|
100
|
+
| Slot | Required | Allowed tag names | Description |
|
|
101
|
+
| --- | --- | --- | --- |
|
|
102
|
+
| _(default)_ | no | — | Default slot for the content. |
|
|
103
|
+
|
|
104
|
+
## Examples
|
|
105
|
+
|
|
106
|
+
| Example | When to use | File |
|
|
107
|
+
| --- | --- | --- |
|
|
108
|
+
| Default | Minimal default configuration. | [./examples/Default.tsx](./examples/Default.tsx) |
|
|
109
|
+
| Framework Implementation | Below you can find an interactive example of an outlined registration process. | [./examples/FrameworkImplementation.tsx](./examples/FrameworkImplementation.tsx) |
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { PSwitch, type SwitchUpdateEventDetail } from '@porsche-design-system/components-react';
|
|
4
|
+
|
|
5
|
+
export const Example = () => {
|
|
6
|
+
const [checked, setChecked] = useState(false);
|
|
7
|
+
|
|
8
|
+
const onUpdate = (e: CustomEvent<SwitchUpdateEventDetail>) => {
|
|
9
|
+
setChecked(e.detail.checked);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<>
|
|
14
|
+
<PSwitch checked={checked} onUpdate={onUpdate}>
|
|
15
|
+
Some label
|
|
16
|
+
</PSwitch>
|
|
17
|
+
</>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# p-switch
|
|
2
|
+
|
|
3
|
+
The `p-switch` component is a control that is used to quickly switch between two possible states. A switch is only used for these binary actions that occur immediately after the user “flips the switch”. Commonly it is used for “on/off” state.
|
|
4
|
+
|
|
5
|
+
It is a controlled component. This means it does not contain any internal state, and you got full control over its behavior.
|
|
6
|
+
|
|
7
|
+
The `p-switch` component can be used with a visible or hidden label, but it's recommended to keep the label visible for better accessibility whenever possible. A `label` is a caption which informs the user which action is followed by interaction. When used with hidden label, it's best practice to provide a descriptive label text for screen readers.
|
|
8
|
+
|
|
9
|
+
You can use native `click`, `focus`, `focusin`, `blur` and `focusout` events on the `p-switch`.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Do:
|
|
14
|
+
|
|
15
|
+
- Use it when an instant response to applied settings is required without explicit action.
|
|
16
|
+
- Use to enable or disable a mode, feature, or function.
|
|
17
|
+
- Use when the user is toggling independent features or behaviors.
|
|
18
|
+
- Use the label to describe the affected property.
|
|
19
|
+
- Use the right-aligned version for lists (especially for handling on mobile devices).
|
|
20
|
+
- Use the stretched version for lists on mobile or smaller containers.
|
|
21
|
+
|
|
22
|
+
### Don't:
|
|
23
|
+
|
|
24
|
+
- Don't use it if a setting requires a button press before it can take effect (use a [Checkbox](../p-checkbox/p-checkbox.md) instead).
|
|
25
|
+
- Don't use anything longer than two words in the label whenever possible.
|
|
26
|
+
- Don't use the switch for multiple-choice questions.
|
|
27
|
+
- Don't use slide Switch when an intermediate state is required (Use [Checkbox](../p-checkbox/p-checkbox.md) instead).
|
|
28
|
+
- Don't use the label to describe the state of the component.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Related Components
|
|
33
|
+
|
|
34
|
+
- [Checkbox](../p-checkbox/p-checkbox.md)
|
|
35
|
+
- [Button](../p-button/p-button.md)
|
|
36
|
+
|
|
37
|
+
## Accessibility support
|
|
38
|
+
|
|
39
|
+
### Keyboard
|
|
40
|
+
|
|
41
|
+
| Key / state | Function |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| `Tab`, `Shift-Tab` | Moves focus to the scroll container or to next (or previous) focusable element. |
|
|
44
|
+
| `Enter`, `Space` | Activates the completed and current step-item. |
|
|
45
|
+
| `disabled` | Step-item still focusable. |
|
|
46
|
+
|
|
47
|
+
### ARIA enhancements
|
|
48
|
+
|
|
49
|
+
#### Internal **ARIA** that is managed by the component:
|
|
50
|
+
|
|
51
|
+
| ARIA | Usage |
|
|
52
|
+
| --- | --- |
|
|
53
|
+
| `role="switch"` | Indicates the element as switch element. |
|
|
54
|
+
| `aria-checked="BOOLEAN"` | Indicates the status of the switch element. |
|
|
55
|
+
| `role="status"` | When `loading` prop is set, the component announces the loading state (start and finish). |
|
|
56
|
+
|
|
57
|
+
## Development considerations
|
|
58
|
+
|
|
59
|
+
### Labelling
|
|
60
|
+
|
|
61
|
+
The switch accessible name comes from the default slot. Provide concise, descriptive text that states what the switch controls and its on/off meaning.
|
|
62
|
+
|
|
63
|
+
### Common do's and don'ts
|
|
64
|
+
|
|
65
|
+
- **Do** provide a clear slotted label that describes what the switch controls.
|
|
66
|
+
- **Do** use `hide-label` only when the label text remains in the slot for screen readers.
|
|
67
|
+
- **Don't** use an icon or visual state alone without descriptive label text.
|
|
68
|
+
|
|
69
|
+
## API
|
|
70
|
+
|
|
71
|
+
### Properties
|
|
72
|
+
|
|
73
|
+
| Property | Type | Default | Description |
|
|
74
|
+
| --- | --- | --- | --- |
|
|
75
|
+
| `alignLabel` | `'start'` `'end'`<br>`BreakpointCustomizable<SwitchAlignLabel>` | `'end'` | Sets the position of the slotted label relative to the switch toggle, either before (`start`) or after (`end`) it. Supports responsive breakpoint values. |
|
|
76
|
+
| `checked` | `boolean` | `false` | Reflects the switch's current on/off state and allows setting the initial checked value when the component first renders. |
|
|
77
|
+
| `compact` | `boolean` | `false` | Reduces the switch size and spacing for use in dense layouts where vertical space is limited. |
|
|
78
|
+
| `disabled` | `boolean` | `false` | Prevents user interaction with the switch and blocks all click and keyboard events while it is disabled. |
|
|
79
|
+
| `hideLabel` | `boolean`<br>`BreakpointCustomizable<boolean>` | `false` | Hides the visible label while keeping it accessible to screen readers. Supports responsive breakpoint values. |
|
|
80
|
+
| `loading` | `boolean` | `false` | Disables the switch and shows a loading spinner to indicate an ongoing asynchronous toggle operation. |
|
|
81
|
+
| `stretch` | `boolean`<br>`BreakpointCustomizable<boolean>` | `false` | Expands the space between the switch toggle and its label to fill the full available width of the container. Supports responsive breakpoint values. |
|
|
82
|
+
|
|
83
|
+
### Events
|
|
84
|
+
|
|
85
|
+
| Event | Type | Description |
|
|
86
|
+
| --- | --- | --- |
|
|
87
|
+
| `update` | `CustomEvent<SwitchUpdateEventDetail>`<br>`{ checked: boolean }` | Emitted when the user toggles the switch, carrying the new `checked` state in the event detail. |
|
|
88
|
+
|
|
89
|
+
### Controlled properties
|
|
90
|
+
|
|
91
|
+
- `checked` — a controlled prop: the component does **not** update it itself. Handle the `update` event and assign the new value to `checked` yourself, or the change will not take effect.
|
|
92
|
+
|
|
93
|
+
### Slots
|
|
94
|
+
|
|
95
|
+
| Slot | Required | Allowed tag names | Description |
|
|
96
|
+
| --- | --- | --- | --- |
|
|
97
|
+
| _(default)_ | no | — | Default slot for the label. |
|
|
98
|
+
|
|
99
|
+
## Examples
|
|
100
|
+
|
|
101
|
+
| Example | When to use | File |
|
|
102
|
+
| --- | --- | --- |
|
|
103
|
+
| Default | Minimal default configuration. | [./examples/Default.tsx](./examples/Default.tsx) |
|