Loading...
Loading...
Apply the Lightdash frontend style guide when working on React components, migrating Mantine v6 to v8, or styling frontend code. Use when editing TSX files, fixing styling issues, or when user mentions Mantine, styling, or CSS modules.
npx skill4agent add lightdash/lightdash frontend-style-guidepackages/frontend/@mantine-8/corestylestylessx--mantine-color-${color}-text--mantine-color-${color}-filled--mantine-color-${color}-filled-hover--mantine-color-${color}-light--mantine-color-${color}-light-hover--mantine-color-${color}-light-color--mantine-color-${color}-outline--mantine-color-${color}-outline-hover// ❌ Mantine 6
import { Button, Group } from '@mantine/core';
<Group spacing="xs" noWrap>
<Button sx={{ mt: 20 }}>Click</Button>
</Group>;
// ✅ Mantine 8
import { Button, Group } from '@mantine-8/core';
<Group gap="xs" wrap="nowrap">
<Button mt={20}>Click</Button>
</Group>;spacinggapnoWrapwrap="nowrap"sxmtwcleftIconleftSectionrightIconrightSectionmantine8Theme.tsmt="xl" w={240}stylessxstylemantine8Theme.ts// In src/mantine8Theme.ts - inside the components object
components: {
Button: Button.extend({
styles: {
root: {
minWidth: '120px',
fontWeight: 600,
}
}
}),
}// ✅ Good
<Button mt="xl" w={240} c="blue.6">Submit</Button>
// ❌ Bad - Too many props, use CSS modules instead
<Button mt={20} mb={20} ml={10} mr={10} w={240} c="blue.6" bg="white">Submit</Button>mtmbmlmrmpptpbplprwhmawmahmiwmihcbgfffsfwtalh.module.css/* Component.module.css */
.customCard {
transition: transform 0.2s ease;
cursor: pointer;
}
.customCard:hover {
transform: translateY(-2px);
box-shadow: var(--mantine-shadow-lg);
}import styles from './Component.module.css';
<Card className={styles.customCard}>{/* content */}</Card>;.css.d.ts// ❌ Bad - Standard Mantine colors (poor dark mode support)
<Text c="gray.6">Secondary text</Text>
// ✅ Good - ldGray for borders and neutral elements
<Text c="ldGray.6">Secondary text</Text>
// ✅ Good - ldDark for elements that appear dark in light mode
<Button bg="ldDark.8" c="ldDark.0">Dark button</Button>
// ✅ Good - Foreground/background variables
<Text c="foreground">Primary text</Text>
<Box bg="background">Main background</Box>| Token | Purpose |
|---|---|
| Borders, subtle text, neutral UI elements |
| Buttons/badges with dark backgrounds in light mode |
| Page/card backgrounds |
| Primary text color |
@mixin dark.clickableRow {
&:hover {
background-color: var(--mantine-color-ldGray-0);
@mixin dark {
background-color: var(--mantine-color-ldDark-5);
}
}
}light-dark().clickableRow:hover {
background-color: light-dark(
var(--mantine-color-ldGray-0),
var(--mantine-color-ldDark-5)
);
}// ❌ Bad - Magic numbers
<Box p={16} mt={24}>
// ✅ Good - Theme tokens
<Box p="md" mt="lg">// ❌ Unnecessary - display: block has no effect on flex children
<Flex justify="flex-end">
<Button style={{display: 'block'}}>Submit</Button>
</Flex>
// ✅ Better - Remove the style entirely
<Flex justify="flex-end">
<Button>Submit</Button>
</Flex>import { useMantineColorScheme } from '@mantine/core';
const MyComponent = () => {
const { colorScheme } = useMantineColorScheme();
const iconColor = colorScheme === 'dark' ? 'blue.4' : 'blue.6';
// ...
};import { clsx } from '@mantine/core';
const MyComponent = () => {
return (
<div className={clsx('my-class', 'my-other-class')}>My Component</div>
);
};<Select
label="Your favorite library"
placeholder="Pick value"
data={[
{ group: 'Frontend', items: ['React', 'Angular'] },
{ group: 'Backend', items: ['Express', 'Django'] },
]}
/>MantineModalcomponents/common/MantineModalstories/Modal.stories.tsxidform="form-id"CalloutdangerwarninginfoCalloutcomponents/common/Calloutdangerwarninginfo<button>PolymorphicGroupButtoncomponents/common/PolymorphicGroupButtonGroupcursor: pointerPolymorphicPaperButtoncomponents/common/PolymorphicPaperButtonPapercursor: pointerGroupPropsPaperPropscomponent// ✅ Clickable row without native button style bleed
<PolymorphicGroupButton component="div" gap="sm" onClick={handleClick}>
<MantineIcon icon={IconFolder} />
<Text>Label</Text>
</PolymorphicGroupButton>
// ✅ Clickable card surface
<PolymorphicPaperButton component="div" p="md" onClick={handleClick}>
Card content
</PolymorphicPaperButton>
// ❌ Avoid - native <button> brings unwanted background/border in menus and panels
<UnstyledButton>
<Group>...</Group>
</UnstyledButton>EmptyStateLoadercomponents/common/EmptyStateLoaderSuboptimalStateTruncatedTextcomponents/common/TruncatedTextmaxWidthfz="sm"Text// ✅ Good - truncates long names, tooltip only appears when needed
<TruncatedText maxWidth={200}>{item.name}</TruncatedText>
// ✅ Accepts any Text prop
<TruncatedText maxWidth="100%" fw={500}>{space.name}</TruncatedText>https://mantine.dev/llms.txt