Buttons
Overview
This page is an example on how to document your button components.
Find the code for this page in the src/pages/components/buttons/index.astro file.
Copied !
\n\n\nRounded \n\n \n \n\n\n\n \n");
let timeout;
visible = true;
timeout = setTimeout(() => visible = false, 2500);
">Copy
---
import Button from "$components/button/Button.astro";
import PrimaryButton from "$components/button/primary/PrimaryButton.astro";
import SecondaryButton from "$components/button/secondary/SecondaryButton.astro";
import SuccessButton from "$components/button/success/SuccessButton.astro";
import WarningButton from "$components/button/warning/WarningButton.astro";
---
<Button>With Slot</Button>
<Button text="With text props" />
<Button text="Disabled" disabled />
<PrimaryButton>Rounded</PrimaryButton>
<Button borderRadius="square" text="Square" />
<SuccessButton borderRadius="arc" text="With Arc borderRadius" />
<SecondaryButton borderRadius="curve" text="Curve" />
<Button variant="outlined" text="Base button outlined" />
<Button variant="inversed" text="Base button inversed" />
<Button class="bg-slate-300 text-slate-800 p-4" borderRadius="pill">
Pill borderRadius with custom class
</Button>
<WarningButton borderRadius="circle" text="Circle" />
Alpine interop
We can use alpine properties such as @click or x:on-click.
Copied !
\n");
let timeout;
visible = true;
timeout = setTimeout(() => visible = false, 2500);
">Copy
---
import Button from "$components/button/Button.astro";
---
<Button @click="console.log('clicked')" text="Click Me" />
Primary button
We use the primary button for main actions like saving a form or creating a new item.
Copied !
\n \n \n");
let timeout;
visible = true;
timeout = setTimeout(() => visible = false, 2500);
">Copy
---
import PrimaryButton from "$components/button/primary/PrimaryButton.astro";
---
<PrimaryButton text="Primary Button" />
<PrimaryButton variant="outlined" text="Primary Outlined" />
<PrimaryButton variant="inversed" text="Primary Inversed" />
Secondary button
Secondary buttons accompany primary buttons to provide additional actions. For example, cancel buttons are secondary buttons.
Copied !
\n \n \n");
let timeout;
visible = true;
timeout = setTimeout(() => visible = false, 2500);
">Copy
---
import SecondaryButton from "$components/button/secondary/SecondaryButton.astro";
---
<SecondaryButton text="Secondary Button" />
<SecondaryButton variant="outlined" text="Secondary Outlined" />
<SecondaryButton variant="inversed" text="Secondary Inversed" />
Success button
Success buttons give positive attempt to actions.
Copied !
\n \n \n");
let timeout;
visible = true;
timeout = setTimeout(() => visible = false, 2500);
">Copy
---
import SuccessButton from "$components/button/success/SuccessButton.astro";
---
<SuccessButton text="Success Button" />
<SuccessButton variant="outlined" text="Success Outlined" />
<SuccessButton variant="inversed" text="Success Inversed" />
Danger button
Danger buttons are useful to prevent/cancel actions.
Copied !
\n \n \n");
let timeout;
visible = true;
timeout = setTimeout(() => visible = false, 2500);
">Copy
---
import DangerButton from "$components/button/danger/DangerButton.astro";
---
<DangerButton text="Danger Button" />
<DangerButton variant="outlined" text="Danger Outlined" />
<DangerButton variant="inversed" text="Danger Inversed" />
Info button
Info buttons are mostly used for informative actions.
Copied !
\n \n \n");
let timeout;
visible = true;
timeout = setTimeout(() => visible = false, 2500);
">Copy
---
import InfoButton from "$components/button/info/InfoButton.astro";
---
<InfoButton text="Info Button" />
<InfoButton variant="outlined" text="Info Outlined" />
<InfoButton variant="inversed" text="Info Inversed" />
Warning button
Warning buttons are often used for risky actions.
Copied !
\n \n \n");
let timeout;
visible = true;
timeout = setTimeout(() => visible = false, 2500);
">Copy
---
import WarningButton from "$components/button/warning/WarningButton.astro";
---
<WarningButton text="Warning Button" />
<WarningButton variant="outlined" text="Warning Outlined" />
<WarningButton variant="inversed" text="Warning Inversed" />