From 58910452df178371fd52b944cc515dcd0b73fb7d Mon Sep 17 00:00:00 2001 From: Maria Hutt Date: Tue, 24 Nov 2026 15:23:57 -0800 Subject: [PATCH 1/4] feat(tabs): share one framework switcher and tab style across the site --- .../global/FrameworkSwitcher/index.tsx | 109 ++++++++++ .../FrameworkSwitcher/styles.module.css | 3 + src/components/global/FrameworkTabs/index.tsx | 102 +++++++++ .../global/FrameworkTabs/styles.module.css | 18 ++ src/components/global/Playground/index.tsx | 205 +++++------------- .../global/Playground/playground.css | 77 ++----- src/components/global/ToggleButton/index.tsx | 56 +++++ .../global/ToggleButton/styles.module.scss | 14 ++ src/css/_mixins.scss | 63 ++++++ src/css/theme/Tabs.scss | 50 ++--- src/utils/frameworks.ts | 50 ++++- 11 files changed, 490 insertions(+), 257 deletions(-) create mode 100644 src/components/global/FrameworkSwitcher/index.tsx create mode 100644 src/components/global/FrameworkSwitcher/styles.module.css create mode 100644 src/components/global/FrameworkTabs/index.tsx create mode 100644 src/components/global/FrameworkTabs/styles.module.css create mode 100644 src/components/global/ToggleButton/index.tsx create mode 100644 src/components/global/ToggleButton/styles.module.scss diff --git a/src/components/global/FrameworkSwitcher/index.tsx b/src/components/global/FrameworkSwitcher/index.tsx new file mode 100644 index 00000000000..961a90b2d28 --- /dev/null +++ b/src/components/global/FrameworkSwitcher/index.tsx @@ -0,0 +1,109 @@ +/** + * The row of framework buttons that framework tabs and playgrounds show above + * their code. + * + * It is a tab list: the arrow keys move between frameworks, skipping disabled + * ones, and Enter or a click selects one. Selecting a framework can change the + * length of content above the switcher, so the switcher is kept where it was on + * screen to stop the page from jumping. + */ + +import React, { useRef, type KeyboardEvent } from 'react'; +import clsx from 'clsx'; + +import ToggleButton from '../ToggleButton'; + +import styles from './styles.module.css'; + +export interface FrameworkOption { + value: string; + label: string; + /** Shown but not selectable, such as a framework a playground has no code for. */ + disabled?: boolean; + /** The id of this option's tab, for its panel's `aria-labelledby`. */ + tabId?: string; + /** The id of the panel this option shows, for `aria-controls`. */ + panelId?: string; +} + +interface Props { + options: readonly FrameworkOption[]; + selected: string; + onSelect: (value: string) => void; + className?: string; +} + +/** + * Runs `update`, then scrolls by however far `element` moved, so it stays at + * the same place on screen. + */ +function keepInPlace(element: HTMLElement | null, update: () => void) { + const top = element?.getBoundingClientRect().top; + update(); + + if (element && top !== undefined) { + requestAnimationFrame(() => { + window.scrollBy({ top: element.getBoundingClientRect().top - top, behavior: 'instant' }); + }); + } +} + +export default function FrameworkSwitcher({ options, selected, onSelect, className }: Props) { + const buttons = useRef<(HTMLButtonElement | null)[]>([]); + + // One tab must be reachable with the Tab key, even if none is selected. + const focusable = options.some((option) => option.value === selected) + ? selected + : options.find((option) => !option.disabled)?.value; + + const select = (index: number) => { + const { value } = options[index]; + + if (value !== selected) { + keepInPlace(buttons.current[index], () => onSelect(value)); + } + }; + + const handleKeyDown = (event: KeyboardEvent, index: number) => { + const step = event.key === 'ArrowRight' ? 1 : event.key === 'ArrowLeft' ? -1 : 0; + + if (step === 0) { + return; + } + + event.preventDefault(); + + for (let offset = 1; offset < options.length; offset++) { + const next = (index + step * offset + options.length) % options.length; + + if (!options[next].disabled) { + buttons.current[next]?.focus(); + return; + } + } + }; + + return ( +
+ {options.map((option, index) => ( + { + buttons.current[index] = button; + }} + role="tab" + id={option.tabId} + aria-controls={option.panelId} + aria-selected={option.value === selected} + tabIndex={option.value === focusable ? 0 : -1} + label={option.label} + title={`Show ${option.label} code`} + selected={option.value === selected} + disabled={option.disabled} + onClick={() => select(index)} + onKeyDown={(event) => handleKeyDown(event, index)} + /> + ))} +
+ ); +} diff --git a/src/components/global/FrameworkSwitcher/styles.module.css b/src/components/global/FrameworkSwitcher/styles.module.css new file mode 100644 index 00000000000..950d6d7df95 --- /dev/null +++ b/src/components/global/FrameworkSwitcher/styles.module.css @@ -0,0 +1,3 @@ +.switcher { + display: flex; +} diff --git a/src/components/global/FrameworkTabs/index.tsx b/src/components/global/FrameworkTabs/index.tsx new file mode 100644 index 00000000000..b35d824a2cd --- /dev/null +++ b/src/components/global/FrameworkTabs/index.tsx @@ -0,0 +1,102 @@ +/** + * Tabs that show a sample once per framework, kept in sync with every other + * framework tab and playground on the site. + * + * Each `` only needs its `value`. The label comes from the shared + * framework list, and the tabs are sorted alphabetically by label, so every page + * names and orders the frameworks the same way. A tab for something outside + * that list, such as Stencil, needs its own `label`. + * + * ```mdx + * + * … + * … + * + * ``` + * + * The tabs are the same buttons playgrounds show. `` only carries each + * tab's value, label, and content: Docusaurus's `TabItem` reads the context of + * its own ``, so it is never rendered here. + */ + +import React, { Children, isValidElement, useId, type ReactElement, type ReactNode } from 'react'; +import clsx from 'clsx'; +import type { Props as TabItemProps } from '@theme/TabItem'; +import { FRAMEWORKS, useFrameworkChoice } from '@site/src/utils/frameworks'; + +import FrameworkSwitcher from '../FrameworkSwitcher'; + +import styles from './styles.module.css'; + +interface Props { + children: ReactNode; + /** The tab to show until the reader picks a framework. Defaults to the first tab. */ + defaultValue?: string; + className?: string; +} + +export default function FrameworkTabs({ children, defaultValue, className }: Props): ReactNode { + const id = useId(); + + const tabs = Children.toArray(children) + .filter((child): child is ReactElement => isValidElement(child)) + .map((item) => { + const { value, label } = item.props; + const frameworkLabel = FRAMEWORKS.find((framework) => framework.value === value)?.label; + + if (!frameworkLabel && !label) { + throw new Error( + ` has a , which is not a framework from src/utils/frameworks.ts. Give it a label.` + ); + } + + return { + value, + label: frameworkLabel ?? label!, + content: item.props.children, + tabId: `${id}-tab-${value}`, + panelId: `${id}-panel-${value}`, + }; + }) + .sort((a, b) => a.label.localeCompare(b.label)); + + const values = tabs.map((tab) => tab.value); + const duplicate = values.find((value, index) => values.indexOf(value) !== index); + + if (duplicate) { + throw new Error(` has more than one .`); + } + + if (defaultValue !== undefined && !values.includes(defaultValue)) { + throw new Error( + ` has defaultValue="${defaultValue}", but no with that value. Available values are: ${values.join(', ')}.` + ); + } + + const { selected, select } = useFrameworkChoice(values); + const shown = selected ?? defaultValue ?? values[0]; + + return ( +
+
+ +
+ {tabs.map((tab) => ( + /** + * Every panel is rendered, and the hidden ones are only hidden, so search + * engines and the browser's find can still reach their content. + */ + + ))} +
+ ); +} diff --git a/src/components/global/FrameworkTabs/styles.module.css b/src/components/global/FrameworkTabs/styles.module.css new file mode 100644 index 00000000000..252700e7fd7 --- /dev/null +++ b/src/components/global/FrameworkTabs/styles.module.css @@ -0,0 +1,18 @@ +/* Matches the spacing of Docusaurus's tabs. */ +.container { + margin-bottom: var(--ifm-leading); +} + +/* Scrolls sideways on narrow screens, as the playground toolbar does. */ +.switcher { + overflow-x: auto; +} + +/* Matches the gap between Docusaurus's tabs and their panels in `src/css/theme/Tabs.scss`. */ +.panel { + margin-top: 0.75rem; +} + +.panel > :last-child { + margin-bottom: 0; +} diff --git a/src/components/global/Playground/index.tsx b/src/components/global/Playground/index.tsx index 72420678b81..763f854a101 100644 --- a/src/components/global/Playground/index.tsx +++ b/src/components/global/Playground/index.tsx @@ -1,101 +1,43 @@ -import React, { - ForwardedRef, - type ReactElement, - type ReactNode, - forwardRef, - useEffect, - useMemo, - useRef, - useState, -} from 'react'; +/** + * The interactive example on a component page: a live demo above the code that + * builds it, for each framework. + * + * The toolbar switches the framework, shared with the docs' framework tabs, and + * the iOS or MD mode, kept in sync with every playground on the page. It also + * opens the example in StackBlitz, copies the code, resets the demo, and links + * to a new issue. + * + * The demo is the example's `demo.html`, loaded once per mode in two iframes so + * switching modes doesn't reload it. The iframes only load once the playground + * scrolls into view, and receive the site's dark mode as a message. The console, + * when shown, lists what the demo logs. + * + * The code is the rendered MDX for the selected framework, with a tab per file + * for a multi-file example. StackBlitz gets the code from those rendered blocks. + * + * For the props and how to write a playground, refer to the README. + */ + +import React, { type ReactElement, type ReactNode, useEffect, useRef, useState } from 'react'; import Link from '@docusaurus/Link'; import useBaseUrl from '@docusaurus/useBaseUrl'; import './playground.css'; import { EditorOptions, openAngularEditor, openHtmlEditor, openReactEditor, openVueEditor } from './stackblitz.utils'; -import { useColorMode, useStorageSlot } from '@docusaurus/theme-common'; +import { useColorMode } from '@docusaurus/theme-common'; import { CodeSnippets, ConsoleItem, Mode, UsageTarget } from './playground.types'; -import { type Framework, FRAMEWORK_GROUP_ID, getFrameworkLabel } from '@site/src/utils/frameworks'; +import { FRAMEWORKS, useFrameworkChoice } from '@site/src/utils/frameworks'; import Tooltip from '../Tooltip'; +import ToggleButton from '../ToggleButton'; +import FrameworkSwitcher from '../FrameworkSwitcher'; import PlaygroundTabs from '../PlaygroundTabs'; import TabItem from '../PlaygroundTabs/TabItem'; import { IconHtml, IconTs, IconVue, IconDefault, IconCss, IconDots } from './icons'; -import { useScrollPositionBlocker } from '@docusaurus/theme-common/internal'; import useIsBrowser from '@docusaurus/useIsBrowser'; -const ControlButton = forwardRef( - ( - { - isSelected, - handleClick, - title, - label, - disabled, - }: { - isSelected: boolean; - handleClick: () => void; - title: string; - label: string; - disabled?: boolean; - }, - ref: ForwardedRef - ) => { - const controlButton = ( - - ); - if (disabled) { - return ( - - {/* Disabled elements do not emit pointer events, so the wrapper is what triggers the tooltip. */} -
{controlButton}
-
- ); - } - return controlButton; - } -); - -const CodeBlockButton = ({ - language, - usageTarget, - setAndSaveUsageTarget, - disabled, -}: { - language: keyof typeof UsageTarget; - usageTarget: UsageTarget; - setAndSaveUsageTarget: (target: UsageTarget, tab: HTMLElement | null) => void; - disabled: boolean; -}) => { - const buttonRef = useRef(null); - const langValue = UsageTarget[language]; - const label = getFrameworkLabel(langValue); - - return ( - { - setAndSaveUsageTarget(langValue, buttonRef.current); - }} - title={`Show ${label} code`} - label={label} - disabled={disabled} - ref={buttonRef} - /> - ); -}; - type MdxContent = () => ReactNode; /** @@ -237,8 +179,6 @@ export default function Playground({ const frameMD = useRef(null); const consoleBodyRef = useRef(null); - const { blockElementScrollPositionUntilNextRender } = useScrollPositionBlocker(); - const getDefaultMode = () => { /** * If a custom mode was specified, use that. @@ -261,26 +201,17 @@ export default function Playground({ }; /** - * The framework is shared with the docs' framework tabs, which store the - * reader's choice under the same key. Picking a framework in either one - * updates the other, and the choice is kept across page loads. + * The framework is shared with the docs' framework tabs. Picking a framework + * in either one updates the other, and the choice is kept across page loads. */ - const [storedFramework, frameworkStorage] = useStorageSlot(FRAMEWORK_STORAGE_KEY); + const { selected: pickedFramework, select: selectFramework } = useFrameworkChoice(Object.keys(code)); const getUsageTarget = (): UsageTarget => { - /** - * The docs tabs have an Angular (Standalone) tab, which the playground - * shows as Angular. - */ - const storedTarget = ( - storedFramework === ANGULAR_STANDALONE_TAB ? UsageTarget.Angular : storedFramework - ) as UsageTarget | null; - /** * If the reader has picked a framework and there is code for it, use that. */ - if (storedTarget && code[storedTarget] !== undefined) { - return storedTarget; + if (pickedFramework) { + return pickedFramework as UsageTarget; } /** @@ -349,30 +280,6 @@ export default function Playground({ } }; - const setAndSaveUsageTarget = (target: UsageTarget, tab: HTMLElement | null) => { - /** - * This prevents the scroll position from jumping around if - * there is a playground or tabs above this one with code that - * changes in length between frameworks. - * - * Note that we don't need this when changing the mode because - * the two mode iframes are always the same height. - */ - if (tab) { - blockElementScrollPositionUntilNextRender(tab); - } - - /** - * Angular (Standalone) in the docs tabs already shows Angular here, - * so keep it rather than switching those tabs to Angular. - */ - if (target === UsageTarget.Angular && storedFramework === ANGULAR_STANDALONE_TAB) { - return; - } - - frameworkStorage.set(target); - }; - /** * Rather than encode isDarkTheme into the frame source * url, we post a message to each frame so that @@ -746,43 +653,38 @@ export default function Playground({ ); } - const sortedUsageTargets = useMemo(() => (Object.keys(UsageTarget) as (keyof typeof UsageTarget)[]).sort(), []); + /** + * Every framework a playground supports, in the shared order. One without + * code is shown disabled. + */ + const usageTargets: readonly string[] = Object.values(UsageTarget); + const frameworkOptions = FRAMEWORKS.filter((framework) => usageTargets.includes(framework.value)).map( + (framework) => ({ + value: framework.value, + label: framework.label, + disabled: code[framework.value as UsageTarget] === undefined, + }) + ); return (
- {sortedUsageTargets.map((lang) => { - /** - * If code was not passed for this target - * then we should disable the button. - */ - const langValue = UsageTarget[lang]; - const hasCode = code[langValue] !== undefined; - return ( - - ); - })} +
- setAndSaveMode(Mode.iOS)} + setAndSaveMode(Mode.iOS)} title="iOS mode" label="iOS" /> - setAndSaveMode(Mode.MD)} + setAndSaveMode(Mode.MD)} title="MD mode" label="MD" /> @@ -985,10 +887,5 @@ const isFrameReady = (frame: HTMLIFrameElement | null) => { return (frame.contentWindow as any).demoReady === true; }; -/** - * The key Docusaurus stores the selected tab under for the docs' framework tabs. - */ -const FRAMEWORK_STORAGE_KEY = `docusaurus.tab.${FRAMEWORK_GROUP_ID}`; -const ANGULAR_STANDALONE_TAB: Framework = 'angular-standalone'; const MODE_STORAGE_KEY = 'playground_mode'; const MODE_UPDATED_EVENT = 'playground-event-updated'; diff --git a/src/components/global/Playground/playground.css b/src/components/global/Playground/playground.css index 1a29ce6c356..8e8b6c3c132 100644 --- a/src/components/global/Playground/playground.css +++ b/src/components/global/Playground/playground.css @@ -1,9 +1,5 @@ /* Dark theme overrides */ [data-theme="dark"] .playground { - --playground-btn-color: var(--c-carbon-20); - --playground-btn-selected-color: #fff; - --playground-btn-selected-background: var(--c-carbon-70); - --playground-btn-icon-color: var(--c-carbon-20); --playground-btn-icon-hover-background: rgba(67, 79, 93, 0.5); @@ -26,9 +22,6 @@ .playground { /** - * @prop --playground-btn-color The text color of the button in the toolbar. - * @prop --playground-btn-selected-color The text color of the button in the toolbar when selected. - * @prop --playground-btn-selected-background The background color of the button in the toolbar when selected. * @prop --playground-btn-icon-color The text color of the button icon in the toolbar. * @prop --playground-btn-icon-hover-background The background color of the button icon in the toolbar when hovered. * @prop --playground-separator-color The color of the separator/border in the toolbar. @@ -44,9 +37,6 @@ * @prop --playground-console-error-color The text color of error items in the console UI. * @prop --playground-console-error-separator-color The color of the top and bottom separator/border for error items in the console UI. */ - --playground-btn-color: var(--c-indigo-90); - --playground-btn-selected-color: var(--c-blue-90); - --playground-btn-selected-background: var(--c-blue-10); --playground-btn-icon-hover-background: var(--c-indigo-20); --playground-btn-icon-color: var(--c-indigo-80); --playground-separator-color: var(--c-indigo-30); @@ -121,7 +111,7 @@ border-left: 1px solid var(--playground-separator-color); } -.playground__control-group .playground__control-button:last-child { +.playground__control-group:not(.playground__control-group--end) > :last-child { margin-right: 12px; } @@ -131,55 +121,6 @@ gap: 4px; } -.playground__control-button { - display: inline-flex; - flex-direction: column; - justify-content: center; - align-items: center; - padding: 6px 10px; - - color: var(--playground-btn-color); - background-color: transparent; - border: none; - border-radius: 100px; - - font-size: 12px; - - appearance: none; - cursor: pointer; - transition: background-color .2s, color .2s; -} - -.playground__control-button:disabled { - opacity: 0.4; - cursor: not-allowed; -} - -/* fix layout shifting when button is bolded on select */ -/* has the same text as the button, but bolded in advance to nudge the width */ -.playground__control-button::after { - content: attr(data-text); - font-weight: 500; - overflow: hidden; - pointer-events: none; - user-select: none; - visibility: hidden; - - height: 0; -} - -@media speech { - .playground__control-button::after { - display: none; - } -} - -.playground__control-button--selected { - background-color: var(--playground-btn-selected-background); - color: var(--playground-btn-selected-color); - font-weight: 500; -} - /* Icon buttons at the end of the toolbar */ .playground__icon-button { @@ -331,8 +272,6 @@ .playground .tabs { background: var(--playground-tabs-background); - --ifm-tabs-spacing: 0; - /** * This fixes an issue in WebKit that causes the * border radius to not be respected when hovering @@ -352,11 +291,25 @@ .playground .tabs__item { color: var(--playground-tab-btn-color); font-size: 12px; + font-weight: 400; + line-height: 100%; + letter-spacing: 0; display: inline-flex; align-items: center; + border: 1px solid transparent; border-radius: 0; + padding-block-start: calc(var(--ifm-tabs-padding-vertical) - 1px); white-space: nowrap; height: 40px; + transition: border-color 0.2s ease-out, opacity 0.2s ease-out; +} + +.playground .tabs__item:hover { + background-color: inherit; +} + +.playground .tabs__item:hover:not(.tabs__item--active) { + opacity: 0.7; } .playground .tabs__item:last-child { diff --git a/src/components/global/ToggleButton/index.tsx b/src/components/global/ToggleButton/index.tsx new file mode 100644 index 00000000000..0bf48786ce9 --- /dev/null +++ b/src/components/global/ToggleButton/index.tsx @@ -0,0 +1,56 @@ +/** + * A pill button that shows whether it is selected. + * + * Framework switchers and the playground's mode buttons use it, so every + * selectable option on the site looks the same. A disabled button shows an + * "Unavailable for" tooltip. + * + * Only playgrounds disable a button, so the tooltip is loaded when one is shown. + * Importing it directly would add its positioning library to every page with + * ``, which never shows it. + */ + +import React, { forwardRef, lazy, Suspense, type ButtonHTMLAttributes } from 'react'; +import clsx from 'clsx'; + +import styles from './styles.module.scss'; + +const Tooltip = lazy(() => import('../Tooltip')); + +interface Props extends Omit, 'children'> { + label: string; + selected: boolean; +} + +const ToggleButton = forwardRef( + ({ label, selected, disabled, title, className, ...rest }, ref) => { + const button = ( + + ); + + if (!disabled) { + return button; + } + + // Disabled elements do not emit pointer events, so the wrapper is what triggers the tooltip. + const wrapper =
{button}
; + + return ( + + {wrapper} + + ); + } +); + +export default ToggleButton; diff --git a/src/components/global/ToggleButton/styles.module.scss b/src/components/global/ToggleButton/styles.module.scss new file mode 100644 index 00000000000..026aa2cb78b --- /dev/null +++ b/src/components/global/ToggleButton/styles.module.scss @@ -0,0 +1,14 @@ +@use '../../../css/mixins'; + +.button { + @include mixins.toggle-button(':global(html[data-theme="dark"])'); +} + +.button:disabled { + opacity: 0.4; + cursor: not-allowed; +} + +.selected { + @include mixins.toggle-button-selected; +} diff --git a/src/css/_mixins.scss b/src/css/_mixins.scss index 5204167dec2..3a6877b0d3a 100644 --- a/src/css/_mixins.scss +++ b/src/css/_mixins.scss @@ -17,3 +17,66 @@ mask-size: 100% 100%; mask-repeat: no-repeat; } + +/// The pill shared by every tab and toggle button on the site: Docusaurus tabs, +/// framework tabs and playground switchers, and the playground's mode buttons. +/// Add `toggle-button-selected` to the selected one. +/// +/// `$dark` selects dark mode. A `.module.scss` has to pass it wrapped in +/// `:global()`, or CSS modules would rename it. +@mixin toggle-button($dark: "html[data-theme='dark']") { + --toggle-button-color: var(--c-indigo-90); + --toggle-button-selected-color: var(--c-blue-90); + --toggle-button-selected-background: var(--c-blue-10); + + display: inline-flex; + flex-direction: column; + justify-content: center; + align-items: center; + padding: 6px 10px; + + color: var(--toggle-button-color); + background-color: transparent; + border: none; + border-radius: 100px; + + font-family: inherit; + font-size: 12px; + font-weight: 400; + line-height: normal; + + appearance: none; + cursor: pointer; + transition: background-color 0.2s, color 0.2s; + + #{$dark} & { + --toggle-button-color: var(--c-carbon-20); + --toggle-button-selected-color: #fff; + --toggle-button-selected-background: var(--c-carbon-70); + } + + // Reserves the width of the bold selected label, so selecting one doesn't + // shift the ones after it. Reads the label from a `data-text` attribute. + &::after { + content: attr(data-text); + font-weight: 500; + overflow: hidden; + pointer-events: none; + user-select: none; + visibility: hidden; + + height: 0; + } + + @media speech { + &::after { + display: none; + } + } +} + +@mixin toggle-button-selected { + background-color: var(--toggle-button-selected-background); + color: var(--toggle-button-selected-color); + font-weight: 500; +} diff --git a/src/css/theme/Tabs.scss b/src/css/theme/Tabs.scss index 87129063643..8cdd5521e99 100644 --- a/src/css/theme/Tabs.scss +++ b/src/css/theme/Tabs.scss @@ -1,53 +1,35 @@ +@use '../mixins'; + html[data-theme='light'] { --ifm-tabs-color: var(--c-indigo-90); --ifm-tabs-color-active: var(--c-carbon-100); - --tabs-border-c: var(--c-indigo-40); } html[data-theme='dark'] { --ifm-tabs-color: #fff; --ifm-tabs-color-active: #fff; - --tabs-border-c: #fff; } :root { --ifm-tabs-padding-horizontal: 0.5rem; --ifm-tabs-padding-vertical: 0.625rem; - - --ifm-tabs-spacing: 0.5rem; } -.tabs { - .tabs__item { - font-weight: 400; - font-size: 0.75rem; - line-height: 100%; - letter-spacing: 0; - - border-radius: 1000px; - border: 1px solid rgba(0, 0, 0, 0); - - padding-block-start: calc(var(--ifm-tabs-padding-vertical) - 1px); - - transition: border-color 0.2s ease-out, opacity 0.2s ease-out; - - &--active { - font-weight: 500; - - border-color: var(--tabs-border-c); - } - - + .tabs__item { - margin-inline-start: var(--ifm-tabs-spacing); - } - - &:hover { - background-color: inherit; - } +/* + * Every tab looks like the playground's toggle buttons, so a page's tabs and + * its playgrounds match. The playground's file tabs keep their own look, + * refer to `Playground/playground.css`. + */ +.tabs:not(.playground__tabs) .tabs__item { + @include mixins.toggle-button; + + // Replaces Infima's hover background, which would cover the selected one. + &:hover { + background-color: transparent; + } - &:hover:not(.tabs__item--active) { - opacity: 0.7; - } + &.tabs__item--active { + @include mixins.toggle-button-selected; } } diff --git a/src/utils/frameworks.ts b/src/utils/frameworks.ts index 8f0838259a6..7e49c132365 100644 --- a/src/utils/frameworks.ts +++ b/src/utils/frameworks.ts @@ -1,13 +1,12 @@ /** * The frameworks a reader can pick in the docs' framework tabs and in playgrounds. * - * Both store the pick under the same Docusaurus tab group, so choosing a framework - * in one selects it in the other. Import the values and labels from here rather - * than writing them out, so the two can't drift apart. + * Both store the pick in the same place, so choosing a framework in one selects + * it in the other. Import the values and labels from here rather than writing + * them out, so the two can't drift apart. */ -/** The `groupId` of the docs' framework tabs. */ -export const FRAMEWORK_GROUP_ID = 'framework'; +import { useStorageSlot } from '@docusaurus/theme-common'; /** Every framework value, with its label, sorted alphabetically by label as the tabs show them. */ export const FRAMEWORKS = [ @@ -20,6 +19,43 @@ export const FRAMEWORKS = [ export type Framework = (typeof FRAMEWORKS)[number]['value']; -export function getFrameworkLabel(framework: Framework): string { - return FRAMEWORKS.find((item) => item.value === framework)!.label; +const ANGULAR: Framework = 'angular'; +const ANGULAR_STANDALONE: Framework = 'angular-standalone'; + +/** + * The key Docusaurus stores `` under. A translation's + * pages still use those tabs, so keeping the key keeps them in sync too. + */ +const STORAGE_KEY = 'docusaurus.tab.framework'; + +/** + * The reader's framework pick, limited to the frameworks a tab group or + * playground has. + * + * `selected` is undefined when the reader hasn't picked one of `available`, so + * the caller can fall back to its own default. A pick of Angular (Standalone) + * shows as Angular where there is no Standalone tab. + */ +export function useFrameworkChoice(available: readonly string[]) { + const [stored, storage] = useStorageSlot(STORAGE_KEY); + + let selected: string | undefined; + if (stored && available.includes(stored)) { + selected = stored; + } else if (stored === ANGULAR_STANDALONE && available.includes(ANGULAR)) { + selected = ANGULAR; + } + + const select = (framework: string) => { + /** + * Picking Angular where there is no Standalone tab keeps a Standalone + * pick, which already shows as Angular here. + */ + if (framework === ANGULAR && stored === ANGULAR_STANDALONE && !available.includes(ANGULAR_STANDALONE)) { + return; + } + storage.set(framework); + }; + + return { selected, select }; } From b29319819ea065f488ee0573850a8116256a98c4 Mon Sep 17 00:00:00 2001 From: Maria Hutt Date: Tue, 24 Nov 2026 15:23:57 -0800 Subject: [PATCH 2/4] docs: use FrameworkTabs for every framework tab group --- docs/angular/platform.mdx | 24 +++------- docs/angular/slides.mdx | 13 ++---- docs/api/action-sheet.mdx | 10 ++--- docs/api/alert.mdx | 10 ++--- docs/api/item.mdx | 6 +-- docs/api/route.mdx | 8 ++-- docs/api/tab-bar.mdx | 6 +-- docs/api/tab-button.mdx | 6 +-- docs/api/toast.mdx | 6 +-- docs/developing/config.mdx | 24 +++------- docs/developing/config/_global.mdx | 16 ++----- docs/developing/config/_per-component.mdx | 16 ++----- .../config/_per-platform-fallback.mdx | 15 ++----- .../config/_per-platform-overrides.mdx | 15 ++----- docs/developing/config/_per-platform.mdx | 15 ++----- docs/developing/hardware-back-button.mdx | 44 +++---------------- docs/developing/keyboard.mdx | 16 ++----- docs/developing/managing-focus.mdx | 27 +++--------- docs/native-setup.mdx | 15 ++----- docs/techniques/security.mdx | 15 ++----- docs/theming/dark-mode.mdx | 13 +++--- docs/theming/high-contrast-mode.mdx | 13 +++--- docs/utilities/animations.mdx | 19 ++------ docs/utilities/gestures.mdx | 18 ++------ .../version-v8/angular/platform.mdx | 13 ++---- versioned_docs/version-v8/angular/slides.mdx | 13 ++---- .../version-v8/api/action-sheet.mdx | 10 ++--- versioned_docs/version-v8/api/alert.mdx | 10 ++--- versioned_docs/version-v8/api/route.mdx | 8 ++-- versioned_docs/version-v8/api/tab-bar.mdx | 6 +-- versioned_docs/version-v8/api/tab-button.mdx | 6 +-- versioned_docs/version-v8/api/toast.mdx | 6 +-- .../version-v8/developing/config.mdx | 24 +++------- .../version-v8/developing/config/_global.mdx | 16 ++----- .../developing/config/_per-component.mdx | 16 ++----- .../config/_per-platform-fallback.mdx | 15 ++----- .../config/_per-platform-overrides.mdx | 15 ++----- .../developing/config/_per-platform.mdx | 15 ++----- .../developing/hardware-back-button.mdx | 44 +++---------------- .../version-v8/developing/keyboard.mdx | 16 ++----- .../version-v8/developing/managing-focus.mdx | 27 +++--------- versioned_docs/version-v8/native-setup.mdx | 15 ++----- .../version-v8/techniques/security.mdx | 15 ++----- .../version-v8/theming/dark-mode.mdx | 13 +++--- .../version-v8/theming/high-contrast-mode.mdx | 13 +++--- .../version-v8/utilities/animations.mdx | 19 ++------ .../version-v8/utilities/gestures.mdx | 18 ++------ 47 files changed, 189 insertions(+), 534 deletions(-) diff --git a/docs/angular/platform.mdx b/docs/angular/platform.mdx index 3869df3e0ca..def2f8e205c 100644 --- a/docs/angular/platform.mdx +++ b/docs/angular/platform.mdx @@ -3,7 +3,7 @@ title: Platform description: 'Ionic Platform service can be used to get information about your current device. With this information you can completely customize your app to fit any device.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; @@ -14,14 +14,7 @@ The Platform service can be used to get information about your current device. Y ## Usage {/* #usage */} - + ```tsx @@ -50,7 +43,7 @@ export class MyPage { ``` - +
## Methods {/* #methods */} @@ -92,14 +85,7 @@ Below is a table listing all the possible platform values along with correspondi The function used to detect a specific platform can be overridden by providing an alternative function in the global [Ionic config](../developing/config.mdx). Each function takes `window` as a parameter and returns a boolean. - + ```tsx title="app.module.ts" @@ -155,7 +141,7 @@ bootstrapApplication(AppComponent, { ``` - + ```ts type PlatformConfig = { diff --git a/docs/angular/slides.mdx b/docs/angular/slides.mdx index 4d54aa0fc70..3f9c5bf0e92 100644 --- a/docs/angular/slides.mdx +++ b/docs/angular/slides.mdx @@ -3,7 +3,7 @@ title: Migrating from ion-slides to Swiper.js description: 'Read this guide to learn how to get Swiper.js for Angular set up in your Ionic Framework application for a modern touch slider component.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; @@ -141,14 +141,7 @@ It is recommended to review the [properties](https://github.com/ionic-team/ionic We can install the `IonicSlides` module by importing and passing it to the `modules` property of `swiper-container` as an array: - + ```typescript @@ -181,7 +174,7 @@ export class HomePage { ``` - + ```html diff --git a/docs/api/action-sheet.mdx b/docs/api/action-sheet.mdx index 49d68d2a442..b19c9bb3756 100644 --- a/docs/api/action-sheet.mdx +++ b/docs/api/action-sheet.mdx @@ -3,7 +3,7 @@ title: 'ion-action-sheet' description: 'Action Sheets are dialogs that display a set of options above app content and must be manually dismissed. Read to learn about use on iOS and Android devices.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; import Props from '@ionic-internal/component-api/v9/action-sheet/props.mdx'; @@ -109,7 +109,7 @@ Action Sheets are given a `role` of [`dialog`](https://developer.mozilla.org/en- It is strongly recommended that every Action Sheet have the `header` property defined, as Ionic will automatically set `aria-labelledby` to point to the header element. However, if you choose not to include a `header`, an alternative is to use the `htmlAttributes` property to provide a descriptive `aria-label` or set a custom `aria-labelledby` value. - + @@ -159,13 +159,13 @@ const actionSheet = await actionSheetController.create({ - + #### Action Sheet Buttons Description {/* #action-sheet-buttons-description */} Buttons containing text will be read by a screen reader. If a button contains only an icon, or a description other than the existing text is desired, a label should be assigned to the button by passing `aria-label` to the `htmlAttributes` property on the button. - + @@ -239,7 +239,7 @@ const actionSheet = await actionSheetController.create({ - + ## Interfaces {/* #interfaces */} diff --git a/docs/api/alert.mdx b/docs/api/alert.mdx index 7c458960d5d..af7163b42eb 100644 --- a/docs/api/alert.mdx +++ b/docs/api/alert.mdx @@ -3,7 +3,7 @@ title: 'ion-alert' description: "ion-alert dialog presents or collects information using inputs. Custom alert button messages appear above the app's content and must be manually dismissed." --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; import Props from '@ionic-internal/component-api/v9/alert/props.mdx'; @@ -127,7 +127,7 @@ If the `header` property is defined for the Alert, the `aria-labelledby` attribu It is strongly recommended that your Alert have a `message`, as well as either a `header` or `subHeader`, in order to align with the ARIA spec. If you choose not to include a `header` or `subHeader`, an alternative is to provide a descriptive `aria-label` using the `htmlAttributes` property. - + @@ -181,7 +181,7 @@ const alert = await alertController.create({ - + All ARIA attributes can be manually overwritten by defining custom values in the `htmlAttributes` property of the Alert. @@ -189,7 +189,7 @@ All ARIA attributes can be manually overwritten by defining custom values in the Buttons containing text will be read by a screen reader. If a description other than the existing text is desired, a label can be set on the button by passing `aria-label` to the `htmlAttributes` property on the button. - + @@ -263,7 +263,7 @@ const alert = await alertController.create({ - + ## Interfaces {/* #interfaces */} diff --git a/docs/api/item.mdx b/docs/api/item.mdx index 30f1b239ad7..9f0b26fba28 100644 --- a/docs/api/item.mdx +++ b/docs/api/item.mdx @@ -13,7 +13,7 @@ import Slots from '@ionic-internal/component-api/v9/item/slots.mdx'; import Link from '@docusaurus/Link'; import useBaseUrl from '@docusaurus/useBaseUrl'; import BestPracticeFigure from '@components/global/BestPracticeFigure'; -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; @@ -286,7 +286,7 @@ import Clickable from '@site/static/usage/v9/item/clickable/index.mdx'; Items support client-side navigation using the `routerLink` property. Setting `routerLink` renders the item as an anchor and navigates to the specified route when tapped. The `routerDirection` property controls the transition animation direction, and `routerAnimation` accepts a custom animation builder. - + @@ -382,7 +382,7 @@ import { IonItem, IonLabel, IonList } from '@ionic/vue'; - + ## Detail Arrows {/* #detail-arrows */} diff --git a/docs/api/route.mdx b/docs/api/route.mdx index 32218db1631..38cf4008866 100644 --- a/docs/api/route.mdx +++ b/docs/api/route.mdx @@ -3,7 +3,7 @@ title: 'ion-route' description: 'The ion-route component takes a component and renders it when the Browser URL matches the URL property. Learn more about the API route component for Ionic Apps.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; import Props from '@ionic-internal/component-api/v9/route/props.mdx'; @@ -44,7 +44,7 @@ interface NavigationHookOptions { ## Usage {/* #usage */} - + @@ -111,7 +111,7 @@ const confirmDiscardChanges = async () => { - + ```typescript import { Component, h } from '@stencil/core'; @@ -242,7 +242,7 @@ const confirmDiscardChanges = async () => { - + ## Properties {/* #properties */} diff --git a/docs/api/tab-bar.mdx b/docs/api/tab-bar.mdx index 6b976c81539..0d78c63f004 100644 --- a/docs/api/tab-bar.mdx +++ b/docs/api/tab-bar.mdx @@ -3,7 +3,7 @@ title: 'ion-tab-bar' description: 'The tab bar component contains a set of tab buttons and a tab bar must be provided inside of tabs to communicate. Read more about use and CSS custom properties.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; import Props from '@ionic-internal/component-api/v9/tab-bar/props.mdx'; @@ -25,7 +25,7 @@ The tab bar is a UI component that contains a set of [tab buttons](./tab-button. ## Usage {/* #usage */} - + @@ -131,7 +131,7 @@ import { call, person, settings } from 'ionicons/icons'; - + ## Badges in Tab Buttons {/* #badges-in-tab-buttons */} diff --git a/docs/api/tab-button.mdx b/docs/api/tab-button.mdx index dcb3498460e..e6c10c1bbe3 100644 --- a/docs/api/tab-button.mdx +++ b/docs/api/tab-button.mdx @@ -3,7 +3,7 @@ title: 'ion-tab-button' description: 'ion-tab-button is placed inside of an ion-tab-bar. It sets the layout of its icon and label, and connects to an ion-tab.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; import Props from '@ionic-internal/component-api/v9/tab-button/props.mdx'; @@ -23,7 +23,7 @@ Refer to the [tabs documentation](./tabs.mdx) for more details on configuring ta ## Usage {/* #usage */} - + @@ -181,7 +181,7 @@ import { calendar, informationCircle, map, personCircle } from 'ionicons/icons'; - + ## Properties {/* #properties */} diff --git a/docs/api/toast.mdx b/docs/api/toast.mdx index f8bb76dec48..9f4d71154f0 100644 --- a/docs/api/toast.mdx +++ b/docs/api/toast.mdx @@ -3,7 +3,7 @@ title: 'ion-toast' description: 'ion-toast component is an app notification displaying system messages or feedback. Toast alerts appear above content and are dismissed to resume interaction.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; import Props from '@ionic-internal/component-api/v9/toast/props.mdx'; @@ -125,7 +125,7 @@ Since toasts are intended to be subtle notification, `aria-live` should never be Buttons containing text will be read by a screen reader when they are interacted with. If a button contains only an icon, or a description other than the existing text is desired, a label should be assigned to the button by passing `aria-label` to the `htmlAttributes` property on the button. - + @@ -199,7 +199,7 @@ const toast = await toastController.create({ - + ### Tips {/* #tips */} diff --git a/docs/developing/config.mdx b/docs/developing/config.mdx index e584060cbba..1c937e43eb1 100644 --- a/docs/developing/config.mdx +++ b/docs/developing/config.mdx @@ -3,7 +3,7 @@ title: Config description: 'Ionic Config changes component properties across an app, such as the mode, tab button layout, and animations, globally or per platform.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; Ionic Config provides a way to change the properties of components globally across an app. It can set the app mode, tab button layout, animations, and more. @@ -73,14 +73,7 @@ Ionic Angular provides a `Config` provider for accessing the Ionic Config. #### Examples {/* #examples */} - + ```ts @@ -109,7 +102,7 @@ class AppComponent { ``` - + ### getBoolean {/* #getboolean */} @@ -120,14 +113,7 @@ class AppComponent { #### Examples {/* #examples-1 */} - + ```ts @@ -156,7 +142,7 @@ class AppComponent { ``` - + ### getNumber {/* #getnumber */} diff --git a/docs/developing/config/_global.mdx b/docs/developing/config/_global.mdx index 6c71cd6f1f3..c198d4ca7f2 100644 --- a/docs/developing/config/_global.mdx +++ b/docs/developing/config/_global.mdx @@ -1,17 +1,7 @@ -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; - + ```javascript title="example.js" @@ -90,4 +80,4 @@ createApp(App).use(IonicVue, { ``` - + diff --git a/docs/developing/config/_per-component.mdx b/docs/developing/config/_per-component.mdx index 656e2ec6698..97bd26dbacd 100644 --- a/docs/developing/config/_per-component.mdx +++ b/docs/developing/config/_per-component.mdx @@ -1,17 +1,7 @@ -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; - + **Not recommended** @@ -185,4 +175,4 @@ const backButtonText = ref('Go Back'); ``` - + diff --git a/docs/developing/config/_per-platform-fallback.mdx b/docs/developing/config/_per-platform-fallback.mdx index c5dbe5e65db..0d356d16b6d 100644 --- a/docs/developing/config/_per-platform-fallback.mdx +++ b/docs/developing/config/_per-platform-fallback.mdx @@ -1,16 +1,7 @@ -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; - + ```ts title="app.module.ts" @@ -109,4 +100,4 @@ createApp(App).use(IonicVue, getConfig()); ``` - + diff --git a/docs/developing/config/_per-platform-overrides.mdx b/docs/developing/config/_per-platform-overrides.mdx index d379bd7bb59..c0e52e24886 100644 --- a/docs/developing/config/_per-platform-overrides.mdx +++ b/docs/developing/config/_per-platform-overrides.mdx @@ -1,16 +1,7 @@ -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; - + ```ts title="app.module.ts" @@ -121,4 +112,4 @@ createApp(App).use(IonicVue, getConfig()); ``` - + diff --git a/docs/developing/config/_per-platform.mdx b/docs/developing/config/_per-platform.mdx index 632f347d783..527457703f3 100644 --- a/docs/developing/config/_per-platform.mdx +++ b/docs/developing/config/_per-platform.mdx @@ -1,16 +1,7 @@ -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; - + :::note @@ -98,4 +89,4 @@ createApp(App).use(IonicVue, { ``` - + diff --git a/docs/developing/hardware-back-button.mdx b/docs/developing/hardware-back-button.mdx index 52e2a46d01c..3a1f0bfa4fc 100644 --- a/docs/developing/hardware-back-button.mdx +++ b/docs/developing/hardware-back-button.mdx @@ -3,7 +3,7 @@ title: Hardware Back Button description: 'The hardware back button is found on most Android devices. Read to learn more about hardware back button use in Capacitor and Cordova on Ionic applications.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; @@ -54,17 +54,7 @@ The `ionBackButton` event will not be emitted when running an app in a browser o ## Basic Usage {/* #basic-usage */} ````mdx-code-block - + ```javascript @@ -128,7 +118,7 @@ useBackButton(10, () => { }); ``` - + ```` In this example, we are registering a handler to be called when the hardware back button is pressed. We have set the priority to be 10, and we have not indicated to the framework that we want the next handler to be called. As a result, any handlers with a priority less than 10 will not be called. A handler that has a priority greater than 10 will be called first. @@ -140,17 +130,7 @@ In the event that there are handlers with the same priority value, the handler t Each hardware back button callback has a `processNextHandler` parameter. Calling this function allows you to continue calling hardware back button handlers. ````mdx-code-block - + ```javascript @@ -244,7 +224,7 @@ useBackButton(10, (processNextHandler) => { }); ``` - + ```` This example shows how to indicate to Ionic Framework that you want the next handler to be fired. All callbacks are provided with a `processNextHandler` function as a parameter. Calling this will cause the next handler, if any exists, to be fired. @@ -278,17 +258,7 @@ In the example above, both handlers A and B have a priority of 10. Since handler In some scenarios, it may be desirable to quit the app when pressing the hardware back button. This can be achieved through the use of the `ionBackButton` event combined with methods that Capacitor/Cordova provide. ````mdx-code-block - + ```tsx @@ -384,7 +354,7 @@ useBackButton(-1, () => { }); ``` - + ```` This example shows the application exiting when the user presses the hardware back button and there is nothing left in the navigation stack. It is also possible to display a confirmation dialog before quitting the app. diff --git a/docs/developing/keyboard.mdx b/docs/developing/keyboard.mdx index 542d6613dcc..3a53cb8d83e 100644 --- a/docs/developing/keyboard.mdx +++ b/docs/developing/keyboard.mdx @@ -3,7 +3,7 @@ title: Keyboard description: 'Accounting for an on-screen keyboard is a common developer roadblock. This guide introduces the tools available for managing on-screen keyboards in mobile apps.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; @@ -77,17 +77,7 @@ Detecting the presence of an on-screen keyboard is useful for adjusting the posi ### Usage {/* #usage-2 */} ````mdx-code-block - + ```javascript @@ -168,7 +158,7 @@ watch(keyboardHeight, () => { ``` - + ```` :::note diff --git a/docs/developing/managing-focus.mdx b/docs/developing/managing-focus.mdx index bd7cb0a5e0c..494ac2c3df3 100644 --- a/docs/developing/managing-focus.mdx +++ b/docs/developing/managing-focus.mdx @@ -3,7 +3,7 @@ title: Managing Focus description: 'Learn how to manage focus in Ionic applications using the setFocus API instead of the autofocus attribute.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; @@ -43,15 +43,7 @@ import Basic from '@site/static/usage/v9/input/set-focus/index.mdx'; Developers can use the `ionViewDidEnter` lifecycle event to set focus to an element when a page is entered. ````mdx-code-block - + @@ -123,7 +115,7 @@ onIonViewDidEnter(() => { ``` - + ```` ### Overlays {/* #overlays */} @@ -131,16 +123,7 @@ onIonViewDidEnter(() => { Developers can use the `didPresent` lifecycle event to set focus to an element when an overlay is presented. ````mdx-code-block - + @@ -235,7 +218,7 @@ function onDidPresent() { ``` - + ```` ## Assistive Technology Focus Management {/* #assistive-technology-focus-management */} diff --git a/docs/native-setup.mdx b/docs/native-setup.mdx index 7f2c2f3f9c0..b5229f17723 100644 --- a/docs/native-setup.mdx +++ b/docs/native-setup.mdx @@ -6,7 +6,7 @@ hide_table_of_contents: true slug: /native/setup --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; @@ -36,16 +36,7 @@ Once installed, plugins can be imported into a component and you can call the na Using the [Camera plugin](./native/camera.mdx) as an example, first install it: ````mdx-code-block - + ```javascript @@ -137,5 +128,5 @@ export function CameraComponent() { ``` - + ```` diff --git a/docs/techniques/security.mdx b/docs/techniques/security.mdx index ee19d152316..31648ecc685 100644 --- a/docs/techniques/security.mdx +++ b/docs/techniques/security.mdx @@ -7,7 +7,7 @@ description: "View Ionic's security info for sanitizing user input, ejecting fro Security for Angular, React, and Vue Apps - Ionic Framework -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; ## Sanitizing User Input {/* #sanitizing-user-input */} @@ -91,16 +91,7 @@ Refer to [Enabling Custom HTML Parsing](#enabling-custom-html-parsing-via-innerh #### Usage {/* #usage */} ````mdx-code-block - + ```tsx @@ -180,7 +171,7 @@ export const ToastExample: React.FC = () => { }; ``` - + ```` ## Content Security Policies (CSP) {/* #content-security-policies-csp */} diff --git a/docs/theming/dark-mode.mdx b/docs/theming/dark-mode.mdx index 38052721a14..f3e02c3da95 100644 --- a/docs/theming/dark-mode.mdx +++ b/docs/theming/dark-mode.mdx @@ -4,6 +4,7 @@ description: 'Developers are adding dark mode CSS on native applications to supp --- import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; @@ -20,7 +21,7 @@ There are three provided ways to enable the dark palette in an app: **always**, The default palette provided with Ionic Framework is a light palette, consisting of a light background and dark text. However, the default palette can be changed to the dark palette by importing the following stylesheet in the appropriate files: - + @@ -51,7 +52,7 @@ import '@ionic/vue/css/palettes/dark.always.css'; - + This sets the [application colors](./themes.mdx#application-colors) and [stepped colors](./themes.mdx#stepped-colors) on the [`:root`](https://developer.mozilla.org/en-US/docs/Web/CSS/:root) selector. @@ -71,7 +72,7 @@ Avoid targeting the `.ios` or `.md` selectors to override the Ionic dark palette The system approach to enable dark mode involves checking the system settings for the user's preferred color scheme. This is the default when starting a new Ionic Framework app. Importing the following stylesheet in the appropriate file will automatically retrieve the user's preference from the system settings and apply the dark palette when dark mode is preferred: - + @@ -102,7 +103,7 @@ import '@ionic/vue/css/palettes/dark.system.css'; - + This sets the [application colors](./themes.mdx#application-colors) and [stepped colors](./themes.mdx#stepped-colors) when the [CSS media query for `prefers-color-scheme`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme) is `dark`. The `prefers-color-scheme` media query is supported by [all modern browsers](https://caniuse.com/#feat=prefers-color-scheme). If support for older browser is required, we recommend using the [CSS class](#css-class) approach. @@ -128,7 +129,7 @@ Avoid targeting the `.ios` or `.md` selectors to override the Ionic dark palette While the previous approaches are excellent for enabling the dark palette through file imports alone, there are scenarios where you may need more control over its application. In cases where you need to apply the dark palette conditionally, such as through a toggle, or if you want to extend the functionality based on system settings, we provide a dark palette class file. This file applies the dark palette when a specific class is added to an app. Importing the following stylesheet into the appropriate file will provide the necessary styles for using the dark palette with the class: - + @@ -159,7 +160,7 @@ import '@ionic/vue/css/palettes/dark.class.css'; - + This sets the [application colors](./themes.mdx#application-colors) and [stepped colors](./themes.mdx#stepped-colors) on the `.ion-palette-dark` selector, which must be applied to the app by the developer. diff --git a/docs/theming/high-contrast-mode.mdx b/docs/theming/high-contrast-mode.mdx index d14b546e197..363b5e31af0 100644 --- a/docs/theming/high-contrast-mode.mdx +++ b/docs/theming/high-contrast-mode.mdx @@ -4,6 +4,7 @@ description: 'Developers are adding high contrast mode CSS on native application --- import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; @@ -24,7 +25,7 @@ There are three provided ways to enable the high contrast palette in an app: **a The high contrast palette can be enabled by importing the following stylesheet in the appropriate files. This approach will enable the high contrast palette regardless of the system settings for contrast preference. - + @@ -59,7 +60,7 @@ import '@ionic/vue/css/palettes/high-contrast.always.css'; // Light palette - + The high contrast dark palette can be applied by importing `high-contrast-dark.always.css` instead of `high-contrast.always.css`. @@ -75,7 +76,7 @@ The system approach to enabling high contrast mode involves checking the system The following example shows how to include both the high contrast light palette as well as the high contrast dark palette. The system's dark mode preference will be checked to show either the light or dark variant of the high contrast palette. - + @@ -110,7 +111,7 @@ import '@ionic/vue/css/palettes/high-contrast-dark.system.css'; - + This approach activates the high contrast palette when the [CSS media query for `prefers-contrast`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-contrast) is `more`. The `prefers-contrast` media query is supported by [all modern browsers](https://caniuse.com/?search=prefers-contrast). If support for an older browser is required, we recommend using the [CSS class](#css-class) approach. @@ -136,7 +137,7 @@ The high contrast light palette must be imported after [core.css](../layout/glob While the previous approaches are excellent for enabling the high contrast palette through file imports alone, there are scenarios where you may need more control over where it is applied. In cases where you need to apply the high contrast palette conditionally, such as through a toggle, or if you want to extend the functionality based on system settings, we provide a high contrast palette class file. This file applies the high contrast palette when a specific class is added to an app. Importing the following stylesheets into the appropriate file will provide the necessary styles for using the high contrast palette with the class: - + @@ -171,7 +172,7 @@ import '@ionic/vue/css/palettes/high-contrast-dark.class.css'; - + This approach activates the high contrast palette when the `.ion-palette-high-contrast` class is set on the `html` element. This class must be applied by the developer. This can be combined with the [`.ion-palette-dark` class](./dark-mode.mdx#css-class) to conditionally apply the high contrast dark palette. diff --git a/docs/utilities/animations.mdx b/docs/utilities/animations.mdx index 6eea3d8791c..7513a96d4b3 100644 --- a/docs/utilities/animations.mdx +++ b/docs/utilities/animations.mdx @@ -4,7 +4,7 @@ description: 'Ionic apps use Web Animations API to build and run animations. Lea --- import Codepen from '@components/global/Codepen'; -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; @@ -22,18 +22,7 @@ Ionic Animations, on the other hand, uses the [Web Animations API](https://devel ## Installation {/* #installation */} ````mdx-code-block - + Developers using Ionic Core and JavaScript should install the latest version of `@ionic/core`. @@ -51,7 +40,7 @@ const animation = createAnimation() ``` - + Developers using Ionic Core and TypeScript should install the latest version of `@ionic/core`. @@ -150,7 +139,7 @@ const animation = createAnimation() ``` - + ```` ## Basic Animations {/* #basic-animations */} diff --git a/docs/utilities/gestures.mdx b/docs/utilities/gestures.mdx index 32004c0044e..923f2e03c38 100644 --- a/docs/utilities/gestures.mdx +++ b/docs/utilities/gestures.mdx @@ -4,7 +4,7 @@ description: 'Ionic Gestures is a utility that allows developers to build custom --- import Codepen from '@components/global/Codepen'; -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; @@ -20,17 +20,7 @@ Building complex gestures can be time consuming. Other libraries that provide cu ## Installation {/* #installation */} ````mdx-code-block - + Developers using Ionic Core and JavaScript should install the latest version of `@ionic/core`. @@ -49,7 +39,7 @@ const gesture = createGesture({ ``` - + Developers using Ionic Core and TypeScript should install the latest version of `@ionic/core`. @@ -154,7 +144,7 @@ const gesture = createGesture({ ``` - + ```` ## Basic Gestures {/* #basic-gestures */} diff --git a/versioned_docs/version-v8/angular/platform.mdx b/versioned_docs/version-v8/angular/platform.mdx index 642c2ae6a5b..8f9c72480a3 100644 --- a/versioned_docs/version-v8/angular/platform.mdx +++ b/versioned_docs/version-v8/angular/platform.mdx @@ -3,7 +3,7 @@ title: Platform description: 'Ionic Platform service can be used to get information about your current device. With this information you can completely customize your app to fit any device.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; @@ -14,14 +14,7 @@ The Platform service can be used to get information about your current device. Y ## Usage {/* #usage */} - + ```tsx @@ -50,7 +43,7 @@ export class MyPage { ``` - + ## Methods {/* #methods */} diff --git a/versioned_docs/version-v8/angular/slides.mdx b/versioned_docs/version-v8/angular/slides.mdx index 4dd77ea6bd6..9368e228030 100644 --- a/versioned_docs/version-v8/angular/slides.mdx +++ b/versioned_docs/version-v8/angular/slides.mdx @@ -3,7 +3,7 @@ title: Migrating from ion-slides to Swiper.js description: 'Read this guide to learn how to get Swiper.js for Angular set up in your Ionic Framework application for a modern touch slider component.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; @@ -141,14 +141,7 @@ It is recommended to review the [properties](https://github.com/ionic-team/ionic We can install the `IonicSlides` module by importing and passing it to the `modules` property of `swiper-container` as an array: - + ```typescript @@ -181,7 +174,7 @@ export class HomePage { ``` - + ```html diff --git a/versioned_docs/version-v8/api/action-sheet.mdx b/versioned_docs/version-v8/api/action-sheet.mdx index f5a79d9e84d..da68a319256 100644 --- a/versioned_docs/version-v8/api/action-sheet.mdx +++ b/versioned_docs/version-v8/api/action-sheet.mdx @@ -3,7 +3,7 @@ title: 'ion-action-sheet' description: 'Action Sheets are dialogs that display a set of options above app content and must be manually dismissed. Read to learn about use on iOS and Android devices.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; import Props from '@ionic-internal/component-api/v8/action-sheet/props.mdx'; @@ -109,7 +109,7 @@ Action Sheets are given a `role` of [`dialog`](https://developer.mozilla.org/en- It is strongly recommended that every Action Sheet have the `header` property defined, as Ionic will automatically set `aria-labelledby` to point to the header element. However, if you choose not to include a `header`, an alternative is to use the `htmlAttributes` property to provide a descriptive `aria-label` or set a custom `aria-labelledby` value. - + @@ -159,13 +159,13 @@ const actionSheet = await actionSheetController.create({ - + #### Action Sheet Buttons Description {/* #action-sheet-buttons-description */} Buttons containing text will be read by a screen reader. If a button contains only an icon, or a description other than the existing text is desired, a label should be assigned to the button by passing `aria-label` to the `htmlAttributes` property on the button. - + @@ -239,7 +239,7 @@ const actionSheet = await actionSheetController.create({ - + ## Interfaces {/* #interfaces */} diff --git a/versioned_docs/version-v8/api/alert.mdx b/versioned_docs/version-v8/api/alert.mdx index a64e2b5390a..19a90136b15 100644 --- a/versioned_docs/version-v8/api/alert.mdx +++ b/versioned_docs/version-v8/api/alert.mdx @@ -3,7 +3,7 @@ title: 'ion-alert' description: "ion-alert dialog presents or collects information using inputs. Custom alert button messages appear above the app's content and must be manually dismissed." --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; import Props from '@ionic-internal/component-api/v8/alert/props.mdx'; @@ -127,7 +127,7 @@ If the `header` property is defined for the Alert, the `aria-labelledby` attribu It is strongly recommended that your Alert have a `message`, as well as either a `header` or `subHeader`, in order to align with the ARIA spec. If you choose not to include a `header` or `subHeader`, an alternative is to provide a descriptive `aria-label` using the `htmlAttributes` property. - + @@ -181,7 +181,7 @@ const alert = await alertController.create({ - + All ARIA attributes can be manually overwritten by defining custom values in the `htmlAttributes` property of the Alert. @@ -189,7 +189,7 @@ All ARIA attributes can be manually overwritten by defining custom values in the Buttons containing text will be read by a screen reader. If a description other than the existing text is desired, a label can be set on the button by passing `aria-label` to the `htmlAttributes` property on the button. - + @@ -263,7 +263,7 @@ const alert = await alertController.create({ - + ## Interfaces {/* #interfaces */} diff --git a/versioned_docs/version-v8/api/route.mdx b/versioned_docs/version-v8/api/route.mdx index ac1f903d47e..0a1351a21b7 100644 --- a/versioned_docs/version-v8/api/route.mdx +++ b/versioned_docs/version-v8/api/route.mdx @@ -3,7 +3,7 @@ title: 'ion-route' description: 'The ion-route component takes a component and renders it when the Browser URL matches the URL property. Learn more about the API route component for Ionic Apps.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; import Props from '@ionic-internal/component-api/v8/route/props.mdx'; @@ -44,7 +44,7 @@ interface NavigationHookOptions { ## Usage {/* #usage */} - + @@ -111,7 +111,7 @@ const confirmDiscardChanges = async () => { - + ```typescript import { Component, h } from '@stencil/core'; @@ -242,7 +242,7 @@ const confirmDiscardChanges = async () => { - + ## Properties {/* #properties */} diff --git a/versioned_docs/version-v8/api/tab-bar.mdx b/versioned_docs/version-v8/api/tab-bar.mdx index 9092d58b9df..7a1768d71ca 100644 --- a/versioned_docs/version-v8/api/tab-bar.mdx +++ b/versioned_docs/version-v8/api/tab-bar.mdx @@ -3,7 +3,7 @@ title: 'ion-tab-bar' description: 'The tab bar component contains a set of tab buttons and a tab bar must be provided inside of tabs to communicate. Read more about use and CSS custom properties.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; import Props from '@ionic-internal/component-api/v8/tab-bar/props.mdx'; @@ -25,7 +25,7 @@ The tab bar is a UI component that contains a set of [tab buttons](./tab-button. ## Usage {/* #usage */} - + @@ -131,7 +131,7 @@ export const TabBarExample: React.FC = () => ( - + ## Badges in Tab Buttons {/* #badges-in-tab-buttons */} diff --git a/versioned_docs/version-v8/api/tab-button.mdx b/versioned_docs/version-v8/api/tab-button.mdx index e77e074451f..824cfbff093 100644 --- a/versioned_docs/version-v8/api/tab-button.mdx +++ b/versioned_docs/version-v8/api/tab-button.mdx @@ -3,7 +3,7 @@ title: 'ion-tab-button' description: 'ion-tab-button is placed inside of an ion-tab-bar. It sets the layout of its icon and label, and connects to an ion-tab.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; import Props from '@ionic-internal/component-api/v8/tab-button/props.mdx'; @@ -23,7 +23,7 @@ Refer to the [tabs documentation](./tabs.mdx) for more details on configuring ta ## Usage {/* #usage */} - + @@ -181,7 +181,7 @@ export const TabButtonExample: React.FC = () => ( - + ## Properties {/* #properties */} diff --git a/versioned_docs/version-v8/api/toast.mdx b/versioned_docs/version-v8/api/toast.mdx index de23f186698..24e2e03c4d7 100644 --- a/versioned_docs/version-v8/api/toast.mdx +++ b/versioned_docs/version-v8/api/toast.mdx @@ -3,7 +3,7 @@ title: 'ion-toast' description: 'ion-toast component is an app notification displaying system messages or feedback. Toast alerts appear above content and are dismissed to resume interaction.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; import Props from '@ionic-internal/component-api/v8/toast/props.mdx'; @@ -125,7 +125,7 @@ Since toasts are intended to be subtle notification, `aria-live` should never be Buttons containing text will be read by a screen reader when they are interacted with. If a button contains only an icon, or a description other than the existing text is desired, a label should be assigned to the button by passing `aria-label` to the `htmlAttributes` property on the button. - + @@ -199,7 +199,7 @@ const toast = await toastController.create({ - + ### Tips {/* #tips */} diff --git a/versioned_docs/version-v8/developing/config.mdx b/versioned_docs/version-v8/developing/config.mdx index 22d5a2be2c7..4dbf9d581a6 100644 --- a/versioned_docs/version-v8/developing/config.mdx +++ b/versioned_docs/version-v8/developing/config.mdx @@ -3,7 +3,7 @@ title: Config description: 'Ionic Config changes component properties across an app, such as the mode, tab button layout, and animations, globally or per platform.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; Ionic Config provides a way to change the properties of components globally across an app. It can set the app mode, tab button layout, animations, and more. @@ -73,14 +73,7 @@ Ionic Angular provides a `Config` provider for accessing the Ionic Config. #### Examples {/* #examples */} - + ```ts @@ -109,7 +102,7 @@ class AppComponent { ``` - + ### getBoolean {/* #getboolean */} @@ -120,14 +113,7 @@ class AppComponent { #### Examples {/* #examples-1 */} - + ```ts @@ -156,7 +142,7 @@ class AppComponent { ``` - + ### getNumber {/* #getnumber */} diff --git a/versioned_docs/version-v8/developing/config/_global.mdx b/versioned_docs/version-v8/developing/config/_global.mdx index 19d3494dd66..3d20c9b27cc 100644 --- a/versioned_docs/version-v8/developing/config/_global.mdx +++ b/versioned_docs/version-v8/developing/config/_global.mdx @@ -1,17 +1,7 @@ -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; - + ```javascript title="example.js" @@ -86,4 +76,4 @@ createApp(App).use(IonicVue, { ``` - + diff --git a/versioned_docs/version-v8/developing/config/_per-component.mdx b/versioned_docs/version-v8/developing/config/_per-component.mdx index cf0aecc3cc2..17401484382 100644 --- a/versioned_docs/version-v8/developing/config/_per-component.mdx +++ b/versioned_docs/version-v8/developing/config/_per-component.mdx @@ -1,17 +1,7 @@ -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; - + **Not recommended** @@ -181,4 +171,4 @@ createApp(App).use(IonicVue, { ``` - + diff --git a/versioned_docs/version-v8/developing/config/_per-platform-fallback.mdx b/versioned_docs/version-v8/developing/config/_per-platform-fallback.mdx index a3bbd7fa45a..c6e20ae1ff9 100644 --- a/versioned_docs/version-v8/developing/config/_per-platform-fallback.mdx +++ b/versioned_docs/version-v8/developing/config/_per-platform-fallback.mdx @@ -1,16 +1,7 @@ -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; - + ```ts title="app.module.ts" @@ -105,4 +96,4 @@ createApp(App).use(IonicVue, getConfig()); ``` - + diff --git a/versioned_docs/version-v8/developing/config/_per-platform-overrides.mdx b/versioned_docs/version-v8/developing/config/_per-platform-overrides.mdx index 6ee558f9e41..14678b462d1 100644 --- a/versioned_docs/version-v8/developing/config/_per-platform-overrides.mdx +++ b/versioned_docs/version-v8/developing/config/_per-platform-overrides.mdx @@ -1,16 +1,7 @@ -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; - + ```ts title="app.module.ts" @@ -117,4 +108,4 @@ createApp(App).use(IonicVue, getConfig()); ``` - + diff --git a/versioned_docs/version-v8/developing/config/_per-platform.mdx b/versioned_docs/version-v8/developing/config/_per-platform.mdx index efa3b05e05c..7cccff81163 100644 --- a/versioned_docs/version-v8/developing/config/_per-platform.mdx +++ b/versioned_docs/version-v8/developing/config/_per-platform.mdx @@ -1,16 +1,7 @@ -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; - + :::note @@ -94,4 +85,4 @@ createApp(App).use(IonicVue, { ``` - + diff --git a/versioned_docs/version-v8/developing/hardware-back-button.mdx b/versioned_docs/version-v8/developing/hardware-back-button.mdx index e3773651541..f0b053aee5d 100644 --- a/versioned_docs/version-v8/developing/hardware-back-button.mdx +++ b/versioned_docs/version-v8/developing/hardware-back-button.mdx @@ -3,7 +3,7 @@ title: Hardware Back Button description: 'The hardware back button is found on most Android devices. Read to learn more about hardware back button use in Capacitor and Cordova on Ionic applications.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; @@ -54,17 +54,7 @@ The `ionBackButton` event will not be emitted when running an app in a browser o ## Basic Usage {/* #basic-usage */} ````mdx-code-block - + ```javascript @@ -128,7 +118,7 @@ useBackButton(10, () => { }); ``` - + ```` In this example, we are registering a handler to be called when the hardware back button is pressed. We have set the priority to be 10, and we have not indicated to the framework that we want the next handler to be called. As a result, any handlers with a priority less than 10 will not be called. A handler that has a priority greater than 10 will be called first. @@ -140,17 +130,7 @@ In the event that there are handlers with the same priority value, the handler t Each hardware back button callback has a `processNextHandler` parameter. Calling this function allows you to continue calling hardware back button handlers. ````mdx-code-block - + ```javascript @@ -244,7 +224,7 @@ useBackButton(10, (processNextHandler) => { }); ``` - + ```` This example shows how to indicate to Ionic Framework that you want the next handler to be fired. All callbacks are provided with a `processNextHandler` function as a parameter. Calling this will cause the next handler, if any exists, to be fired. @@ -278,17 +258,7 @@ In the example above, both handlers A and B have a priority of 10. Since handler In some scenarios, it may be desirable to quit the app when pressing the hardware back button. This can be achieved through the use of the `ionBackButton` event combined with methods that Capacitor/Cordova provide. ````mdx-code-block - + ```tsx @@ -384,7 +354,7 @@ useBackButton(-1, () => { }); ``` - + ```` This example shows the application exiting when the user presses the hardware back button and there is nothing left in the navigation stack. It is also possible to display a confirmation dialog before quitting the app. diff --git a/versioned_docs/version-v8/developing/keyboard.mdx b/versioned_docs/version-v8/developing/keyboard.mdx index 2812766dc9b..5152c65d040 100644 --- a/versioned_docs/version-v8/developing/keyboard.mdx +++ b/versioned_docs/version-v8/developing/keyboard.mdx @@ -3,7 +3,7 @@ title: Keyboard description: 'Accounting for an on-screen keyboard is a common developer roadblock. This guide introduces the tools available for managing on-screen keyboards in mobile apps.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; @@ -77,17 +77,7 @@ Detecting the presence of an on-screen keyboard is useful for adjusting the posi ### Usage {/* #usage-2 */} ````mdx-code-block - + ```javascript @@ -168,7 +158,7 @@ watch(keyboardHeight, () => { ``` - + ```` :::note diff --git a/versioned_docs/version-v8/developing/managing-focus.mdx b/versioned_docs/version-v8/developing/managing-focus.mdx index b6da8cabe96..f7f50bb7218 100644 --- a/versioned_docs/version-v8/developing/managing-focus.mdx +++ b/versioned_docs/version-v8/developing/managing-focus.mdx @@ -3,7 +3,7 @@ title: Managing Focus description: 'Learn how to manage focus in Ionic applications using the setFocus API instead of the autofocus attribute.' --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; @@ -43,15 +43,7 @@ import Basic from '@site/static/usage/v8/input/set-focus/index.mdx'; Developers can use the `ionViewDidEnter` lifecycle event to set focus to an element when a page is entered. ````mdx-code-block - + @@ -122,7 +114,7 @@ export default Home; ``` - + ```` ### Overlays {/* #overlays */} @@ -130,16 +122,7 @@ export default Home; Developers can use the `didPresent` lifecycle event to set focus to an element when an overlay is presented. ````mdx-code-block - + @@ -233,7 +216,7 @@ export default Home; ``` - + ```` ## Assistive Technology Focus Management {/* #assistive-technology-focus-management */} diff --git a/versioned_docs/version-v8/native-setup.mdx b/versioned_docs/version-v8/native-setup.mdx index 96a225bdcaf..59f46f2cc6d 100644 --- a/versioned_docs/version-v8/native-setup.mdx +++ b/versioned_docs/version-v8/native-setup.mdx @@ -6,7 +6,7 @@ hide_table_of_contents: true slug: /native/setup --- -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; @@ -36,16 +36,7 @@ Once installed, plugins can be imported into a component and you can call the na Using the [Camera plugin](./native/camera.mdx) as an example, first install it: ````mdx-code-block - + ```javascript @@ -137,5 +128,5 @@ export function CameraComponent() { ``` - + ```` diff --git a/versioned_docs/version-v8/techniques/security.mdx b/versioned_docs/version-v8/techniques/security.mdx index 1d91e2cb2e1..9a07773e03d 100644 --- a/versioned_docs/version-v8/techniques/security.mdx +++ b/versioned_docs/version-v8/techniques/security.mdx @@ -7,7 +7,7 @@ description: "View Ionic's security info for sanitizing user input, ejecting fro Security for Angular, React, and Vue Apps - Ionic Framework -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; ## Sanitizing User Input {/* #sanitizing-user-input */} @@ -91,16 +91,7 @@ Refer to [Enabling Custom HTML Parsing](#enabling-custom-html-parsing-via-innerh #### Usage {/* #usage */} ````mdx-code-block - + ```tsx @@ -180,7 +171,7 @@ export const ToastExample: React.FC = () => { }; ``` - + ```` ## Content Security Policies (CSP) {/* #content-security-policies-csp */} diff --git a/versioned_docs/version-v8/theming/dark-mode.mdx b/versioned_docs/version-v8/theming/dark-mode.mdx index 38fef10530e..34f0052a642 100644 --- a/versioned_docs/version-v8/theming/dark-mode.mdx +++ b/versioned_docs/version-v8/theming/dark-mode.mdx @@ -4,6 +4,7 @@ description: 'Developers are adding dark mode CSS on native applications to supp --- import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; @@ -20,7 +21,7 @@ There are three provided ways to enable the dark palette in an app: **always**, The default palette provided with Ionic Framework is a light palette, consisting of a light background and dark text. However, the default palette can be changed to the dark palette by importing the following stylesheet in the appropriate files: - + @@ -51,7 +52,7 @@ import '@ionic/vue/css/palettes/dark.always.css'; - + This sets the [application colors](./themes.mdx#application-colors) and [stepped colors](./themes.mdx#stepped-colors) on the [`:root`](https://developer.mozilla.org/en-US/docs/Web/CSS/:root) selector. @@ -71,7 +72,7 @@ Avoid targeting the `.ios` or `.md` selectors to override the Ionic dark palette The system approach to enable dark mode involves checking the system settings for the user's preferred color scheme. This is the default when starting a new Ionic Framework app. Importing the following stylesheet in the appropriate file will automatically retrieve the user's preference from the system settings and apply the dark palette when dark mode is preferred: - + @@ -102,7 +103,7 @@ import '@ionic/vue/css/palettes/dark.system.css'; - + This sets the [application colors](./themes.mdx#application-colors) and [stepped colors](./themes.mdx#stepped-colors) when the [CSS media query for `prefers-color-scheme`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme) is `dark`. The `prefers-color-scheme` media query is supported by [all modern browsers](https://caniuse.com/#feat=prefers-color-scheme). If support for older browser is required, we recommend using the [CSS class](#css-class) approach. @@ -128,7 +129,7 @@ Avoid targeting the `.ios` or `.md` selectors to override the Ionic dark palette While the previous approaches are excellent for enabling the dark palette through file imports alone, there are scenarios where you may need more control over its application. In cases where you need to apply the dark palette conditionally, such as through a toggle, or if you want to extend the functionality based on system settings, we provide a dark palette class file. This file applies the dark palette when a specific class is added to an app. Importing the following stylesheet into the appropriate file will provide the necessary styles for using the dark palette with the class: - + @@ -159,7 +160,7 @@ import '@ionic/vue/css/palettes/dark.class.css'; - + This sets the [application colors](./themes.mdx#application-colors) and [stepped colors](./themes.mdx#stepped-colors) on the `.ion-palette-dark` selector, which must be applied to the app by the developer. diff --git a/versioned_docs/version-v8/theming/high-contrast-mode.mdx b/versioned_docs/version-v8/theming/high-contrast-mode.mdx index 2c9a842e47b..4e331793628 100644 --- a/versioned_docs/version-v8/theming/high-contrast-mode.mdx +++ b/versioned_docs/version-v8/theming/high-contrast-mode.mdx @@ -4,6 +4,7 @@ description: 'Developers are adding high contrast mode CSS on native application --- import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; @@ -24,7 +25,7 @@ There are three provided ways to enable the high contrast palette in an app: **a The high contrast palette can be enabled by importing the following stylesheet in the appropriate files. This approach will enable the high contrast palette regardless of the system settings for contrast preference. - + @@ -59,7 +60,7 @@ import '@ionic/vue/css/palettes/high-contrast.always.css'; // Light palette - + The high contrast dark palette can be applied by importing `high-contrast-dark.always.css` instead of `high-contrast.always.css`. @@ -75,7 +76,7 @@ The system approach to enabling high contrast mode involves checking the system The following example shows how to include both the high contrast light palette as well as the high contrast dark palette. The system's dark mode preference will be checked to show either the light or dark variant of the high contrast palette. - + @@ -110,7 +111,7 @@ import '@ionic/vue/css/palettes/high-contrast-dark.system.css'; - + This approach activates the high contrast palette when the [CSS media query for `prefers-contrast`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-contrast) is `more`. The `prefers-contrast` media query is supported by [all modern browsers](https://caniuse.com/?search=prefers-contrast). If support for an older browser is required, we recommend using the [CSS class](#css-class) approach. @@ -136,7 +137,7 @@ The high contrast light palette must be imported after [core.css](../layout/glob While the previous approaches are excellent for enabling the high contrast palette through file imports alone, there are scenarios where you may need more control over where it is applied. In cases where you need to apply the high contrast palette conditionally, such as through a toggle, or if you want to extend the functionality based on system settings, we provide a high contrast palette class file. This file applies the high contrast palette when a specific class is added to an app. Importing the following stylesheets into the appropriate file will provide the necessary styles for using the high contrast palette with the class: - + @@ -171,7 +172,7 @@ import '@ionic/vue/css/palettes/high-contrast-dark.class.css'; - + This approach activates the high contrast palette when the `.ion-palette-high-contrast` class is set on the `html` element. This class must be applied by the developer. This can be combined with the [`.ion-palette-dark` class](./dark-mode.mdx#css-class) to conditionally apply the high contrast dark palette. diff --git a/versioned_docs/version-v8/utilities/animations.mdx b/versioned_docs/version-v8/utilities/animations.mdx index 5537f74c550..118c3d3aeb2 100644 --- a/versioned_docs/version-v8/utilities/animations.mdx +++ b/versioned_docs/version-v8/utilities/animations.mdx @@ -4,7 +4,7 @@ description: 'Ionic apps use Web Animations API to build and run animations. Lea --- import Codepen from '@components/global/Codepen'; -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; @@ -22,18 +22,7 @@ Ionic Animations, on the other hand, uses the [Web Animations API](https://devel ## Installation {/* #installation */} ````mdx-code-block - + Developers using Ionic Core and JavaScript should install the latest version of `@ionic/core`. @@ -51,7 +40,7 @@ const animation = createAnimation() ``` - + Developers using Ionic Core and TypeScript should install the latest version of `@ionic/core`. @@ -150,7 +139,7 @@ const animation = createAnimation() ``` - + ```` ## Basic Animations {/* #basic-animations */} diff --git a/versioned_docs/version-v8/utilities/gestures.mdx b/versioned_docs/version-v8/utilities/gestures.mdx index afd21c0f1fa..6eb81cfb5ce 100644 --- a/versioned_docs/version-v8/utilities/gestures.mdx +++ b/versioned_docs/version-v8/utilities/gestures.mdx @@ -4,7 +4,7 @@ description: 'Ionic Gestures is a utility that allows developers to build custom --- import Codepen from '@components/global/Codepen'; -import Tabs from '@theme/Tabs'; +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; import TabItem from '@theme/TabItem'; @@ -20,17 +20,7 @@ Building complex gestures can be time consuming. Other libraries that provide cu ## Installation {/* #installation */} ````mdx-code-block - + Developers using Ionic Core and JavaScript should install the latest version of `@ionic/core`. @@ -49,7 +39,7 @@ const gesture = createGesture({ ``` - + Developers using Ionic Core and TypeScript should install the latest version of `@ionic/core`. @@ -154,7 +144,7 @@ const gesture = createGesture({ ``` - + ```` ## Basic Gestures {/* #basic-gestures */} From 149d2264d67dbfc4b7b4bd72ec408818a650f67d Mon Sep 17 00:00:00 2001 From: Maria Hutt Date: Tue, 24 Nov 2026 15:23:57 -0800 Subject: [PATCH 3/4] chore(lint): require FrameworkTabs for framework tabs --- .remarkrc.mjs | 38 +++++++++++++++++++++++++++++++++++++- CONTRIBUTING.md | 17 +++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/.remarkrc.mjs b/.remarkrc.mjs index cd939f2f88a..c56cc541079 100644 --- a/.remarkrc.mjs +++ b/.remarkrc.mjs @@ -139,9 +139,45 @@ function pageDescription() { }; } +/** + * Framework tabs must use ``, which takes each tab's label and + * the tab order from `src/utils/frameworks.ts`. A `` + * with its own `values` lets pages drift apart in spelling and order. + * + * A Tabs inside an `mdx-code-block` fence is a code node to remark, so the + * fence's text is searched as well. + */ +const FRAMEWORK_TABS_IN_CODE = /]*\bgroupId=["']framework["']/; + +function frameworkTabs() { + return (tree, file) => { + const report = (node) => { + const message = file.message( + 'Use `` instead of ``. It takes the labels and order from `src/utils/frameworks.ts`, so every page shows the frameworks the same way.', + node + ); + message.source = 'ionic-docs'; + message.ruleId = 'framework-tabs'; + }; + const visit = (node) => { + if (node.type === 'code' && node.lang === 'mdx-code-block' && FRAMEWORK_TABS_IN_CODE.test(node.value)) { + report(node); + } else if ( + node.type === 'mdxJsxFlowElement' && + node.name === 'Tabs' && + node.attributes.some((a) => a.name === 'groupId' && a.value === 'framework') + ) { + report(node); + } + node.children?.forEach(visit); + }; + visit(tree); + }; +} + export default { // remark-frontmatter parses the frontmatter as YAML, as Docusaurus does. // Without it, the lint reads it as Markdown, and a `<` in a description // becomes an unclosed JSX tag. - plugins: [remarkFrontmatter, docLinks, pageDescription], + plugins: [remarkFrontmatter, docLinks, pageDescription, frameworkTabs], }; diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 79b826a483f..8a47e8f2b78 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,6 +18,7 @@ Thanks for your interest in contributing to Ionic's documentation! :tada: Check - [Authoring Content](#authoring-content) - [Admonitions](#admonitions) - [Links and Headings](#links-and-headings) + - [Framework Tabs](#framework-tabs) - [Playgrounds](#playgrounds) - [Reference Content](#reference-content) - [Translation](#translation) @@ -241,6 +242,22 @@ Markup inside code samples is exempt, since it's example code rather than part o npm run lint ``` +### Framework Tabs + +To show a sample once per framework, use ``. Give each `` only its `value`, such as `angular`, `react`, or `vue`: + +```mdx +import FrameworkTabs from '@site/src/components/global/FrameworkTabs'; +import TabItem from '@theme/TabItem'; + + + … + … + +``` + +The labels come from `src/utils/frameworks.ts`, and the tabs are sorted alphabetically by label. Picking a framework selects it in every framework tab and playground on the site. A tab outside that list, such as Stencil, needs its own `label`. `npm run lint` fails on a ``. + ### Playgrounds A playground is the interactive example on a component page. It shows a live demo that switches between iOS and Material Design modes, the code for JavaScript, Angular, React and Vue, and a button to open the example in StackBlitz. From c9b29f3e2804a021657ec74a0ad0f1d09d62e471 Mon Sep 17 00:00:00 2001 From: Maria Hutt Date: Tue, 24 Nov 2026 17:32:58 -0800 Subject: [PATCH 4/4] style(framework-switcher): remove trailing whitespace --- src/components/global/FrameworkSwitcher/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/global/FrameworkSwitcher/index.tsx b/src/components/global/FrameworkSwitcher/index.tsx index 961a90b2d28..da6b54c9a04 100644 --- a/src/components/global/FrameworkSwitcher/index.tsx +++ b/src/components/global/FrameworkSwitcher/index.tsx @@ -58,7 +58,7 @@ export default function FrameworkSwitcher({ options, selected, onSelect, classNa const select = (index: number) => { const { value } = options[index]; - + if (value !== selected) { keepInPlace(buttons.current[index], () => onSelect(value)); }