feat(ui): add danger variant to Button component

Added a `danger` variant for destructive actions like delete or remove.
Uses solid red background with white text in both light and dark modes.

- Added CSS styles with custom properties for future token migration
- Updated Storybook stories to include danger variant examples
- Updated docs-ui documentation to reflect the new variant

Signed-off-by: Johan Persson <johanopersson@gmail.com>
This commit is contained in:
Johan Persson
2026-01-28 16:27:01 +01:00
parent 87da9c08b4
commit 2c219b9817
10 changed files with 322 additions and 12 deletions
@@ -59,6 +59,22 @@ export const Disabled = () => {
);
};
export const Destructive = () => {
return (
<Flex gap="4">
<Button variant="primary" destructive>
Primary
</Button>
<Button variant="secondary" destructive>
Secondary
</Button>
<Button variant="tertiary" destructive>
Tertiary
</Button>
</Flex>
);
};
export const Loading = () => {
return (
<Button variant="primary" loading={true}>
+16 -1
View File
@@ -7,6 +7,7 @@ import {
sizesSnippet,
withIconsSnippet,
disabledSnippet,
destructiveSnippet,
loadingSnippet,
asLinkSnippet,
buttonSnippetUsage,
@@ -22,6 +23,7 @@ import {
Sizes,
WithIcons,
Disabled,
Destructive,
Loading,
AsLink,
} from './components';
@@ -32,7 +34,7 @@ export const reactAriaUrls = {
<PageTitle
title="Button"
description="A button with primary, secondary, and tertiary variants and loading state."
description="A button with primary, secondary, and tertiary variants, destructive styling, and loading state."
/>
<Snippet align="center" py={4} preview={<Variants />} code={variantsSnippet} />
@@ -95,6 +97,19 @@ Icons can appear before or after the label.
layout="side-by-side"
/>
### Destructive
Use the `destructive` prop for dangerous actions like delete or remove.
<Snippet
align="center"
py={4}
open
preview={<Destructive />}
code={destructiveSnippet}
layout="side-by-side"
/>
### Loading
Shows a spinner and disables interaction during async operations.
@@ -16,6 +16,12 @@ export const buttonPropDefs: Record<string, PropDef> = {
</>
),
},
destructive: {
type: 'boolean',
default: 'false',
description:
'Applies destructive styling for dangerous actions like delete or remove.',
},
size: {
type: 'enum',
values: ['small', 'medium'],
@@ -43,6 +43,18 @@ export const disabledSnippet = `<Flex gap="4">
</Button>
</Flex>`;
export const destructiveSnippet = `<Flex gap="4">
<Button variant="primary" destructive>
Primary
</Button>
<Button variant="secondary" destructive>
Secondary
</Button>
<Button variant="tertiary" destructive>
Tertiary
</Button>
</Flex>`;
export const loadingSnippet = `<Button variant="primary" loading={true}>
Load more items
</Button>`;