Tabs
Switches between views without leaving the page, with the active line gliding
from one tab to the next instead of jumping. This is the tabs component
here — import Tabs from the design system and use it the way you would use
Mantine's.
@mantine/core exports this name too — that one is a different component.@mantine/coreBoth packages export a Tabs, and the wrong one compiles. Mantine's is themed
by the same stylesheet, so it looks almost right — it just draws the active line
as a static border on each tab, with none of the motion, and has no
transitionDuration or fill.
Editor autocomplete will offer @mantine/core first, because it is a direct
dependency of your app. The lint rule under
Keeping the import honest is what makes the
mistake impossible rather than merely documented.
Mantine's own Tabs stays available and supported — see
Tabs (native) — but reach for it deliberately, when the
motion is unwanted.
TabsOur Tabs renders Mantine's underneath and forwards its full prop set — every
Mantine Tabs prop keeps working, controlled and uncontrolled both work. It
adds two props of its own: transitionDuration on the root, and fill on
Tabs.List.
Its compound sub-components stand in for Mantine's:
Tabs.List— forTabs.ListTabs.Tab— forTabs.TabTabs.Panel— Mantine'sTabs.Panel, re-exported unchanged
Both are styled by the same tab.module.css.
Usage
Tabs is a compound component: import it once and use its own .List, .Tab
and .Panel.
<Tabs defaultValue="oversikt" orientation="horizontal">
<Tabs.List>
<Tabs.Tab value="oversikt">Oversikt</Tabs.Tab>
<Tabs.Tab value="detaljer">Detaljer</Tabs.Tab>
<Tabs.Tab value="innstillinger">Innstillinger</Tabs.Tab>
</Tabs.List>
<Tabs.Panel value="oversikt" mt="sm">Oversikt-innhold</Tabs.Panel>
<Tabs.Panel value="detaljer" mt="sm">Detaljer-innhold</Tabs.Panel>
<Tabs.Panel value="innstillinger" mt="sm">Innstillinger-innhold</Tabs.Panel>
</Tabs>
The mt="sm" on each panel is not part of the component. Tabs puts no space
between the tab list and the panel — that gap is layout, so the page using it
decides how much. The example sets 8px.
Keeping the import honest
Nothing in TypeScript stops a call site from importing Tabs from
@mantine/core and getting the static line by accident. A lint rule does, and
it belongs in the consuming project's ESLint config — this package cannot
install it for you:
// eslint.config.js
'no-restricted-imports': ['error', {
paths: [{
name: '@mantine/core',
importNames: ['Tabs', 'MultiSelect', 'Select', 'TextInput'],
message: 'Importer denne fra @multiconsult-group-products/design-system — Mantines versjon mangler de tilførte propsene.',
}],
}],
The other names are on the list for the same reason: they keep the name of the Mantine component they replace. See All components for the full set.
To use Mantine's Tabs on purpose in a project with this rule, import it under
another name and say why:
// Static line wanted here — no travelling indicator.
import { Tabs as NativeTabs } from '@mantine/core';
Props
Only the delta from Mantine's Tabs — see
the native page's props table for everything that passes
through unchanged.
| Property | Type | Allowed values | Default | Description |
|---|---|---|---|---|
transitionDuration | number | — | 200 | How long the indicator takes to glide to the newly active tab, in ms. Passed straight to the underlying FloatingIndicator; the default is the shared Duration.base token. |
classNames / styles / vars | Styles API | indicator | — | Typed against our own Styles API, not Mantine's — the travelling line is the only part we own. The list, tab and panel parts are still styled in tab.module.css, shared with the native component. |
variant | string | — | — | Reaches Mantine's Tabs underneath, retyped as a plain string instead of Mantine's literal union so the two factories' types don't collide. Same caveat as the native one: only the default variant is styled. |
Tabs.List | — | — | — | Drop-in for Mantine's Tabs.List. Sets data-indicator on the list, which tells tab.module.css to keep the active tab's own border grey so the indicator draws the active line instead. |
fill (on Tabs.List) | boolean | — | false | Extends the grey line across the full width of the list, past the last tab. Off by default — the line is normally each tab's own border and stops where the tabs stop. See Fill and grow. |
grow (on Tabs.List) | boolean | — | false | Mantine's own Tabs.List prop, passed through: stretches the tabs to share the full width. Not a way to extend the line — see Fill and grow. |
Tabs.Tab | — | — | — | Drop-in for Mantine's Tabs.Tab. Registers its DOM node under value so FloatingIndicator has a target to fly to — otherwise identical. |
The indicator itself is one element, sized to the active tab and moved with a
transform. Its edge follows the layout: bottom border in horizontal
orientation, right or left border in vertical (mirroring Mantine's
placement), top border when inverted.
DsTabsTo set project-wide defaults through MantineProvider, the key is DsTabs —
not Tabs, which Mantine's own component already owns:
components: {
DsTabs: Tabs.extend({ defaultProps: { transitionDuration: 0 } }),
}
The sub-components are DsTabsList and DsTabsTab. This is the one place the
name cannot simply be Tabs: theme.components is a flat map of plain strings,
so sharing the key would hand this component a set of classNames written for
selectors it does not have. Chip is registered as DsChip for the same
reason.
Fill and grow
The two are easy to confuse and do different things. Both sit on Tabs.List.
By default a tab list draws no continuous baseline: each tab carries its own 1px border, so the grey line is exactly as wide as the tabs put together and stops after the last one. That is the design system's normal look.
grow stretches the tabs. Three tabs in a wide container become three wide
tabs, each label centred in its share of the space. Their borders meet, so the
line does end up spanning the width — but the tabs are no longer sized to their
labels. Reach for it when the tabs really are meant to divide the width, not to
fix the line.
fill leaves the tabs alone and extends the line. The tabs stay at their
natural width on the left, and one continuous 1px line runs to the right edge
of the list. It restores Mantine's own list baseline, which the design system
otherwise switches off — a pseudo-element, not a DOM node, so it adds nothing
to the accessibility tree. The line follows the layout the same way the
indicator does: bottom edge in horizontal orientation, top when inverted,
the inline edge in vertical.
Under the tabs the baseline and each tab's own border land on the same pixel,
so fill changes nothing there — including the hover border, which still grows
from 1px to 2px. Under the active tab, where the border is grey so the
indicator can draw the active line over it, the baseline and the border sit on
the same pixel and the blue indicator lands on top of both.
Accessibility
The tab list and tabs are Mantine's own Tabs.List / Tabs.Tab underneath, so
the same WAI-ARIA tabs pattern and keyboard behaviour apply — see
the native page's accessibility notes. The
travelling indicator adds one extra DOM node inside the tab list; it is marked
aria-hidden, so it never reaches the accessibility tree and the list still
reads as tabs only.