diff --git a/src/components/tab-title/tab-title.scss b/src/components/tab-title/tab-title.scss index 2cd2101d851..380011995fa 100644 --- a/src/components/tab-title/tab-title.scss +++ b/src/components/tab-title/tab-title.scss @@ -7,7 +7,40 @@ :host([layout="center"]) { @apply my-0 mx-5 text-center; flex-basis: theme("spacing.48"); - margin: auto; + .content { + @apply m-auto; + } +} + +// center the text visually and not affected by the x button so as to avoid moving when on or off +:host([layout="center"][closable]) { + .content { + padding-inline-start: 32px; //28px button width + 0.25rem padding + } +} + +:host([layout="center"][bordered][closable][scale="s"]) { + .content { + padding-inline-start: 36px; //28px button width + 0.5rem padding + } +} + +:host([layout="center"][bordered][closable][scale="m"]) { + .content { + padding-inline-start: 40px; //28px button width + 0.75rem padding + } +} + +:host([layout="center"][closable][scale="l"]) { + .content { + padding-inline-start: 40px; //36px button width + .25 padding + } +} + +:host([layout="center"][closable][bordered][scale="l"]) { + .content { + padding-inline-start: 52px; //36px button width + 1rem padding + } } :host([position="bottom"]) .container { @@ -192,9 +225,15 @@ :host([closable]) .container, :host([bordered]) .container { - border-block-end-style: unset; border-inline-start: 1px solid transparent; border-inline-end: 1px solid transparent; + .close-button { + margin-inline: 0; + } +} + +:host([closable]) .content { + @apply h-full box-border border-b-color-transparent; } :host([closable][position="bottom"]) .container, diff --git a/src/components/tabs/tabs.stories.ts b/src/components/tabs/tabs.stories.ts index dbc13676ec3..e35a4863f10 100644 --- a/src/components/tabs/tabs.stories.ts +++ b/src/components/tabs/tabs.stories.ts @@ -184,6 +184,55 @@ export const disabledTabsAndMediumIconsForLargeTabsTitle_TestOnly = (): string = `; +export const centered_TestOnly = (): string => html` + + + Tab 1 Title + Tab 2 Title + Tab 3 Title + Tab 4 Title + +

Tab 1 Content

+

Tab 2 Content

+

Tab 3 Content

+

Tab 4 Content

+
+`; + +export const centeredClosable_TestOnly = (): string => html` + + + Tab 1 Title + Tab 2 Title + Tab 3 Title + Tab 4 Title + +

Tab 1 Content

+

Tab 2 Content

+

Tab 3 Content

+

Tab 4 Content

+
+`; + +export const centeredBorderedClosable_TestOnly = (): string => html` + + + Tab 1 Title + Tab 2 Title + Tab 3 Title + Tab 4 Title + +

Tab 1 Content

+

Tab 2 Content

+

Tab 3 Content

+

Tab 4 Content

+
+`; + export const TabChildrenWithPercentageHeights = (): string => html`