diff --git a/src/lib/components/tab.svelte b/src/lib/components/tab.svelte
index 246d9db0d..db46fb6b2 100644
--- a/src/lib/components/tab.svelte
+++ b/src/lib/components/tab.svelte
@@ -1,5 +1,6 @@
{#if href}
-
+
{:else}
@@ -22,7 +82,10 @@
class="tabs-button"
class:is-selected={selected}
on:click|preventDefault
- on:click={track}>
+ on:click={track}
+ tabindex={selected ? 0 : -1}
+ on:keydown={handleKeyDown}
+ role="tab">
{/if}
diff --git a/src/lib/helpers/style.ts b/src/lib/helpers/style.ts
new file mode 100644
index 000000000..fef15c8cc
--- /dev/null
+++ b/src/lib/helpers/style.ts
@@ -0,0 +1,16 @@
+type Direction = 'rtl' | 'ltr';
+
+function isDirection(dir: string): dir is Direction {
+ return dir === 'rtl' || dir === 'ltr';
+}
+
+function parseDirection(dir: string): Direction {
+ return isDirection(dir) ? dir : 'ltr';
+}
+
+export function getElementDir(el: HTMLElement): Direction {
+ if (window.getComputedStyle) {
+ return parseDirection(window.getComputedStyle(el, null).getPropertyValue('direction'));
+ }
+ return parseDirection(el.style.direction);
+}