Improve keyboard and screen reader support (#4761)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Nolann B.
2026-11-12 18:23:36 +01:00
committed by GitHub
parent 3e86382cdc
commit 265ca4bd9d
54 changed files with 243 additions and 59 deletions
@@ -0,0 +1,6 @@
---
"gitbook": patch
"@gitbook/icons": patch
---
Add a skip link, keyboard navigation between content tabs, focusable table of contents toggles, and hide decorative icons from assistive technologies.
@@ -1,8 +1,7 @@
'use client'; 'use client';
import React from 'react';
import { getCodeTextFromId } from './utils'; import { getCodeTextFromId } from './utils';
import { useCopyToClipboard } from '@/components/hooks';
import { Button } from '@/components/primitives'; import { Button } from '@/components/primitives';
import { t, useLanguage } from '@/intl/client'; import { t, useLanguage } from '@/intl/client';
import { type ClassValue, tcls } from '@/lib/tailwind'; import { type ClassValue, tcls } from '@/lib/tailwind';
@@ -15,41 +14,30 @@ export function CopyCodeButton(props: { codeId: string; style: ClassValue }) {
const { codeId, style } = props; const { codeId, style } = props;
const language = useLanguage(); const language = useLanguage();
const [copied, setCopied] = React.useState(false); const { copied, copy } = useCopyToClipboard();
React.useEffect(() => {
if (!copied) {
return;
}
const timeout = setTimeout(() => {
setCopied(false);
}, 1000);
return () => {
clearTimeout(timeout);
};
}, [copied]);
const onClick = () => { const onClick = () => {
const codeText = getCodeTextFromId(codeId); const codeText = getCodeTextFromId(codeId);
if (codeText === null) { if (codeText === null) {
return; return;
} }
copy(codeText);
navigator.clipboard.writeText(codeText);
setCopied(true);
}; };
return ( return (
<Button <>
size="xsmall" <Button
variant="secondary" size="xsmall"
onClick={onClick} variant="secondary"
className={tcls(style, 'translate-y-0!', 'print:hidden')} onClick={onClick}
> className={tcls(style, 'translate-y-0!', 'print:hidden')}
{t(language, copied ? 'code_copied' : 'code_copy')} >
</Button> {t(language, copied ? 'code_copied' : 'code_copy')}
</Button>
{/* A label swap on the focused button isn't announced, the live region is. */}
<span role="status" className="sr-only">
{copied ? t(language, 'code_copied') : null}
</span>
</>
); );
} }
@@ -5,6 +5,7 @@ import React from 'react';
import { Icon } from '@gitbook/icons'; import { Icon } from '@gitbook/icons';
import { type PromptActionId, setPromptAction, usePromptAction } from './promptAction'; import { type PromptActionId, setPromptAction, usePromptAction } from './promptAction';
import { useCopyToClipboard } from '@/components/hooks';
import { import {
Button, Button,
ButtonGroup, ButtonGroup,
@@ -27,25 +28,10 @@ export function PromptActions(props: { prompt: string; openInAIProviders: boolea
const { prompt, openInAIProviders } = props; const { prompt, openInAIProviders } = props;
const language = useLanguage(); const language = useLanguage();
const selectedAction = usePromptAction(); const selectedAction = usePromptAction();
const [copied, setCopied] = React.useState(false); const { copied, copy } = useCopyToClipboard(COPIED_MESSAGE_DURATION);
React.useEffect(() => {
if (!copied) {
return;
}
const timeout = setTimeout(() => {
setCopied(false);
}, COPIED_MESSAGE_DURATION);
return () => {
clearTimeout(timeout);
};
}, [copied]);
const copyPrompt = () => { const copyPrompt = () => {
navigator.clipboard.writeText(prompt); copy(prompt);
setCopied(true);
}; };
// The pick follows the visitor from site to site, so fall back to copying wherever the agent // The pick follows the visitor from site to site, so fall back to copying wherever the agent
@@ -0,0 +1,26 @@
import { describe, expect, it } from 'bun:test';
import { getNextTabIndex } from './DynamicTabs';
describe('getNextTabIndex', () => {
it('moves with the arrow keys and wraps around', () => {
expect(getNextTabIndex('ArrowRight', 0, 3)).toBe(1);
expect(getNextTabIndex('ArrowRight', 2, 3)).toBe(0);
expect(getNextTabIndex('ArrowLeft', 0, 3)).toBe(2);
});
it('jumps to the first and last tab', () => {
expect(getNextTabIndex('Home', 2, 3)).toBe(0);
expect(getNextTabIndex('End', 0, 3)).toBe(2);
});
it('mirrors the arrows in right-to-left', () => {
expect(getNextTabIndex('ArrowLeft', 0, 3, true)).toBe(1);
expect(getNextTabIndex('ArrowRight', 0, 3, true)).toBe(2);
});
it('ignores other keys and an unknown tab', () => {
expect(getNextTabIndex('Enter', 0, 3)).toBeNull();
expect(getNextTabIndex('ArrowRight', -1, 3)).toBeNull();
});
});
@@ -151,10 +151,15 @@ const TabItemList = memo(function TabItemList(props: {
}).filter((x) => x !== undefined), }).filter((x) => x !== undefined),
[overflowing, tabs] [overflowing, tabs]
); );
// Roving tabindex: one tab stop for the strip, the active tab when it isn't in the overflow menu.
const visibleTabs = tabs.filter((tab) => !overflowing.has(getTabButtonId(tab.id)));
const focusableTabId =
visibleTabs.find((tab) => tab.id === activeTabId)?.id ?? visibleTabs[0]?.id ?? null;
return ( return (
<div <div
ref={containerRef} ref={containerRef}
role="tablist" role="tablist"
onKeyDown={moveFocusBetweenTabs}
className={tcls( className={tcls(
'group/tabs', 'group/tabs',
'overflow-hidden', 'overflow-hidden',
@@ -182,6 +187,7 @@ const TabItemList = memo(function TabItemList(props: {
key={tab.id} key={tab.id}
ref={itemRef} ref={itemRef}
isActive={tab.id === activeTabId} isActive={tab.id === activeTabId}
isFocusable={tab.id === focusableTabId}
isMeasuring={isMeasuring} isMeasuring={isMeasuring}
tab={tab} tab={tab}
onSelect={onSelect} onSelect={onSelect}
@@ -241,16 +247,18 @@ function TabsDropdownMenu(props: {
const TabItem = memo(function TabItem(props: { const TabItem = memo(function TabItem(props: {
ref: React.Ref<HTMLButtonElement>; ref: React.Ref<HTMLButtonElement>;
isActive: boolean; isActive: boolean;
isFocusable: boolean;
isMeasuring: boolean; isMeasuring: boolean;
tab: TabsItem; tab: TabsItem;
onSelect: (tabId: string) => void; onSelect: (tabId: string) => void;
}) { }) {
const { ref, tab, isActive, isMeasuring, onSelect } = props; const { ref, tab, isActive, isFocusable, isMeasuring, onSelect } = props;
return ( return (
<TabButton <TabButton
ref={ref} ref={ref}
role="tab" role="tab"
aria-selected={isActive} aria-selected={isActive}
tabIndex={isFocusable ? 0 : -1}
aria-controls={tab.id} aria-controls={tab.id}
id={getTabButtonId(tab.id)} id={getTabButtonId(tab.id)}
title={tab.title} title={tab.title}
@@ -343,6 +351,55 @@ function TabButton(
); );
} }
/**
* Arrow keys, Home and End move focus between the tabs of a tablist; Enter or Space then selects.
*/
function moveFocusBetweenTabs(event: React.KeyboardEvent<HTMLElement>) {
const current = event.target instanceof HTMLElement ? event.target : null;
if (current?.getAttribute('role') !== 'tab') {
return;
}
const tabs = Array.from(
event.currentTarget.querySelectorAll<HTMLElement>('[role="tab"]:not([disabled])')
);
const index = tabs.indexOf(current);
const isRTL = getComputedStyle(event.currentTarget).direction === 'rtl';
const next = getNextTabIndex(event.key, index, tabs.length, isRTL);
if (next === null) {
return;
}
event.preventDefault();
tabs[next]?.focus();
}
/**
* Index of the tab to focus for a key press, or null when the key doesn't move focus.
*/
export function getNextTabIndex(
key: string,
index: number,
count: number,
isRTL = false
): number | null {
if (index < 0 || count === 0) {
return null;
}
const forward = isRTL ? 'ArrowLeft' : 'ArrowRight';
const backward = isRTL ? 'ArrowRight' : 'ArrowLeft';
switch (key) {
case forward:
return (index + 1) % count;
case backward:
return (index - 1 + count) % count;
case 'Home':
return 0;
case 'End':
return count - 1;
default:
return null;
}
}
/** /**
* Get the ID for a tab button. * Get the ID for a tab button.
*/ */
@@ -9,7 +9,7 @@ interface HeaderLinksProps {
export async function HeaderLinks({ children, style }: HeaderLinksProps) { export async function HeaderLinks({ children, style }: HeaderLinksProps) {
return ( return (
<div <nav
className={tcls( className={tcls(
'header-links', 'header-links',
'@4xl:[&>.button+.button]:-ml-2 z-20 ml-auto flex min-w-9 shrink grow @7xl:grow-0 items-center justify-end @4xl:gap-x-6 gap-x-4', '@4xl:[&>.button+.button]:-ml-2 z-20 ml-auto flex min-w-9 shrink grow @7xl:grow-0 items-center justify-end @4xl:gap-x-6 gap-x-4',
@@ -17,6 +17,6 @@ export async function HeaderLinks({ children, style }: HeaderLinksProps) {
)} )}
> >
{children} {children}
</div> </nav>
); );
} }
@@ -16,6 +16,7 @@ import { PageCover } from './PageCover';
import { PageFooterNavigation } from './PageFooterNavigation'; import { PageFooterNavigation } from './PageFooterNavigation';
import { PageHeader } from './PageHeader'; import { PageHeader } from './PageHeader';
import { PreservePageLayout } from './PreservePageLayout'; import { PreservePageLayout } from './PreservePageLayout';
import { MAIN_CONTENT_ID } from '@/components/layout';
import { getSpaceLanguage } from '@/intl/server'; import { getSpaceLanguage } from '@/intl/server';
import { t } from '@/intl/translate'; import { t } from '@/intl/translate';
import type { GitBookSiteContext } from '@/lib/context'; import type { GitBookSiteContext } from '@/lib/context';
@@ -103,6 +104,7 @@ export async function PageBody(props: {
/> />
) : null} ) : null}
<main <main
id={MAIN_CONTENT_ID}
// Comments on the whole page target anywhere in it that isn't a block. // Comments on the whole page target anywhere in it that isn't a block.
{...(withCommentAnchors ? { 'data-comment-page': '' } : {})} {...(withCommentAnchors ? { 'data-comment-page': '' } : {})}
className={tcls( className={tcls(
@@ -22,6 +22,7 @@ import {
useSpaceBasePath, useSpaceBasePath,
} from '../SpaceLayout/SpaceLayoutContext'; } from '../SpaceLayout/SpaceLayoutContext';
import { TrackPageViewEvent } from '@/components/Insights'; import { TrackPageViewEvent } from '@/components/Insights';
import { MAIN_CONTENT_ID } from '@/components/layout';
import { t, tString, useLanguage } from '@/intl/client'; import { t, tString, useLanguage } from '@/intl/client';
import { tcls } from '@/lib/tailwind'; import { tcls } from '@/lib/tailwind';
@@ -102,6 +103,7 @@ export function SitePageNotFound() {
<CurrentPageProvider page={null}> <CurrentPageProvider page={null}>
<div className="lg:has-sidebar:-ml-84 w-full"> <div className="lg:has-sidebar:-ml-84 w-full">
<main <main
id={MAIN_CONTENT_ID}
className={tcls( className={tcls(
// `page-no-toc` hides the TOC (like PageBody), and `layout-wide` takes the // `page-no-toc` hides the TOC (like PageBody), and `layout-wide` takes the
// now-empty sidebar out of flow so the content stays centered on all layouts. // now-empty sidebar out of flow so the content stays centered on all layouts.
@@ -12,6 +12,7 @@ import { CurrentContentProvider } from '../hooks';
import { InsightsProvider, VisitorProvider } from '../Insights'; import { InsightsProvider, VisitorProvider } from '../Insights';
import { CONTAINER_STYLE } from '../layout'; import { CONTAINER_STYLE } from '../layout';
import { NavigationLoader } from '../primitives/NavigationLoader'; import { NavigationLoader } from '../primitives/NavigationLoader';
import { SkipToContent } from '../primitives/SkipToContent';
import { SearchContainer, getSearchBaseProps } from '../Search'; import { SearchContainer, getSearchBaseProps } from '../Search';
import { import {
SiteSectionList, SiteSectionList,
@@ -131,6 +132,7 @@ export function SpaceLayout(props: SpaceLayoutProps) {
return ( return (
<SpaceLayoutServerContext {...props}> <SpaceLayoutServerContext {...props}>
<SkipToContent />
<Announcement context={context} /> <Announcement context={context} />
<Header withTopHeader={withTopHeader} variants={variants} context={context} /> <Header withTopHeader={withTopHeader} variants={variants} context={context} />
<NavigationLoader /> <NavigationLoader />
@@ -26,6 +26,7 @@ export function ToggleableLinkItem(
isActive || pathnames.some((pathname) => currentPagePath.startsWith(`${pathname}/`)); isActive || pathnames.some((pathname) => currentPagePath.startsWith(`${pathname}/`));
const [isOpen, setIsOpen] = React.useState(defaultIsOpen); const [isOpen, setIsOpen] = React.useState(defaultIsOpen);
const hasBeenToggled = useRef(false); const hasBeenToggled = useRef(false);
const linkId = React.useId();
// Update the visibility of the children if one of the descendants becomes active. // Update the visibility of the children if one of the descendants becomes active.
React.useEffect(() => { React.useEffect(() => {
@@ -60,10 +61,16 @@ export function ToggleableLinkItem(
} }
return ( return (
<DescendantsRenderer descendants={descendants} isOpen={isOpen} setIsOpen={handleToggle}> <DescendantsRenderer
descendants={descendants}
isOpen={isOpen}
setIsOpen={handleToggle}
labelledBy={linkId}
>
{({ descendants, toggler }) => ( {({ descendants, toggler }) => (
<> <>
<LinkItem <LinkItem
id={linkId}
href={href} href={href}
insights={insights} insights={insights}
isActive={isActive} isActive={isActive}
@@ -88,12 +95,12 @@ export function ToggleableLinkItem(
} }
function LinkItem( function LinkItem(
props: Pick<LinkProps, 'href' | 'insights' | 'children'> & { props: Pick<LinkProps, 'href' | 'insights' | 'children' | 'id'> & {
isActive: boolean; isActive: boolean;
onActiveClick?: () => void; onActiveClick?: () => void;
} }
) { ) {
const { isActive, href, insights, children, onActiveClick } = props; const { id, isActive, href, insights, children, onActiveClick } = props;
const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => { const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => {
if (isActive && onActiveClick) { if (isActive && onActiveClick) {
@@ -104,6 +111,7 @@ function LinkItem(
return ( return (
<Link <Link
id={id}
data-active={isActive} data-active={isActive}
href={href} href={href}
insights={insights} insights={insights}
@@ -123,18 +131,21 @@ function DescendantsRenderer(props: {
descendants: React.ReactNode; descendants: React.ReactNode;
isOpen: boolean; isOpen: boolean;
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>; setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
/** Id of the link the toggle belongs to, used as its accessible name. */
labelledBy: string;
children: (renderProps: { children: (renderProps: {
descendants: React.ReactNode; descendants: React.ReactNode;
toggler: React.ReactNode; toggler: React.ReactNode;
}) => React.ReactNode; }) => React.ReactNode;
}) { }) {
const { descendants, isOpen, setIsOpen } = props; const { descendants, isOpen, setIsOpen, labelledBy } = props;
return props.children({ return props.children({
toggler: ( toggler: (
<Toggler <Toggler
isLinkActive={isOpen} isLinkActive={isOpen}
isOpen={isOpen} isOpen={isOpen}
labelledBy={labelledBy}
onToggle={() => { onToggle={() => {
setIsOpen((prev) => !prev); setIsOpen((prev) => !prev);
}} }}
@@ -144,8 +155,13 @@ function DescendantsRenderer(props: {
}); });
} }
function Toggler(props: { isLinkActive: boolean; isOpen: boolean; onToggle: () => void }) { function Toggler(props: {
const { isOpen, onToggle } = props; isLinkActive: boolean;
isOpen: boolean;
labelledBy: string;
onToggle: () => void;
}) {
const { isOpen, labelledBy, onToggle } = props;
return ( return (
<Button <Button
icon={ icon={
@@ -164,9 +180,12 @@ function Toggler(props: { isLinkActive: boolean; isOpen: boolean; onToggle: () =
size="xsmall" size="xsmall"
iconOnly iconOnly
variant="blank" variant="blank"
aria-hidden="true" // The button has no label or focus so hiding it from screen readers. // Named after its page and focusable: the link only toggles on the current page, so
className="-my-0.5 -mr-1 ml-auto min-h-6 min-w-6 text-current hover:bg-tint-base" // this is the only keyboard way to expand another page's children.
tabIndex={-1} // Prevent focus on the button since it's already inside a clickable link that performs the same toggle action. aria-labelledby={labelledBy}
aria-expanded={isOpen}
// Cancels the Button's expanded highlight: an open chevron must look like a closed one.
className="-my-0.5 -mr-1 ml-auto min-h-6 min-w-6 text-current hover:bg-tint-base aria-expanded:bg-transparent aria-expanded:text-current aria-expanded:hover:bg-tint-hover"
/> />
); );
} }
@@ -10,3 +10,4 @@ export * from './useNow';
export * from './useListOverflow'; export * from './useListOverflow';
export * from './useCurrentPageMetadata'; export * from './useCurrentPageMetadata';
export * from './useBackToSpace'; export * from './useBackToSpace';
export * from './useCopyToClipboard';
@@ -0,0 +1,31 @@
'use client';
import React from 'react';
/**
* Copy text to the clipboard and expose a `copied` flag that resets after `duration`.
* The flag is only set once the write succeeded.
*/
export function useCopyToClipboard(duration = 1000) {
const [copied, setCopied] = React.useState(false);
React.useEffect(() => {
if (!copied) {
return;
}
const timeout = setTimeout(() => setCopied(false), duration);
return () => clearTimeout(timeout);
}, [copied, duration]);
const copy = React.useCallback(async (text: string) => {
try {
await navigator.clipboard.writeText(text);
setCopied(true);
} catch {
// Clipboard access can be denied (permissions, insecure context): don't claim success.
setCopied(false);
}
}, []);
return { copied, copy };
}
@@ -50,3 +50,6 @@ export const SIDE_COLUMN_WITHOUT_HEADER_AND_COVER: ClassValue = [
'top-[240px]', 'top-[240px]',
'h-[calc(100vh-240px)]', 'h-[calc(100vh-240px)]',
]; ];
/** Id of the `<main>` landmark, target of the skip link. */
export const MAIN_CONTENT_ID = 'gitbook-main-content';
@@ -0,0 +1,19 @@
'use client';
import { MAIN_CONTENT_ID } from '../layout';
import { tString, useLanguage } from '@/intl/client';
/**
* Link shown on keyboard focus to jump over the header and navigation.
*/
export function SkipToContent() {
const language = useLanguage();
return (
<a
href={`#${MAIN_CONTENT_ID}`}
className="sr-only focus:not-sr-only focus:fixed focus:left-2 focus:top-2 focus:z-50 focus:rounded-md focus:bg-tint-base focus:px-4 focus:py-2 focus:text-sm focus:text-tint-strong focus:shadow-lg focus:ring-2 focus:ring-primary"
>
{tString(language, 'skip_to_content')}
</a>
);
}
@@ -10,6 +10,7 @@ export const ar: TranslationLanguage = {
switch_to_light_theme: 'التبديل إلى السمة الفاتحة', switch_to_light_theme: 'التبديل إلى السمة الفاتحة',
switch_to_system_theme: 'التبديل إلى سمة النظام', switch_to_system_theme: 'التبديل إلى سمة النظام',
search: 'بحث', search: 'بحث',
skip_to_content: 'تخطي إلى المحتوى',
clear: 'مسح', clear: 'مسح',
table_filtered_by_selection: 'يطابق الاختيار: ${1}', table_filtered_by_selection: 'يطابق الاختيار: ${1}',
table_clear_selection: 'مسح الاختيار', table_clear_selection: 'مسح الاختيار',
@@ -10,6 +10,7 @@ export const bg: TranslationLanguage = {
switch_to_light_theme: 'Превключване към светла тема', switch_to_light_theme: 'Превключване към светла тема',
switch_to_system_theme: 'Превключване към системната тема', switch_to_system_theme: 'Превключване към системната тема',
search: 'Търсене', search: 'Търсене',
skip_to_content: 'Към съдържанието',
clear: 'Изчистване', clear: 'Изчистване',
table_filtered_by_selection: 'Съответства на избора: ${1}', table_filtered_by_selection: 'Съответства на избора: ${1}',
table_clear_selection: 'Изчисти избора', table_clear_selection: 'Изчисти избора',
@@ -10,6 +10,7 @@ export const cs: TranslationLanguage = {
switch_to_light_theme: 'Přepnout na světlý motiv', switch_to_light_theme: 'Přepnout na světlý motiv',
switch_to_system_theme: 'Přepnout na systémový motiv', switch_to_system_theme: 'Přepnout na systémový motiv',
search: 'Hledat', search: 'Hledat',
skip_to_content: 'Přejít k obsahu',
clear: 'Vymazat', clear: 'Vymazat',
table_filtered_by_selection: 'Odpovídá výběru: ${1}', table_filtered_by_selection: 'Odpovídá výběru: ${1}',
table_clear_selection: 'Zrušit výběr', table_clear_selection: 'Zrušit výběr',
@@ -10,6 +10,7 @@ export const da: TranslationLanguage = {
switch_to_light_theme: 'Skift til lyst tema', switch_to_light_theme: 'Skift til lyst tema',
switch_to_system_theme: 'Skift til systemtema', switch_to_system_theme: 'Skift til systemtema',
search: 'Søg', search: 'Søg',
skip_to_content: 'Spring til indhold',
clear: 'Ryd', clear: 'Ryd',
table_filtered_by_selection: 'Matcher valg: ${1}', table_filtered_by_selection: 'Matcher valg: ${1}',
table_clear_selection: 'Ryd valg', table_clear_selection: 'Ryd valg',
@@ -10,6 +10,7 @@ export const de: TranslationLanguage = {
switch_to_light_theme: 'Zum hellen Modus wechseln', switch_to_light_theme: 'Zum hellen Modus wechseln',
switch_to_system_theme: 'Zum Systemmodus wechseln', switch_to_system_theme: 'Zum Systemmodus wechseln',
search: 'Suche', search: 'Suche',
skip_to_content: 'Zum Inhalt springen',
clear: 'Löschen', clear: 'Löschen',
table_filtered_by_selection: 'Entspricht Auswahl: ${1}', table_filtered_by_selection: 'Entspricht Auswahl: ${1}',
table_clear_selection: 'Auswahl zurücksetzen', table_clear_selection: 'Auswahl zurücksetzen',
@@ -10,6 +10,7 @@ export const el: TranslationLanguage = {
switch_to_light_theme: 'Αλλαγή σε φωτεινό θέμα', switch_to_light_theme: 'Αλλαγή σε φωτεινό θέμα',
switch_to_system_theme: 'Αλλαγή στο θέμα συστήματος', switch_to_system_theme: 'Αλλαγή στο θέμα συστήματος',
search: 'Αναζήτηση', search: 'Αναζήτηση',
skip_to_content: 'Μετάβαση στο περιεχόμενο',
clear: 'Εκκαθάριση', clear: 'Εκκαθάριση',
table_filtered_by_selection: 'Ταιριάζει με την επιλογή: ${1}', table_filtered_by_selection: 'Ταιριάζει με την επιλογή: ${1}',
table_clear_selection: 'Εκκαθάριση επιλογής', table_clear_selection: 'Εκκαθάριση επιλογής',
@@ -8,6 +8,7 @@ export const en = {
switch_to_light_theme: 'Switch to light theme', switch_to_light_theme: 'Switch to light theme',
switch_to_system_theme: 'Switch to system theme', switch_to_system_theme: 'Switch to system theme',
search: 'Search', search: 'Search',
skip_to_content: 'Skip to content',
clear: 'Clear', clear: 'Clear',
table_filtered_by_selection: 'Matches selection: ${1}', table_filtered_by_selection: 'Matches selection: ${1}',
table_clear_selection: 'Clear selection', table_clear_selection: 'Clear selection',
@@ -10,6 +10,7 @@ export const es: TranslationLanguage = {
switch_to_light_theme: 'Cambiar a tema claro', switch_to_light_theme: 'Cambiar a tema claro',
switch_to_system_theme: 'Cambiar a tema del sistema', switch_to_system_theme: 'Cambiar a tema del sistema',
search: 'Buscar', search: 'Buscar',
skip_to_content: 'Saltar al contenido',
clear: 'Limpiar', clear: 'Limpiar',
table_filtered_by_selection: 'Coincide con la selección: ${1}', table_filtered_by_selection: 'Coincide con la selección: ${1}',
table_clear_selection: 'Borrar selección', table_clear_selection: 'Borrar selección',
@@ -10,6 +10,7 @@ export const et: TranslationLanguage = {
switch_to_light_theme: 'Lülitu heledale teemale', switch_to_light_theme: 'Lülitu heledale teemale',
switch_to_system_theme: 'Lülitu süsteemi teemale', switch_to_system_theme: 'Lülitu süsteemi teemale',
search: 'Otsi', search: 'Otsi',
skip_to_content: 'Liigu sisu juurde',
clear: 'Tühjenda', clear: 'Tühjenda',
table_filtered_by_selection: 'Vastab valikule: ${1}', table_filtered_by_selection: 'Vastab valikule: ${1}',
table_clear_selection: 'Tühjenda valik', table_clear_selection: 'Tühjenda valik',
@@ -10,6 +10,7 @@ export const fi: TranslationLanguage = {
switch_to_light_theme: 'Vaihda vaaleaan teemaan', switch_to_light_theme: 'Vaihda vaaleaan teemaan',
switch_to_system_theme: 'Vaihda järjestelmän teemaan', switch_to_system_theme: 'Vaihda järjestelmän teemaan',
search: 'Haku', search: 'Haku',
skip_to_content: 'Siirry sisältöön',
clear: 'Tyhjennä', clear: 'Tyhjennä',
table_filtered_by_selection: 'Vastaa valintaa: ${1}', table_filtered_by_selection: 'Vastaa valintaa: ${1}',
table_clear_selection: 'Tyhjennä valinta', table_clear_selection: 'Tyhjennä valinta',
@@ -10,6 +10,7 @@ export const fr: TranslationLanguage = {
switch_to_light_theme: 'Activer le thème clair', switch_to_light_theme: 'Activer le thème clair',
switch_to_system_theme: 'Utiliser le thème du système', switch_to_system_theme: 'Utiliser le thème du système',
search: 'Rechercher', search: 'Rechercher',
skip_to_content: 'Aller au contenu',
clear: 'Effacer', clear: 'Effacer',
table_filtered_by_selection: 'Correspond à la sélection : ${1}', table_filtered_by_selection: 'Correspond à la sélection : ${1}',
table_clear_selection: 'Effacer la sélection', table_clear_selection: 'Effacer la sélection',
@@ -10,6 +10,7 @@ export const he: TranslationLanguage = {
switch_to_light_theme: 'מעבר לערכת נושא בהירה', switch_to_light_theme: 'מעבר לערכת נושא בהירה',
switch_to_system_theme: 'מעבר לערכת הנושא של המערכת', switch_to_system_theme: 'מעבר לערכת הנושא של המערכת',
search: 'חיפוש', search: 'חיפוש',
skip_to_content: 'דילוג לתוכן',
clear: 'ניקוי', clear: 'ניקוי',
table_filtered_by_selection: 'תואם לבחירה: ${1}', table_filtered_by_selection: 'תואם לבחירה: ${1}',
table_clear_selection: 'נקה בחירה', table_clear_selection: 'נקה בחירה',
@@ -10,6 +10,7 @@ export const hi: TranslationLanguage = {
switch_to_light_theme: 'लाइट थीम पर जाएं', switch_to_light_theme: 'लाइट थीम पर जाएं',
switch_to_system_theme: 'सिस्टम थीम पर जाएं', switch_to_system_theme: 'सिस्टम थीम पर जाएं',
search: 'खोजें', search: 'खोजें',
skip_to_content: 'सामग्री पर जाएं',
clear: 'साफ करें', clear: 'साफ करें',
table_filtered_by_selection: 'चयन से मेल खाता है: ${1}', table_filtered_by_selection: 'चयन से मेल खाता है: ${1}',
table_clear_selection: 'चयन साफ़ करें', table_clear_selection: 'चयन साफ़ करें',
@@ -10,6 +10,7 @@ export const hr: TranslationLanguage = {
switch_to_light_theme: 'Prebaci na svijetlu temu', switch_to_light_theme: 'Prebaci na svijetlu temu',
switch_to_system_theme: 'Prebaci na temu sustava', switch_to_system_theme: 'Prebaci na temu sustava',
search: 'Pretraži', search: 'Pretraži',
skip_to_content: 'Preskoči na sadržaj',
clear: 'Očisti', clear: 'Očisti',
table_filtered_by_selection: 'Odgovara odabiru: ${1}', table_filtered_by_selection: 'Odgovara odabiru: ${1}',
table_clear_selection: 'Očisti odabir', table_clear_selection: 'Očisti odabir',
@@ -10,6 +10,7 @@ export const hu: TranslationLanguage = {
switch_to_light_theme: 'Váltás világos témára', switch_to_light_theme: 'Váltás világos témára',
switch_to_system_theme: 'Váltás rendszer témára', switch_to_system_theme: 'Váltás rendszer témára',
search: 'Keresés', search: 'Keresés',
skip_to_content: 'Ugrás a tartalomra',
clear: 'Törlés', clear: 'Törlés',
table_filtered_by_selection: 'Megfelel a kijelölésnek: ${1}', table_filtered_by_selection: 'Megfelel a kijelölésnek: ${1}',
table_clear_selection: 'Kijelölés törlése', table_clear_selection: 'Kijelölés törlése',
@@ -10,6 +10,7 @@ export const id: TranslationLanguage = {
switch_to_light_theme: 'Beralih ke tema terang', switch_to_light_theme: 'Beralih ke tema terang',
switch_to_system_theme: 'Beralih ke tema sistem', switch_to_system_theme: 'Beralih ke tema sistem',
search: 'Cari', search: 'Cari',
skip_to_content: 'Lewati ke konten',
clear: 'Bersihkan', clear: 'Bersihkan',
table_filtered_by_selection: 'Sesuai pilihan: ${1}', table_filtered_by_selection: 'Sesuai pilihan: ${1}',
table_clear_selection: 'Hapus pilihan', table_clear_selection: 'Hapus pilihan',
@@ -10,6 +10,7 @@ export const it: TranslationLanguage = {
switch_to_light_theme: 'Passa al tema chiaro', switch_to_light_theme: 'Passa al tema chiaro',
switch_to_system_theme: 'Passa al tema di sistema', switch_to_system_theme: 'Passa al tema di sistema',
search: 'Cerca', search: 'Cerca',
skip_to_content: 'Vai al contenuto',
clear: 'Cancella', clear: 'Cancella',
table_filtered_by_selection: 'Corrisponde alla selezione: ${1}', table_filtered_by_selection: 'Corrisponde alla selezione: ${1}',
table_clear_selection: 'Cancella selezione', table_clear_selection: 'Cancella selezione',
@@ -10,6 +10,7 @@ export const ja: TranslationLanguage = {
switch_to_light_theme: 'ライトテーマに切り替え', switch_to_light_theme: 'ライトテーマに切り替え',
switch_to_system_theme: 'システムのテーマに切り替え', switch_to_system_theme: 'システムのテーマに切り替え',
search: '検索', search: '検索',
skip_to_content: 'コンテンツへスキップ',
clear: 'クリア', clear: 'クリア',
table_filtered_by_selection: '選択に一致: ${1}', table_filtered_by_selection: '選択に一致: ${1}',
table_clear_selection: '選択をクリア', table_clear_selection: '選択をクリア',
@@ -10,6 +10,7 @@ export const ko: TranslationLanguage = {
switch_to_light_theme: '라이트 테마로 전환', switch_to_light_theme: '라이트 테마로 전환',
switch_to_system_theme: '시스템 테마로 전환', switch_to_system_theme: '시스템 테마로 전환',
search: '검색', search: '검색',
skip_to_content: '본문으로 건너뛰기',
clear: '지우기', clear: '지우기',
table_filtered_by_selection: '선택과 일치: ${1}', table_filtered_by_selection: '선택과 일치: ${1}',
table_clear_selection: '선택 지우기', table_clear_selection: '선택 지우기',
@@ -10,6 +10,7 @@ export const lt: TranslationLanguage = {
switch_to_light_theme: 'Perjungti į šviesią temą', switch_to_light_theme: 'Perjungti į šviesią temą',
switch_to_system_theme: 'Perjungti į sistemos temą', switch_to_system_theme: 'Perjungti į sistemos temą',
search: 'Ieškoti', search: 'Ieškoti',
skip_to_content: 'Pereiti prie turinio',
clear: 'Išvalyti', clear: 'Išvalyti',
table_filtered_by_selection: 'Atitinka pasirinkimą: ${1}', table_filtered_by_selection: 'Atitinka pasirinkimą: ${1}',
table_clear_selection: 'Išvalyti pasirinkimą', table_clear_selection: 'Išvalyti pasirinkimą',
@@ -10,6 +10,7 @@ export const lv: TranslationLanguage = {
switch_to_light_theme: 'Pārslēgt uz gaišo motīvu', switch_to_light_theme: 'Pārslēgt uz gaišo motīvu',
switch_to_system_theme: 'Pārslēgt uz sistēmas motīvu', switch_to_system_theme: 'Pārslēgt uz sistēmas motīvu',
search: 'Meklēt', search: 'Meklēt',
skip_to_content: 'Pāriet uz saturu',
clear: 'Notīrīt', clear: 'Notīrīt',
table_filtered_by_selection: 'Atbilst izvēlei: ${1}', table_filtered_by_selection: 'Atbilst izvēlei: ${1}',
table_clear_selection: 'Notīrīt izvēli', table_clear_selection: 'Notīrīt izvēli',
@@ -10,6 +10,7 @@ export const ms: TranslationLanguage = {
switch_to_light_theme: 'Tukar kepada tema cerah', switch_to_light_theme: 'Tukar kepada tema cerah',
switch_to_system_theme: 'Tukar kepada tema sistem', switch_to_system_theme: 'Tukar kepada tema sistem',
search: 'Cari', search: 'Cari',
skip_to_content: 'Langkau ke kandungan',
clear: 'Kosongkan', clear: 'Kosongkan',
table_filtered_by_selection: 'Sepadan dengan pilihan: ${1}', table_filtered_by_selection: 'Sepadan dengan pilihan: ${1}',
table_clear_selection: 'Kosongkan pilihan', table_clear_selection: 'Kosongkan pilihan',
@@ -10,6 +10,7 @@ export const nl: TranslationLanguage = {
switch_to_light_theme: 'Schakel over naar lichte modus', switch_to_light_theme: 'Schakel over naar lichte modus',
switch_to_system_theme: 'Schakel over naar systeemmodus', switch_to_system_theme: 'Schakel over naar systeemmodus',
search: 'Zoeken', search: 'Zoeken',
skip_to_content: 'Naar inhoud',
clear: 'Wissen', clear: 'Wissen',
table_filtered_by_selection: 'Komt overeen met selectie: ${1}', table_filtered_by_selection: 'Komt overeen met selectie: ${1}',
table_clear_selection: 'Selectie wissen', table_clear_selection: 'Selectie wissen',
@@ -10,6 +10,7 @@ export const no: TranslationLanguage = {
switch_to_light_theme: 'Bytt til lyst tema', switch_to_light_theme: 'Bytt til lyst tema',
switch_to_system_theme: 'Bytt til systemtema', switch_to_system_theme: 'Bytt til systemtema',
search: 'Søk', search: 'Søk',
skip_to_content: 'Hopp til innhold',
clear: 'Tøm', clear: 'Tøm',
table_filtered_by_selection: 'Samsvarer med valg: ${1}', table_filtered_by_selection: 'Samsvarer med valg: ${1}',
table_clear_selection: 'Fjern valg', table_clear_selection: 'Fjern valg',
@@ -10,6 +10,7 @@ export const pl: TranslationLanguage = {
switch_to_light_theme: 'Przełącz na jasny motyw', switch_to_light_theme: 'Przełącz na jasny motyw',
switch_to_system_theme: 'Przełącz na motyw systemowy', switch_to_system_theme: 'Przełącz na motyw systemowy',
search: 'Szukaj', search: 'Szukaj',
skip_to_content: 'Przejdź do treści',
clear: 'Wyczyść', clear: 'Wyczyść',
table_filtered_by_selection: 'Zgodne z wyborem: ${1}', table_filtered_by_selection: 'Zgodne z wyborem: ${1}',
table_clear_selection: 'Wyczyść wybór', table_clear_selection: 'Wyczyść wybór',
@@ -10,6 +10,7 @@ export const pt_br: TranslationLanguage = {
switch_to_light_theme: 'Mudar para modo claro', switch_to_light_theme: 'Mudar para modo claro',
switch_to_system_theme: 'Mudar para configuração do sistema', switch_to_system_theme: 'Mudar para configuração do sistema',
search: 'Buscar', search: 'Buscar',
skip_to_content: 'Pular para o conteúdo',
clear: 'Limpar', clear: 'Limpar',
table_filtered_by_selection: 'Corresponde à seleção: ${1}', table_filtered_by_selection: 'Corresponde à seleção: ${1}',
table_clear_selection: 'Limpar seleção', table_clear_selection: 'Limpar seleção',
@@ -10,6 +10,7 @@ export const pt: TranslationLanguage = {
switch_to_light_theme: 'Mudar para o tema claro', switch_to_light_theme: 'Mudar para o tema claro',
switch_to_system_theme: 'Mudar para o tema do sistema', switch_to_system_theme: 'Mudar para o tema do sistema',
search: 'Pesquisar', search: 'Pesquisar',
skip_to_content: 'Saltar para o conteúdo',
clear: 'Limpar', clear: 'Limpar',
table_filtered_by_selection: 'Corresponde à seleção: ${1}', table_filtered_by_selection: 'Corresponde à seleção: ${1}',
table_clear_selection: 'Limpar seleção', table_clear_selection: 'Limpar seleção',
@@ -10,6 +10,7 @@ export const ro: TranslationLanguage = {
switch_to_light_theme: 'Comută la tema luminoasă', switch_to_light_theme: 'Comută la tema luminoasă',
switch_to_system_theme: 'Comută la tema sistemului', switch_to_system_theme: 'Comută la tema sistemului',
search: 'Caută', search: 'Caută',
skip_to_content: 'Salt la conținut',
clear: 'Șterge', clear: 'Șterge',
table_filtered_by_selection: 'Se potrivește cu selecția: ${1}', table_filtered_by_selection: 'Se potrivește cu selecția: ${1}',
table_clear_selection: 'Șterge selecția', table_clear_selection: 'Șterge selecția',
@@ -10,6 +10,7 @@ export const ru: TranslationLanguage = {
switch_to_light_theme: 'Переключиться на светлую тему', switch_to_light_theme: 'Переключиться на светлую тему',
switch_to_system_theme: 'Переключиться на системную тему', switch_to_system_theme: 'Переключиться на системную тему',
search: 'Поиск', search: 'Поиск',
skip_to_content: 'Перейти к содержимому',
clear: 'Очистить', clear: 'Очистить',
table_filtered_by_selection: 'Соответствует выбору: ${1}', table_filtered_by_selection: 'Соответствует выбору: ${1}',
table_clear_selection: 'Очистить выбор', table_clear_selection: 'Очистить выбор',
@@ -10,6 +10,7 @@ export const sk: TranslationLanguage = {
switch_to_light_theme: 'Prepnúť na svetlý motív', switch_to_light_theme: 'Prepnúť na svetlý motív',
switch_to_system_theme: 'Prepnúť na systémový motív', switch_to_system_theme: 'Prepnúť na systémový motív',
search: 'Hľadať', search: 'Hľadať',
skip_to_content: 'Preskočiť na obsah',
clear: 'Vymazať', clear: 'Vymazať',
table_filtered_by_selection: 'Zodpovedá výberu: ${1}', table_filtered_by_selection: 'Zodpovedá výberu: ${1}',
table_clear_selection: 'Zrušiť výber', table_clear_selection: 'Zrušiť výber',
@@ -10,6 +10,7 @@ export const sl: TranslationLanguage = {
switch_to_light_theme: 'Preklopi na svetlo temo', switch_to_light_theme: 'Preklopi na svetlo temo',
switch_to_system_theme: 'Preklopi na sistemsko temo', switch_to_system_theme: 'Preklopi na sistemsko temo',
search: 'Išči', search: 'Išči',
skip_to_content: 'Preskoči na vsebino',
clear: 'Počisti', clear: 'Počisti',
table_filtered_by_selection: 'Ustreza izbiri: ${1}', table_filtered_by_selection: 'Ustreza izbiri: ${1}',
table_clear_selection: 'Počisti izbiro', table_clear_selection: 'Počisti izbiro',
@@ -10,6 +10,7 @@ export const sv: TranslationLanguage = {
switch_to_light_theme: 'Byt till ljust tema', switch_to_light_theme: 'Byt till ljust tema',
switch_to_system_theme: 'Byt till systemtema', switch_to_system_theme: 'Byt till systemtema',
search: 'Sök', search: 'Sök',
skip_to_content: 'Hoppa till innehåll',
clear: 'Rensa', clear: 'Rensa',
table_filtered_by_selection: 'Matchar val: ${1}', table_filtered_by_selection: 'Matchar val: ${1}',
table_clear_selection: 'Rensa val', table_clear_selection: 'Rensa val',
@@ -10,6 +10,7 @@ export const th: TranslationLanguage = {
switch_to_light_theme: 'เปลี่ยนเป็นธีมสว่าง', switch_to_light_theme: 'เปลี่ยนเป็นธีมสว่าง',
switch_to_system_theme: 'เปลี่ยนเป็นธีมของระบบ', switch_to_system_theme: 'เปลี่ยนเป็นธีมของระบบ',
search: 'ค้นหา', search: 'ค้นหา',
skip_to_content: 'ข้ามไปยังเนื้อหา',
clear: 'ล้าง', clear: 'ล้าง',
table_filtered_by_selection: 'ตรงกับการเลือก: ${1}', table_filtered_by_selection: 'ตรงกับการเลือก: ${1}',
table_clear_selection: 'ล้างการเลือก', table_clear_selection: 'ล้างการเลือก',
@@ -10,6 +10,7 @@ export const tr: TranslationLanguage = {
switch_to_light_theme: 'Açık temaya geç', switch_to_light_theme: 'Açık temaya geç',
switch_to_system_theme: 'Sistem temasına geç', switch_to_system_theme: 'Sistem temasına geç',
search: 'Ara', search: 'Ara',
skip_to_content: 'İçeriğe geç',
clear: 'Temizle', clear: 'Temizle',
table_filtered_by_selection: 'Seçimle eşleşiyor: ${1}', table_filtered_by_selection: 'Seçimle eşleşiyor: ${1}',
table_clear_selection: 'Seçimi temizle', table_clear_selection: 'Seçimi temizle',
@@ -10,6 +10,7 @@ export const uk: TranslationLanguage = {
switch_to_light_theme: 'Перемкнути на світлу тему', switch_to_light_theme: 'Перемкнути на світлу тему',
switch_to_system_theme: 'Перемкнути на системну тему', switch_to_system_theme: 'Перемкнути на системну тему',
search: 'Пошук', search: 'Пошук',
skip_to_content: 'Перейти до вмісту',
clear: 'Очистити', clear: 'Очистити',
table_filtered_by_selection: 'Відповідає вибору: ${1}', table_filtered_by_selection: 'Відповідає вибору: ${1}',
table_clear_selection: 'Очистити вибір', table_clear_selection: 'Очистити вибір',
@@ -10,6 +10,7 @@ export const vi: TranslationLanguage = {
switch_to_light_theme: 'Chuyển sang giao diện sáng', switch_to_light_theme: 'Chuyển sang giao diện sáng',
switch_to_system_theme: 'Chuyển sang giao diện hệ thống', switch_to_system_theme: 'Chuyển sang giao diện hệ thống',
search: 'Tìm kiếm', search: 'Tìm kiếm',
skip_to_content: 'Chuyển đến nội dung',
clear: 'Xóa', clear: 'Xóa',
table_filtered_by_selection: 'Khớp với lựa chọn: ${1}', table_filtered_by_selection: 'Khớp với lựa chọn: ${1}',
table_clear_selection: 'Xóa lựa chọn', table_clear_selection: 'Xóa lựa chọn',
@@ -10,6 +10,7 @@ export const yue: TranslationLanguage = {
switch_to_light_theme: '切換到淺色主題', switch_to_light_theme: '切換到淺色主題',
switch_to_system_theme: '切換到系統主題', switch_to_system_theme: '切換到系統主題',
search: '搜尋', search: '搜尋',
skip_to_content: '跳至內容',
clear: '清除', clear: '清除',
table_filtered_by_selection: '符合選擇:${1}', table_filtered_by_selection: '符合選擇:${1}',
table_clear_selection: '清除選擇', table_clear_selection: '清除選擇',
@@ -10,6 +10,7 @@ export const zh_tw: TranslationLanguage = {
switch_to_light_theme: '切換至淺色主題', switch_to_light_theme: '切換至淺色主題',
switch_to_system_theme: '切換至系統主題', switch_to_system_theme: '切換至系統主題',
search: '搜尋', search: '搜尋',
skip_to_content: '跳至內容',
clear: '清除', clear: '清除',
table_filtered_by_selection: '符合選擇:${1}', table_filtered_by_selection: '符合選擇:${1}',
table_clear_selection: '清除選擇', table_clear_selection: '清除選擇',
@@ -10,6 +10,7 @@ export const zh: TranslationLanguage = {
switch_to_light_theme: '切换到浅色主题', switch_to_light_theme: '切换到浅色主题',
switch_to_system_theme: '切换到系统主题', switch_to_system_theme: '切换到系统主题',
search: '搜索', search: '搜索',
skip_to_content: '跳转到内容',
clear: '清除', clear: '清除',
table_filtered_by_selection: '符合选择:${1}', table_filtered_by_selection: '符合选择:${1}',
table_clear_selection: '清除选择', table_clear_selection: '清除选择',
+4 -1
View File
@@ -53,11 +53,14 @@ export const Icon = React.forwardRef(function Icon(
const [iconStyle, icon] = getIconStyle(propIconStyle, propIcon); const [iconStyle, icon] = getIconStyle(propIconStyle, propIcon);
const source = context.iconSources?.[getInlineIconSourceKey(iconStyle, icon)]; const source = context.iconSources?.[getInlineIconSourceKey(iconStyle, icon)];
const maskId = React.useId(); const maskId = React.useId();
// Icons are decorative unless the caller names them; the control they sit in carries the name.
const isDecorative = !rest['aria-label'] && !rest['aria-labelledby'] && !rest.role;
if (source) { if (source) {
return ( return (
<svg <svg
ref={ref} ref={ref}
aria-hidden={isDecorative ? true : undefined}
{...rest} {...rest}
viewBox={source.viewBox} viewBox={source.viewBox}
fill="currentColor" fill="currentColor"
@@ -77,6 +80,7 @@ export const Icon = React.forwardRef(function Icon(
return ( return (
<svg <svg
ref={ref} ref={ref}
aria-hidden={isDecorative ? true : undefined}
{...rest} {...rest}
style={{ style={{
...(size ? { width: size, height: size } : {}), ...(size ? { width: size, height: size } : {}),
@@ -84,7 +88,6 @@ export const Icon = React.forwardRef(function Icon(
}} }}
className={`gb-icon ${className}`} className={`gb-icon ${className}`}
> >
<title>{icon}</title>
<defs> <defs>
<mask <mask
id={maskId} id={maskId}