diff --git a/src/lib/components/button/Button.svelte b/src/lib/components/button/Button.svelte
index 06b8accd..35b1324d 100644
--- a/src/lib/components/button/Button.svelte
+++ b/src/lib/components/button/Button.svelte
@@ -34,11 +34,6 @@
export let disableHover = false;
export let ariaLabel: undefined | string = undefined;
- setContext(BUTTON_CONTEXT_ID, {
- button: true,
- size
- });
-
let iconSize = '';
if (size === 'xs') {
iconSize = '16px';
@@ -54,6 +49,11 @@
iconSize = '34px';
}
+ setContext(BUTTON_CONTEXT_ID, {
+ button: true,
+ iconSize
+ });
+
let defaultClass =
'btn group relative inline-flex justify-center items-center font-medium active:hover:animate-none active:hover:scale-95 outline-none';
if (loading) {
diff --git a/src/lib/components/button/Icon.svelte b/src/lib/components/button/Icon.svelte
new file mode 100644
index 00000000..a23c58b5
--- /dev/null
+++ b/src/lib/components/button/Icon.svelte
@@ -0,0 +1,46 @@
+
+
+
diff --git a/src/lib/components/button/index.ts b/src/lib/components/button/index.ts
index 993e8f9d..3826ec32 100644
--- a/src/lib/components/button/index.ts
+++ b/src/lib/components/button/index.ts
@@ -1,12 +1,19 @@
import OriginalButton from './Button.svelte';
import Loader from './Loader.svelte';
+import Icon from './Icon.svelte';
const Button = OriginalButton as ButtonStatic;
Button.Loader = Loader;
+Button.Icon = Icon;
+Button.Leading = Icon;
+Button.Trailing = Icon;
export default Button;
export interface ButtonStatic {
new (...args: ConstructorParameters): OriginalButton;
Loader: typeof Loader;
+ Icon: typeof Icon;
+ Leading: typeof Icon;
+ Trailing: typeof Icon;
}
diff --git a/src/routes/button/+page.svelte b/src/routes/button/+page.svelte
index 824a3bd6..da4aa118 100644
--- a/src/routes/button/+page.svelte
+++ b/src/routes/button/+page.svelte
@@ -8,7 +8,8 @@
exampleShape,
exampleSwap,
props,
- slots
+ slots,
+ iconProps
} from './examples';
import { PropsTable, SlotsTable, CodeBlock } from '../../docs';
import { home } from '../../docs/icons';
@@ -92,27 +93,27 @@
Leading & Trailing
I am primary
@@ -128,7 +129,7 @@
Shape
@@ -152,16 +153,16 @@
Swap Icon
@@ -189,51 +190,51 @@
@@ -247,3 +248,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/routes/button/examples.ts b/src/routes/button/examples.ts
index 922c3169..49c7f54c 100644
--- a/src/routes/button/examples.ts
+++ b/src/routes/button/examples.ts
@@ -61,12 +61,12 @@ export const slots: Slot[] = [
{
id: '1',
slot: 'leading',
- component: ''
+ component: ''
},
{
id: '2',
slot: 'icon',
- component: ''
+ component: ''
},
{
id: '3',
@@ -76,7 +76,58 @@ export const slots: Slot[] = [
{
id: '4',
slot: 'trailing',
- component: ''
+ component: ''
+ }
+];
+
+export const iconProps: Prop[] = [
+ {
+ id: '1',
+ prop: 'data',
+ type: 'string (IconData)',
+ default: ''
+ },
+ {
+ id: '2',
+ prop: 'viewBox',
+ type: 'string',
+ default: '0 0 24 24'
+ },
+ {
+ id: '3',
+ prop: 'size',
+ type: 'string',
+ default: '24px'
+ },
+ {
+ id: '4',
+ prop: 'width',
+ type: 'string',
+ default: '24px'
+ },
+ {
+ id: '5',
+ prop: 'height',
+ type: 'string',
+ default: '24px'
+ },
+ {
+ id: '6',
+ prop: 'color',
+ type: 'string',
+ default: 'currentColor'
+ },
+ {
+ id: '7',
+ prop: 'stroke',
+ type: 'string',
+ default: 'currentColor'
+ },
+ {
+ id: '8',
+ prop: 'fill',
+ type: 'string',
+ default: 'currentColor'
}
];
@@ -115,45 +166,45 @@ export const exampleDisabled = `
export const exampleLeadingTrailing = `
`;
export const exampleShape = `
@@ -176,16 +227,16 @@ export const exampleSwap = `
`;